Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1620 from gellweiler/master
Browse files Browse the repository at this point in the history
Continue when k8s returns Forbidden when getting resources of resourc…
  • Loading branch information
squaremo authored Dec 31, 2018
2 parents f0eac80 + ae977c6 commit 9ce57ef
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions cluster/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,18 @@ func (c *Cluster) AllControllers(namespace string) (res []cluster.Controller, er
for kind, resourceKind := range resourceKinds {
podControllers, err := resourceKind.getPodControllers(c, ns.Name)
if err != nil {
if se, ok := err.(*apierrors.StatusError); ok && se.ErrStatus.Reason == meta_v1.StatusReasonNotFound {
// Kind not supported by API server, skip
continue
if se, ok := err.(*apierrors.StatusError); ok {
switch (se.ErrStatus.Reason) {
case meta_v1.StatusReasonNotFound:
// Kind not supported by API server, skip
continue
case meta_v1.StatusReasonForbidden:
// K8s can return forbidden instead of not found for non super admins
c.logger.Log("warning", "not allowed to list resources", "err", err)
continue
default:
return nil, err
}
} else {
return nil, err
}
Expand Down Expand Up @@ -281,9 +290,18 @@ func (c *Cluster) Export() ([]byte, error) {
for _, resourceKind := range resourceKinds {
podControllers, err := resourceKind.getPodControllers(c, ns.Name)
if err != nil {
if se, ok := err.(*apierrors.StatusError); ok && se.ErrStatus.Reason == meta_v1.StatusReasonNotFound {
// Kind not supported by API server, skip
continue
if se, ok := err.(*apierrors.StatusError); ok {
switch (se.ErrStatus.Reason) {
case meta_v1.StatusReasonNotFound:
// Kind not supported by API server, skip
continue
case meta_v1.StatusReasonForbidden:
// K8s can return forbidden instead of not found for non super admins
c.logger.Log("warning", "not allowed to list resources", "err", err)
continue
default:
return nil, err
}
} else {
return nil, err
}
Expand Down

0 comments on commit 9ce57ef

Please sign in to comment.