Skip to content

Conversation

@Starefossen
Copy link
Member

Prevents errors like this:

{"error":"failed to list unleash.nais.io/v1, Resource=unleashes: unleashes.unleash.nais.io is forbidden: User \"system:serviceaccount:nais-system:nais-api\" cannot list resource \"unleashes\" in API group \"unleash.nais.io\" at the cluster scope","level":"error","logger":"UnhandledError","msg":"Failed to watch","reflector":"pkg/mod/k8s.io/client-go@v0.34.3/tools/cache/reflector.go:290","time":"2025-12-22T08:41:29Z","type":"unleash.nais.io/v1, Resource=unleashes"}

@Starefossen Starefossen requested a review from a team as a code owner December 22, 2025 14:02
@thokra-nav
Copy link
Contributor

Den feilen skjer ved oppstart, no? Vi byttet til å gjøre discovery av config basert på tilgjengelige ressurser, fremfor å vedlikeholde en liste av booleans. Men ble kanskje ikke helt ryddet opp. Men jeg har egentlig mer lyst å finne ut av den løsningen framfor å ha det som config

@Starefossen Starefossen force-pushed the unleash-disabled-fix branch from 442dd7b to 5ada747 Compare January 8, 2026 21:02
@Starefossen
Copy link
Member Author

Enig, @thokra-nav!

Comment on lines +82 to +91

// Also verify we have permission to list the resource by doing a test list with limit=1
// This prevents errors at runtime when the informer tries to watch resources we can't access
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err = c.client.Resource(*gvr).List(ctx, v1.ListOptions{Limit: 1})
if err != nil {
c.log.WithError(err).WithField("resource", gvr.String()).Warn("no permission to list resource, skipping watcher")
return nil, *gvr, fmt.Errorf("no permission to list resource: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hvorfor trenger vi dette?
Hvis det er rettigheter som er problemet, så er det fint at vi rett og slett blir spamma imho. Vi kan også fikse rettighetene uten å måtte restarte api etterpå, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants