Skip to content

Commit

Permalink
Don't throw annotation deprication warning when ingressClassName is…
Browse files Browse the repository at this point in the history
… not used in an Ingress resource (#4564)

Signed-off-by: Shaun <[email protected]>
  • Loading branch information
shaun-nx authored Nov 2, 2023
1 parent 7a1e600 commit 8a93be8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/k8s/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3980,7 +3980,7 @@ func (lbc *LoadBalancerController) HasCorrectIngressClass(obj interface{}) bool
class = obj.Annotations[ingressClassKey]
if class == "" && obj.Spec.IngressClassName != nil {
class = *obj.Spec.IngressClassName
} else {
} else if class != "" {
// the annotation takes precedence over the field
glog.Warningln("Using the DEPRECATED annotation 'kubernetes.io/ingress.class'. The 'ingressClassName' field will be ignored.")
}
Expand Down
10 changes: 10 additions & 0 deletions internal/k8s/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ func TestHasCorrectIngressClass(t *testing.T) {
},
true,
},
{
&LoadBalancerController{
ingressClass: ingressClass,
metricsCollector: collectors.NewControllerFakeCollector(),
},
&networking.Ingress{
Spec: networking.IngressSpec{},
},
false,
},
}

for _, test := range tests {
Expand Down

0 comments on commit 8a93be8

Please sign in to comment.