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

Avoid using resource status for reconcile logic #420

Closed
ankitathomas opened this issue Sep 27, 2024 · 0 comments · Fixed by #424
Closed

Avoid using resource status for reconcile logic #420

ankitathomas opened this issue Sep 27, 2024 · 0 comments · Fixed by #424
Labels
bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. v1.x Issues related to features added after v1.0

Comments

@ankitathomas
Copy link
Contributor

ankitathomas commented Sep 27, 2024

Using a ClusterCatalog object's status for the catalogd controller's reconcile logic is an anti-pattern we should avoid.

We currently read from ClusterCatalog status to determine whether a catalog is ready to be polled again

examples:

  1. Reading from Status for comparing ObservedGeneration of conditions with current generation

    for _, c := range catalog.Status.Conditions {
    if c.ObservedGeneration != catalog.Generation {
    return true
    }
    }

  2. Using LastSuccessfulPollAttempt from status to calculate when to poll next

    nextPoll := catalog.Status.ResolvedSource.Image.LastSuccessfulPollAttempt.Add(catalog.Spec.Source.Image.PollInterval.Duration)

The status field should ideally be treated as a write-only field by the controller - we should update the controller so it can track information about a ClusterCatalog's current state without having to reference the ClusterCatalog's status field, as reading from Status may read to non-deterministic behavior if reconciler runs in quick succession.

Follow up based on #384 (comment)

See https://book.kubebuilder.io/reference/good-practices, https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

@LalatenduMohanty LalatenduMohanty added the v1.x Issues related to features added after v1.0 label Oct 1, 2024
@joelanford joelanford added this to OLM v1 Oct 1, 2024
@LalatenduMohanty LalatenduMohanty added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. v1.x Issues related to features added after v1.0
Projects
Status: No status
2 participants