Print warning only instead of error if no permission on ingressclass (#7578)

* skip ingressclass check if ingressclass is not enabled

* reformat with gofmt
This commit is contained in:
emerson 2021-10-11 03:48:37 +08:00 committed by GitHub
parent 710d0db9a5
commit 6499393772
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 10 deletions

View file

@ -110,8 +110,11 @@ func main() {
_, err = kubeClient.NetworkingV1().IngressClasses().List(context.TODO(), metav1.ListOptions{})
if err != nil {
if !errors.IsNotFound(err) {
if errors.IsUnauthorized(err) || !errors.IsForbidden(err) {
if errors.IsUnauthorized(err) {
klog.Fatalf("Error searching IngressClass: Please verify your RBAC and allow Ingress Controller to list and get Ingress Classes: %v", err)
} else if errors.IsForbidden(err) {
klog.Warningf("No permissions to list and get Ingress Classes: %v, IngressClass feature will be disabled", err)
conf.IngressClassConfiguration.IgnoreIngressClass = true
}
}
}