Skip to content

Commit

Permalink
policy: Fix missing labels from SelectorCache selectors
Browse files Browse the repository at this point in the history
During the refactor of the below commit, it seems the labels were left
out inadvertently, breaking the `cilium policy selectors` command that
displays the labels/name of the policy from which the selectors
originate from.

Fixes: 501944c ("policy/selectorcache: invert identitySelector interface")

Signed-off-by: Chris Tarazi <chris@isovalent.com>
  • Loading branch information
christarazi committed Mar 14, 2024
1 parent 787858c commit 65bbf3f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/policy/selectorcache.go
Expand Up @@ -397,15 +397,16 @@ func (sc *SelectorCache) AddFQDNSelector(user CachedSelectionUser, lbls labels.L
currentIPs := sc.localIdentityNotifier.RegisterForIPUpdatesLocked(source.selector)
source.setSelectorIPs(currentIPs)

return sc.addSelector(user, key, source)
return sc.addSelector(user, lbls, key, source)
}

func (sc *SelectorCache) addSelector(user CachedSelectionUser, key string, source selectorSource) (CachedSelector, bool) {
func (sc *SelectorCache) addSelector(user CachedSelectionUser, lbls labels.LabelArray, key string, source selectorSource) (CachedSelector, bool) {
idSel := &identitySelector{
key: key,
users: make(map[CachedSelectionUser]struct{}),
cachedSelections: make(map[identity.NumericIdentity]struct{}),
source: source,
metadataLbls: lbls,
}
sc.selectors[key] = idSel

Expand Down Expand Up @@ -467,7 +468,7 @@ func (sc *SelectorCache) AddIdentitySelector(user CachedSelectionUser, lbls labe
source.namespaces = namespaces
}

return sc.addSelector(user, key, source)
return sc.addSelector(user, lbls, key, source)
}

// lock must be held
Expand Down

0 comments on commit 65bbf3f

Please sign in to comment.