Skip to content

Commit

Permalink
fix: ignore nodes when listing permission is not allowed (#374)
Browse files Browse the repository at this point in the history
* fix: ignore nodes when listing permission is not allowed

Signed-off-by: chenk <hen.keinan@gmail.com>

* fix: ignore nodes when listing permission is not allowed

Signed-off-by: chenk <hen.keinan@gmail.com>

---------

Signed-off-by: chenk <hen.keinan@gmail.com>
  • Loading branch information
chen-keinan authored Jul 7, 2024
1 parent cf9d488 commit 0300bc4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/opencontainers/go-digest"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
k8sapierror "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -481,7 +482,11 @@ func GetContainer(hex string, imageName containerimage.Reference) (bom.Container
func (c *cluster) CollectNodes(components []bom.Component) ([]bom.NodeInfo, error) {
nodes, err := c.clientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{})
if err != nil {
return []bom.NodeInfo{}, err
if errors.IsNotFound(err) || errors.IsForbidden(err) {
slog.Error("Unable to list node resources", "error", err)
return []bom.NodeInfo{}, nil
}
return nil, err
}
nodesInfo := make([]bom.NodeInfo, 0)
for _, node := range nodes.Items {
Expand Down

0 comments on commit 0300bc4

Please sign in to comment.