Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use labels.ValidatedSetSelector #319

Merged
merged 1 commit into from
Mar 11, 2024
Merged
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
6 changes: 3 additions & 3 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ func (lbc *LoadBalancerController) podReferenced(ctx context.Context, pod *corev

if !lbc.internalDefaultBackend {
if svc, err := lbc.svcLister.Services(lbc.defaultSvc.Namespace).Get(lbc.defaultSvc.Name); err == nil {
if labels.Set(svc.Spec.Selector).AsSelector().Matches(labels.Set(pod.Labels)) {
if labels.ValidatedSetSelector(svc.Spec.Selector).Matches(labels.Set(pod.Labels)) {
log.V(4).Info("Referenced by default Service", "pod", klog.KObj(pod), "service", lbc.defaultSvc)
return true
}
Expand All @@ -816,7 +816,7 @@ func (lbc *LoadBalancerController) podReferenced(ctx context.Context, pod *corev
if !lbc.noDefaultBackendOverride {
if isb := getDefaultBackendService(ing); isb != nil {
if svc, err := lbc.svcLister.Services(pod.Namespace).Get(isb.Name); err == nil {
if labels.Set(svc.Spec.Selector).AsSelector().Matches(labels.Set(pod.Labels)) {
if labels.ValidatedSetSelector(svc.Spec.Selector).Matches(labels.Set(pod.Labels)) {
log.V(4).Info("Referenced by Ingress", "pod", klog.KObj(pod),
"ingress", klog.KObj(ing), "service", klog.KObj(svc))
return true
Expand All @@ -839,7 +839,7 @@ func (lbc *LoadBalancerController) podReferenced(ctx context.Context, pod *corev
if err != nil {
continue
}
if labels.Set(svc.Spec.Selector).AsSelector().Matches(labels.Set(pod.Labels)) {
if labels.ValidatedSetSelector(svc.Spec.Selector).Matches(labels.Set(pod.Labels)) {
log.V(4).Info("Referenced by Ingress", "pod", klog.KObj(pod),
"ingress", klog.KObj(ing), "service", klog.KObj(svc))
return true
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,7 @@ func TestGetLoadBalancerIngressSelector(t *testing.T) {
f.preparePod(po1)
f.setupStore()

lbIngs, err := f.lc.getLoadBalancerIngressSelector(context.Background(), labels.Set(defaultIngPodLables).AsSelector())
lbIngs, err := f.lc.getLoadBalancerIngressSelector(context.Background(), labels.ValidatedSetSelector(defaultIngPodLables))

f.verifyActions()

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func podLabelSelector(labelSet map[string]string) labels.Selector {
}
l[k] = v
}
return labels.Set(l).AsSelector()
return labels.ValidatedSetSelector(l)
}

// validateIngressClass checks whether this controller should process ing or not.
Expand Down