Skip to content

Commit

Permalink
feat: Fix auth error, errors out properly closes #450 and increased l…
Browse files Browse the repository at this point in the history
…og level for silent resource failures

Signed-off-by: dark0dave <dark0dave@mykolab.com>
  • Loading branch information
dark0dave committed Sep 5, 2023
1 parent f6ebd85 commit fcafd01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions cmd/kubent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@ func generateUserAgent() string {
return fmt.Sprintf("kubent (%s/%s)", version, gitSha)
}

func getCollectors(collectors []collector.Collector) []map[string]interface{} {
func getCollectors(collectors []collector.Collector, exitIfError bool) []map[string]interface{} {
var inputs []map[string]interface{}
for _, c := range collectors {
rs, err := c.Get()
if err != nil {
log.Error().Err(err).Str("name", c.Name()).Msg("Failed to retrieve data from collector")
} else {
inputs = append(inputs, rs...)
log.Info().Str("name", c.Name()).Msgf("Retrieved %d resources from collector", len(rs))
if exitIfError {
os.Exit(EXIT_CODE_FAIL_GENERIC)
}
continue
}
inputs = append(inputs, rs...)
log.Info().Str("name", c.Name()).Msgf("Retrieved %d resources from collector", len(rs))
}
return inputs
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/collector/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (c *ClusterCollector) Get() ([]map[string]interface{}, error) {
log.Debug().Msgf("Retrieving: %s.%s.%s", g.Resource, g.Version, g.Group)
rs, err := ri.List(context.Background(), metav1.ListOptions{})
if err != nil {
log.Debug().Msgf("Failed to retrieve: %s: %s", g, err)
log.Warn().Msgf("Failed to retrieve: %s: %s", g, err)
continue
}

Expand Down

0 comments on commit fcafd01

Please sign in to comment.