Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/cache/references.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"

synccommon "github.com/argoproj/gitops-engine/pkg/sync/common"
syncresource "github.com/argoproj/gitops-engine/pkg/sync/resource"
"github.com/argoproj/gitops-engine/pkg/utils/kube"
)

Expand All @@ -23,6 +25,16 @@ func (c *clusterCache) resolveResourceReferences(un *unstructured.Unstructured)
ownerRefs := un.GetOwnerReferences()
gvk := un.GroupVersionKind()

if syncresource.HasAnnotationOption(un, synccommon.AnnotationSyncOptions, synccommon.SyncOptionControllerReferencesOnly) {
controllerOwnerRefs := []metav1.OwnerReference{}
for _, ownerRef := range un.GetOwnerReferences() {
if ownerRef.Controller != nil && *ownerRef.Controller {
controllerOwnerRefs = append(controllerOwnerRefs, ownerRef)
}
}
return controllerOwnerRefs, isInferredParentOf
}

switch {
// Special case for endpoint. Remove after https://github.com/kubernetes/kubernetes/issues/28483 is fixed
case gvk.Group == "" && gvk.Kind == kube.EndpointsKind && len(ownerRefs) == 0:
Expand Down
2 changes: 2 additions & 0 deletions pkg/sync/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const (
SyncOptionClientSideApplyMigration = "ClientSideApplyMigration=true"
// Sync option that disables client-side apply migration
SyncOptionDisableClientSideApplyMigration = "ClientSideApplyMigration=false"
// Sync option that means only controller owner references are respected
SyncOptionControllerReferencesOnly = "ControllerReferencesOnly=true"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious how this options can become the default. Is there a concept in the Argo project as feature gates.

eg. where it's opt-in and then the flag get's switched to opt out?


// Default field manager for client-side apply migration
DefaultClientSideApplyMigrationManager = "kubectl-client-side-apply"
Expand Down