Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make status compatible with kstatus #325

Closed
wants to merge 4 commits into from

Conversation

somtochiama
Copy link
Member

@somtochiama somtochiama commented Apr 19, 2021

This PR projects the Ready status condition to Reconciling and Stalled for better kstatus compliance.

Signed-off-by: Somtochi Onyekwere somtochionyekwere@gmail.com

Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

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

Based on the documentation, the Stalled state must be complimented with a Reconciling condition (== what we call "Progressing" at the moment).

It looks like this technically also makes it possible to drop the Ready condition as it seems to be that Ready == !Stalled && !Reconciling. For backward compatibility reasons, and because of the limited adoption of kstatus, I would however still keep the condition.

@hiddeco
Copy link
Member

hiddeco commented Apr 20, 2021

To add to my review comment:

  • Add Reconciling condition to fluxcd/pkg, this seems to be the right thing to do as it follows the complete spec and the conditions are the new standard.
  • Implement Reconciling condition here, it can be set when the resource is currently "progressing", and removed when it moves to Ready state.
  • I would see if it is possible to scope the API around Reconciling and Stalled, and remove NotReady. This should save you a setter.

Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
api/v1beta1/kustomization_types.go Show resolved Hide resolved
// SetKustomizeStalled sets the StalledCondition, ObservedGeneration on the Kustomization.
func SetKustomizationStalled(k *Kustomization, status metav1.ConditionStatus, reason, message string) {
meta.SetResourceCondition(k, meta.StalledCondition, status, reason, trimString(message, MaxConditionMessageLength))
k.Status.ObservedGeneration = k.Generation
Copy link
Member

Choose a reason for hiding this comment

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

Should this be set on Stalled, or on reaching Ready? Or do we want to record it in the ObservedGeneration field of the metav1.Condition Status, but only move the one in the Status on a successful run?

Copy link
Member Author

Choose a reason for hiding this comment

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

kstatus seems to return an InProgress status once status.ObserveredGeneration != metadata.generation regardless of the conditions present. So I thought we would want to set just incase,

Copy link
Member

Choose a reason for hiding this comment

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

Good catch! Which brings us to a new question: does every error mean that the reported condition status is Stalled, and kstatus should thus stop waiting because ObservedGeneration == Generation or Status == Stalled?

If we for example run into a transient error (e.g. transient resource lookup failure that returned an error from the K8s API server). This would mean that kstatus would stop waiting for the resource to reach the expected state if we would set both ObservedGeneration and Stalled, while if we would set Ready==False or left the ObservedGeneration untouched, it would continue to wait for the next reconciliation to (hopefully) succeed: https://github.com/kubernetes-sigs/cli-utils/blob/e351b2bc43cec2107ba1d874c3dec54fd0956c59/pkg/kstatus/status/generic.go#L39-L54

Copy link
Member Author

Choose a reason for hiding this comment

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

If we for example run into a transient error (e.g. transient resource lookup failure that returned an error from the K8s API server).

Hmm. We probably have to identify transient errors and real errors, then decide how best to handle the transient. I think we should set it Reconciling status and Ready=false for transient errors. kstatus takes ObservationGeneration != generated to mean that the controller might not be running or unable to update the resource.

Plus a generic message is set when ObservationGeneration != generated. If we use Reconciling condition, kstatus sets the reason and message from the condition .

Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
@stefanprodan
Copy link
Member

@hiddeco should we close this? I guess the kstatus conditions will be implemented in #347?

@hiddeco
Copy link
Member

hiddeco commented May 25, 2021

This can be closed in favor of #347 indeed.

@hiddeco hiddeco closed this May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants