Skip to content

✨ Cleaner Condition Types & Reasons - #1007

Merged
tmshort merged 11 commits into
operator-framework:mainfrom
bentito:cleaner-types-reasons
Jul 22, 2024
Merged

✨ Cleaner Condition Types & Reasons#1007
tmshort merged 11 commits into
operator-framework:mainfrom
bentito:cleaner-types-reasons

Conversation

@bentito

@bentitobentito commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

Description

Fixes: #996

Cleaner Condition Types & Reasons. See commit messages for coverage of this PR and its sync to the RFC recommendations. https://docs.google.com/document/d/1JWJxnDXM0X1JQ67ZIDx5j1ayb1d7ajrK_uSDDaz0G98

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@bentito
bentito requested a review from a team as a code ownerJuly 2, 2024 15:31
@netlify

netlifyBot commented Jul 2, 2024

Copy link
Copy Markdown

Deploy Preview for olmv1 ready!

NameLink
🔨 Latest commitf678a7c
🔍 Latest deploy loghttps://app.netlify.com/sites/olmv1/deploys/669e4e46518dfc0008abd4fa
😎 Deploy Previewhttps://deploy-preview-1007--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@codecov

codecovBot commented Jul 2, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 72.93%. Comparing base (a0fca0d) to head (f678a7c).

FilesPatch %Lines
...nternal/controllers/clusterextension_controller.go50.00%2 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #1007 +/- ##
==========================================
+ Coverage 72.75% 72.93% +0.17% 
==========================================
Files 31 31 Lines 1883 1862 -21 ==========================================
- Hits 1370 1358 -12 + Misses 375 366 -9 
Partials 138 138 
FlagCoverage Δ
e2e56.68% <0.00%> (+0.32%)⬆️
unit44.41% <50.00%> (-0.15%)⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bentito

Copy link
Copy Markdown
ContributorAuthor

NB: go-apidiff is an expected failing test as we're intentionally removing API items pre-GA.

Comment threadapi/v1alpha1/clusterextension_types.go Outdated
setStatusUnpackPending(ext, unpackResult.Message)
setInstalledStatusConditionUnknown(ext, "installation has not been attempted as unpack is pending")
setStatusInstallFalseUnpackFailed(ext, unpackResult.Message)
setInstalledStatusConditionInstalledFalse(ext, "installation has not been attempted as unpack is pending")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Installed=False is not always correct here. If we have previously installed a bundle, and now the unpack of the next bundle is pending, we still have an installed bundle.

The installation status and the bundle unpack status are not related to each other.

@bentitobentitoJul 8, 2024

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

okay, just setting the unpack as failed in 0306c9d

case rukpaksource.StatePending:
setStatusUnpackPending(ext, unpackResult.Message)
setInstalledStatusConditionUnknown(ext, "installation has not been attempted as unpack is pending")
setStatusInstallFalseUnpackFailed(ext, unpackResult.Message)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unpack state is pending, but we're setting Unpacked=False, Failed?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Well this was changed to acknowledge that we've switched to direct image registry and that as far as opr-ctrl is concerned we can't really be in an Unknown state, we're either failed or not. Perhaps we should just not process StatePending here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure we should write this code with specific knowledge of the underlying Source implementation. In theory, the source could be switched out to a different implementation that can return StatePending. I've been tinkering with an async direct image client, so this is not entirely hypothetical.

More broadly, I wonder if we even need an Unpacked condition type? I don't see it in the diagram in the RFC. The only reason we are unpacking a bundle is so that we can install it. So can we rollup unpacking status into Progressing and/or Installed conditions?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

That's farther than the RFC went, but I think it's in the same spirit. I think we can roll it into TypeInstalled. I think TypeProgressing would actually be adding a new type?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

as noted above there is no TypeProgressing currently, if we want to eliminate TypeUnpacked in favor of TypeInstalled
@joelanford, these two helper methods encapsulate all the places changes would be needed:

funcsetStatusUnpackFailed(ext*ocv1alpha1.ClusterExtension, messagestring) {
ext.Status.InstalledBundle=nilapimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
Type: ocv1alpha1.TypeUnpacked,
Status: metav1.ConditionFalse,
Reason: ocv1alpha1.ReasonUnpackFailed,
Message: message,
ObservedGeneration: ext.GetGeneration(),
})
}
funcsetStatusUnpacked(ext*ocv1alpha1.ClusterExtension, messagestring) {
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
Type: ocv1alpha1.TypeUnpacked,
Status: metav1.ConditionTrue,
Reason: ocv1alpha1.ReasonUnpackSuccess,
Message: message,
ObservedGeneration: ext.GetGeneration(),
})
}

So on the fail case we'd want TypeInstalled as ConditionUnknown and same on the success case. The reason would be the difference. But I wonder if the success case is a bit odd: TypeInstalled is Uknown and the reason is Unpack success?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think TypeInstalled should literally just be based on: "is there a helm release secret with status deployed? if so, Installed=True. If not "Installed=False". If there was an error looking up helm release secrets (other than "not found"), then "Installed=Unknown".

Nothing else should play into it.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I created #1027 to capture this need. I'd like to keep this PR limited to the RFC covered items.

@tmshort

Copy link
Copy Markdown
Contributor

@joelanford are you ok with this?

@openshift-merge-robotopenshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 12, 2024
bentito added 11 commits July 22, 2024 07:57
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
@bentito
bentitoforce-pushed the cleaner-types-reasons branch from e5952e4 to f678a7cCompareJuly 22, 2024 12:19
@openshift-merge-robotopenshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2024

@tmshorttmshort left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@openshift-ciopenshift-ciBot added the lgtm Indicates that a PR is ready to be merged. label Jul 22, 2024
@tmshort
tmshort added this pull request to the merge queue Jul 22, 2024
Merged via the queue into operator-framework:main with commit 58c5776Jul 22, 2024
perdasilva pushed a commit to LalatenduMohanty/operator-controller that referenced this pull request Aug 13, 2024
* Replace ReasonCreateDynamicWatchFailed w/ ReasonInstallationFailed
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Remove unused ReasonInstallationSucceeded
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Drop usage of ConditionUnknown on Pending Install
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Remove ReasonUnpackPending/InstallationsStatusUnk
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Update related TODO in ClusterExtension controller
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Rm InstalledStatus->nil on upack & add comment
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Align CRD for added Go doc on InstalledBundle
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Move comment on InstalledBundle field
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Commit manifest changes for godoc change
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Decouple bundle unpacking and installed statuses
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Remove unneeded unpack stage helper method
Signed-off-by: Brett Tofel <btofel@redhat.com>
---------
Signed-off-by: Brett Tofel <btofel@redhat.com>
perdasilva pushed a commit to kevinrizza/operator-controller that referenced this pull request Aug 13, 2024
* Replace ReasonCreateDynamicWatchFailed w/ ReasonInstallationFailed
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Remove unused ReasonInstallationSucceeded
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Drop usage of ConditionUnknown on Pending Install
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Remove ReasonUnpackPending/InstallationsStatusUnk
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Update related TODO in ClusterExtension controller
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Rm InstalledStatus->nil on upack & add comment
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Align CRD for added Go doc on InstalledBundle
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Move comment on InstalledBundle field
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Commit manifest changes for godoc change
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Decouple bundle unpacking and installed statuses
Signed-off-by: Brett Tofel <btofel@redhat.com>
* Remove unneeded unpack stage helper method
Signed-off-by: Brett Tofel <btofel@redhat.com>
---------
Signed-off-by: Brett Tofel <btofel@redhat.com>
@skattojuskattoju mentioned this pull request Sep 25, 2024
4 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtmIndicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement condition changes for operator-controller per RFC

5 participants

@bentito@tmshort@joelanford@LalatenduMohanty@openshift-merge-robot