Skip to content

Commit

Permalink
feat(must gather): add debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Aug 23, 2022
1 parent ea625b7 commit 8ea6b93
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rhoc/pkg/util/kubernetes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,22 @@ func (in *Client) List(resources []schema.GroupVersionResource, options metav1.L
}

resList, err := dc.Resource(gvr).List(in.f.Context, options)

if err != nil {
switch {
case kerr.IsUnauthorized(err):
in.f.Logger.Errorf("Unauthorized access to %s:%s", gvr.GroupVersion(), gvr.Resource)
in.f.Logger.Debugf("unauthorized access to %s:%s", gvr.GroupVersion(), gvr.Resource)
continue
case kerr.IsForbidden(err):
in.f.Logger.Errorf("Forbidden access to %s:%s", gvr.GroupVersion(), gvr.Resource)
in.f.Logger.Debugf("forbidden access to %s:%s", gvr.GroupVersion(), gvr.Resource)
continue
default:
in.f.Logger.Debugf("error listing %s:%s, %s", gvr.GroupVersion(), gvr.Resource, err.Error())
return nil, err
}
}

in.f.Logger.Debugf("found %d %s:%s resources", len(resList.Items), gvr.GroupVersion(), gvr.Resource)

for i := range resList.Items {
// remove managed fields as they are only making noise
resList.Items[i].SetManagedFields(nil)
Expand Down

0 comments on commit 8ea6b93

Please sign in to comment.