kstatus: defaults to fail open when no `status` field is available
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.
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.
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.
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/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas 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
/remove-lifecycle stale
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
Currentif 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.