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

Commit

Permalink
Continue when k8s returns Forbidden when getting resources of resourc…
Browse files Browse the repository at this point in the history
…e type.
  • Loading branch information
Sebastian Tom Gellweiler committed Dec 28, 2018
1 parent f0eac80 commit 8465a4b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cluster/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,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 8465a4b

Please sign in to comment.