compare error with error types from k8s.io/apimachinery/pkg/api/errors
Signed-off-by: Guihua Zhu <zhuguihua@cmss.chinamobile.com>
This commit is contained in:
parent
ea89d27b5d
commit
bb41a9d56f
1 changed files with 2 additions and 3 deletions
|
@ -24,13 +24,13 @@ import (
|
||||||
"net/http/pprof"
|
"net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
discovery "k8s.io/apimachinery/pkg/version"
|
discovery "k8s.io/apimachinery/pkg/version"
|
||||||
|
@ -94,8 +94,7 @@ func main() {
|
||||||
|
|
||||||
_, err = kubeClient.CoreV1().Services(defSvcNs).Get(defSvcName, metav1.GetOptions{})
|
_, err = kubeClient.CoreV1().Services(defSvcNs).Get(defSvcName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO (antoineco): compare with error types from k8s.io/apimachinery/pkg/api/errors
|
if errors.IsUnauthorized(err) || errors.IsForbidden(err) {
|
||||||
if strings.Contains(err.Error(), "cannot get services in the namespace") {
|
|
||||||
klog.Fatal("✖ The cluster seems to be running with a restrictive Authorization mode and the Ingress controller does not have the required permissions to operate normally.")
|
klog.Fatal("✖ The cluster seems to be running with a restrictive Authorization mode and the Ingress controller does not have the required permissions to operate normally.")
|
||||||
}
|
}
|
||||||
klog.Fatalf("No service with name %v found: %v", conf.DefaultService, err)
|
klog.Fatalf("No service with name %v found: %v", conf.DefaultService, err)
|
||||||
|
|
Loading…
Reference in a new issue