cli-utils icon indicating copy to clipboard operation
cli-utils copied to clipboard

kstatus: defaults to fail open when no `status` field is available

Open jack1902 opened this issue 2 years ago • 7 comments

TL;DR - When a resource doesn't yet have a status field does kstatus report unknown ?

When creating a resource which is defined by a CRD which has no status by default, i believe the behaviour of kstatus is to state "unknown". I believe this then enables developers using unknown as a condition to determine if that should be seen as "lets carry on" or "stop here and wait".

If the "unknown" status is indeed what happens when no status field exists on a resource (because it has been freshly applied and the backing controller hasn't had a chance to update the CR' status field yet, i'll close this issue and raise another with the project using this one to add configuration.

jack1902 avatar Oct 20 '23 16:10 jack1902

One thing that we have been doing is to patch the logic for every custom CRD that we create. It's not great, but we also don't have a lot of custom CRDs.

Raffo avatar Oct 23 '23 09:10 Raffo

When a resource doesn't yet have a status field does kstatus report unknown ?

If I am reading the code right (https://github.com/kubernetes-sigs/cli-utils/blob/0b156cb0425fdb29a436d13f840a39039558c10e/pkg/kstatus/status/status.go#L102), it actually falls all the way through to Current if there is no status field.

aw185176 avatar Dec 22 '23 20:12 aw185176

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Mar 21 '24 21:03 k8s-triage-robot

/remove-lifecycle stale

Raffo avatar Apr 04 '24 08:04 Raffo

When a resource doesn't yet have a status field does kstatus report unknown ?

If I am reading the code right (

https://github.com/kubernetes-sigs/cli-utils/blob/0b156cb0425fdb29a436d13f840a39039558c10e/pkg/kstatus/status/status.go#L102

), it actually falls all the way through to Current if there is no status field.

This is correct. Objects without status are assumed to be Current. This is how many of the base k8s types are handled, like Role & RoleBinding, which don't have status.

If you want your CRD to not immediately be seen as Current, add status.observedGeneration to the schema with a default of 0. This will cause the API Server to create a default status when the object is created, which kstatus will interpret as InProgress until your controller sets status.observedGeneration = meta.generation.

karlkfi avatar Jul 02 '24 18:07 karlkfi