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

Separate positive polarity conditions for ArtifactInStorage #646

Merged
merged 4 commits into from
Mar 30, 2022

Conversation

darkowlzz
Copy link
Contributor

@darkowlzz darkowlzz commented Mar 29, 2022

Introduce separate positive polarity conditions which are used to set
Ready condition. Move the "artifact stored" ready condition into
ArtifactInStorage positive polarity condition. If ArtifactInStorage is
True and there's no negative polarity condition present, the Ready
condition is summarized with ArtifactInStorage condition value.

Also, update the priorities of the conditions. ArtifactInStorage has
higher priority than SourceVerfied condition. If both are present, the
Ready condition will have ArtifactInStorage.
The negative polarity conditions are reordered to have the most likely
actual cause of failure condition the highest priority, for example
StorageOperationFailed, followed by the conditions that are reconciled
first in the whole reconciliation so as to prioritize the first failure
which may be the cause of subsequent failures.

In addition, the "artifact up-to-date" log is now also emitted as an event.

Fixes #617

@darkowlzz darkowlzz added the enhancement New feature or request label Mar 29, 2022
api/v1beta2/condition_types.go Outdated Show resolved Hide resolved
api/v1beta2/condition_types.go Outdated Show resolved Hide resolved
Copy link
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

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

@darkowlzz nice work! I added a nit and a question, apart from that it LGTM.

controllers/bucket_controller.go Show resolved Hide resolved
Introduce separate positive polarity conditions which are used to set
Ready condition. Move the "artifact stored" ready condition into
ArtifactInStorage positive polarity condition. If ArtifactInStorage is
True and there's no negative polarity condition present, the Ready
condition is summarized with ArtifactInStorage condition value.

Also, update the priorities of the conditions. ArtifactInStorage has
higher priority than SourceVerfied condition. If both are present, the
Ready condition will have ArtifactInStorage.
The negative polarity conditions are reordered to have the most likely
actual cause of failure condition the highest priority, for example
StorageOperationFailed, followed by the conditions that are reconciled
first in the whole reconciliation so as to prioritize the first failure
which may be the cause of subsequent failures.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
Update alll the other reconcilers similar to the GitRepository
reconcilers to introduce positive condition ArtifactInStorage and
reorder the status conditions.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
Signed-off-by: Sunny <darkowlzz@protonmail.com>
Signed-off-by: Sunny <darkowlzz@protonmail.com>
@darkowlzz
Copy link
Contributor Author

For reference, with this change, the status conditions of GitRepository object after a successful reconciliation with source verification enabled would look like:

  conditions:
  - lastTransitionTime: "2022-03-29T20:42:13Z"
    message: stored artifact for revision 'no-source-ignore/60c7ae324d2edbb692ebd82d744c2e3cecc141f4'
    observedGeneration: 1
    reason: Succeeded
    status: "True"
    type: Ready
  - lastTransitionTime: "2022-03-29T20:42:13Z"
    message: stored artifact for revision 'no-source-ignore/60c7ae324d2edbb692ebd82d744c2e3cecc141f4'
    observedGeneration: 1
    reason: Succeeded
    status: "True"
    type: ArtifactInStorage
  - lastTransitionTime: "2022-03-29T20:42:13Z"
    message: verified signature of commit '60c7ae324d2edbb692ebd82d744c2e3cecc141f4'
    observedGeneration: 1
    reason: Succeeded
    status: "True"
    type: SourceVerified
  observedGeneration: 1

And when there's a failure due to misconfiguration in the new generation, the conditions would look like:

  conditions:
  - lastTransitionTime: "2022-03-30T11:34:05Z"
    message: reconciling new object generation (2)
    observedGeneration: 2
    reason: NewGeneration
    status: "True"
    type: Reconciling
  - lastTransitionTime: "2022-03-30T11:34:10Z"
    message: 'failed to checkout and determine revision: unable to clone ''https://github.com/darkowlzz/flux2-kustomize-helm-example2'':
      too many redirects or authentication replays'
    observedGeneration: 2
    reason: GitOperationFailed
    status: "False"
    type: Ready
  - lastTransitionTime: "2022-03-30T11:34:10Z"
    message: 'failed to checkout and determine revision: unable to clone ''https://github.com/darkowlzz/flux2-kustomize-helm-example2'':
      too many redirects or authentication replays'
    observedGeneration: 2
    reason: GitOperationFailed
    status: "True"
    type: FetchFailed
  - lastTransitionTime: "2022-03-29T20:42:13Z"
    message: stored artifact for revision 'no-source-ignore/60c7ae324d2edbb692ebd82d744c2e3cecc141f4'
    observedGeneration: 1
    reason: Succeeded
    status: "True"
    type: ArtifactInStorage
  - lastTransitionTime: "2022-03-29T20:42:13Z"
    message: verified signature of commit '60c7ae324d2edbb692ebd82d744c2e3cecc141f4'
    observedGeneration: 1
    reason: Succeeded
    status: "True"
    type: SourceVerified
  observedGeneration: 1

After the resolution of the above failure:

  conditions:
  - lastTransitionTime: "2022-03-30T11:34:28Z"
    message: stored artifact for revision 'no-source-ignore/60c7ae324d2edbb692ebd82d744c2e3cecc141f4'
    observedGeneration: 3
    reason: Succeeded
    status: "True"
    type: Ready
  - lastTransitionTime: "2022-03-29T20:42:13Z"
    message: stored artifact for revision 'no-source-ignore/60c7ae324d2edbb692ebd82d744c2e3cecc141f4'
    observedGeneration: 3
    reason: Succeeded
    status: "True"
    type: ArtifactInStorage
  - lastTransitionTime: "2022-03-29T20:42:13Z"
    message: verified signature of commit '60c7ae324d2edbb692ebd82d744c2e3cecc141f4'
    observedGeneration: 3
    reason: Succeeded
    status: "True"
    type: SourceVerified
  observedGeneration: 3

Similar changes in all the other Source kinds.

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.

LGTM, thank you @darkowlzz 🙇

@hiddeco hiddeco requested a review from pjbgf March 30, 2022 12:14
Copy link
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

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

LGTM - really great stuff @darkowlzz

@hiddeco hiddeco merged commit ae0b38c into main Mar 30, 2022
@hiddeco hiddeco deleted the positive-conditions branch March 30, 2022 13:44
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
Status: Done
Development

Successfully merging this pull request may close these issues.

Test the order of status conditions
4 participants