Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

Avoid using resource status for reconcile logic #420

Description

@ankitathomas

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzilla/valid-bugIndicates that a referenced Bugzilla bug is valid for the branch this PR is targeting.v1.xIssues related to features added after v1.0

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions