Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit 7992f7a

Browse files
committed
Fix hierarchy conflict validation excluding non-propagated objects
1 parent b03328e commit 7992f7a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

internal/validators/hierarchy.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
api "sigs.k8s.io/hierarchical-namespaces/api/v1alpha2"
2323
"sigs.k8s.io/hierarchical-namespaces/internal/config"
2424
"sigs.k8s.io/hierarchical-namespaces/internal/forest"
25+
"sigs.k8s.io/hierarchical-namespaces/internal/pkg/selectors"
2526
)
2627

2728
const (
@@ -250,11 +251,12 @@ func (v *Hierarchy) getConflictingObjectsOfType(gvk schema.GroupVersionKind, new
250251
// Get all the source objects in the new ancestors that would be propagated
251252
// into the descendants.
252253
newAnsSrcObjs := make(map[string]bool)
253-
// TODO additionally check if the ancestor source objects obey the
254-
// 'shouldPropagateSource()' rules from the reconcilers/object.go. Only
255-
// propagatable ancestor source would cause overwriting conflict.
256254
for _, o := range newParent.GetAncestorSourceObjects(gvk, "") {
257-
newAnsSrcObjs[o.GetName()] = true
255+
// If the user has chosen not to propagate the object to this descendant,
256+
// then it should not be included in conflict checks
257+
if ok, _ := selectors.ShouldPropagate(o, o.GetLabels()); ok {
258+
newAnsSrcObjs[o.GetName()] = true
259+
}
258260
}
259261

260262
// Look in the descendants to find if there's any conflict.

0 commit comments

Comments
 (0)