Skip to content

🐛(fix) Remove "Serving" condition type from ConditionSets #1859

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

Merged
merged 1 commit into from
Mar 12, 2025

Conversation

anik120
Copy link
Contributor

@anik120 anik120 commented Mar 11, 2025

conditionset.ConditionTypes was being used by the CluterExtension controller to ensureAllConditionsWithReason whenever a particular reason needed to be set for all of the ClusterExention's conditions. However, the ConditionTypes included a Condition Type Serving, which is not a ClusterExtension Condition(it is a ClusterCatalog condition).

This is causing the Serving condition to show up when a resolution fails, which is incorrect to begin with, and is then never cleared when the resolution succeeds at a later stage.

try to upgrade ClusterExtension to a non-exist version
$ kubectl patch ClusterExtension extension-77972 -p '{"spec":{"source":{"catalog":{"version":"0.2.0"}}}}' --type=merge
clusterextension.olm.operatorframework.io/extension-77972 patched

- lastTransitionTime: "2025-03-04T07:16:27Z"
    message: 'error upgrading from currently installed version "0.1.0": no bundles
      found for package "nginx77972" matching version "0.2.0"'
    observedGeneration: 2
    reason: Retrying
    status: "True"
    type: Progressing
  - lastTransitionTime: "2025-03-04T07:16:35Z"
    message: 'error upgrading from currently installed version "0.1.0": no bundles
      found for package "nginx77972" matching version "0.2.0"'
    observedGeneration: 2
    reason: Failed
    status: "False"
    type: Serving
  install:
    bundle:
      name: nginx77972.v0.1.0
      version: 0.1.0

This PR removes the Serving condition type from conditonSets.ConditionType

Description

Reviewer Checklist

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

@anik120 anik120 requested a review from a team as a code owner March 11, 2025 18:13
Copy link

netlify bot commented Mar 11, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 46d0ca6
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/67d1be89ae1f750008ac25e3
😎 Deploy Preview https://deploy-preview-1859--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.

@anik120 anik120 changed the title (fix) Remove "Serving" condition type from ConditionSets 🐛(fix) Remove "Serving" condition type from ConditionSets Mar 11, 2025
@anik120 anik120 force-pushed the clear-serving-error branch from 40e213b to 2db9364 Compare March 11, 2025 19:43
Copy link

codecov bot commented Mar 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.39%. Comparing base (995dc2b) to head (46d0ca6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1859      +/-   ##
==========================================
- Coverage   68.45%   68.39%   -0.06%     
==========================================
  Files          63       63              
  Lines        5136     5136              
==========================================
- Hits         3516     3513       -3     
- Misses       1390     1392       +2     
- Partials      230      231       +1     
Flag Coverage Δ
e2e 51.52% <ø> (-0.16%) ⬇️
unit 56.01% <ø> (ø)

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.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -61,7 +61,7 @@ func parseConstants(prefix string) ([]string, error) {
// ParseDir returns a map of package name to package ASTs. An AST is a representation of the source code
// that can be traversed to extract information. The map is keyed by the package name.
pkgs, err := parser.ParseDir(fset, ".", func(info fs.FileInfo) bool {
return !strings.HasSuffix(info.Name(), "_test.go")
return !strings.HasSuffix(info.Name(), "_test.go") && !(info.Name() == "clustercatalog_types.go")
Copy link
Member

@joelanford joelanford Mar 11, 2025

Choose a reason for hiding this comment

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

Maybe we should test that the filename is clusterextension_types.go instead?

That way if we ever add a new type, we don't need to change this to exclude that new file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. I actually changed the function to

// parseConstants parses the values of the top-level constants that start with the given prefix,
// in the files clusterextension_types.go and common_types.go.
func parseConstants(prefix string) ([]string, error)

so that this function never sees any movement if new types are added. It also helped to get rid of the 3 nest for-loops and replace it with a nicer looking 2 nested one.

All this made possible by the replacement of parseDir with parseFile

Copy link
Contributor

@azych azych left a comment

Choose a reason for hiding this comment

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

/lgtm

@@ -34,6 +34,14 @@ const (

AvailabilityModeAvailable AvailabilityMode = "Available"
AvailabilityModeUnavailable AvailabilityMode = "Unavailable"

// Serving condition types
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Serving Condition types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍🏽
I pushed a change to address Joe's feedback too can I get a re-lgtm please 🙏🏽

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 12, 2025
@anik120 anik120 force-pushed the clear-serving-error branch from 2db9364 to 56397fd Compare March 12, 2025 13:53
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 12, 2025
@anik120 anik120 force-pushed the clear-serving-error branch 3 times, most recently from 6f12f28 to da50278 Compare March 12, 2025 14:41
Comment on lines 38 to 39
// Serving Condition types
TypeServing = "Serving"
Copy link
Member

Choose a reason for hiding this comment

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

I think this is what @azych meant? If we add more condition types, we can add them in this section.

Suggested change
// Serving Condition types
TypeServing = "Serving"
// Condition types
TypeServing = "Serving"

But I would leave Serving reasons as its own section since it can be helpful to see which reasons are used for which condition types.

@joelanford
Copy link
Member

Other then the nit on the comment, changes look good to me!

@joelanford
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 12, 2025
conditionset.ConditionTypes was being used by the CluterExtension
controller to `ensureAllConditionsWithReason` whenever a particular
reason needed to be set for all of the ClusterExention's conditions.
However, the `ConditionTypes` included a Condition Type `Serving`, which
is not a ClusterExtension Condition(it is a ClusterCatalog condition).

This is causing the `Serving` condition to show up when a resolution fails,
which is incorrect to begin with, and is then never cleared when the resolution
succeeds at a later stage.

```
try to upgrade ClusterExtension to a non-exist version
$ kubectl patch ClusterExtension extension-77972 -p '{"spec":{"source":{"catalog":{"version":"0.2.0"}}}}' --type=merge
clusterextension.olm.operatorframework.io/extension-77972 patched

- lastTransitionTime: "2025-03-04T07:16:27Z"
    message: 'error upgrading from currently installed version "0.1.0": no bundles
      found for package "nginx77972" matching version "0.2.0"'
    observedGeneration: 2
    reason: Retrying
    status: "True"
    type: Progressing
  - lastTransitionTime: "2025-03-04T07:16:35Z"
    message: 'error upgrading from currently installed version "0.1.0": no bundles
      found for package "nginx77972" matching version "0.2.0"'
    observedGeneration: 2
    reason: Failed
    status: "False"
    type: Serving
  install:
    bundle:
      name: nginx77972.v0.1.0
      version: 0.1.0
```

This PR removes the `Serving` condition type from `conditonSets.ConditionType`
@anik120 anik120 force-pushed the clear-serving-error branch from da50278 to 46d0ca6 Compare March 12, 2025 17:04
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 12, 2025
Copy link

openshift-ci bot commented Mar 12, 2025

New changes are detected. LGTM label has been removed.

@anik120 anik120 enabled auto-merge March 12, 2025 17:05
@anik120 anik120 added this pull request to the merge queue Mar 12, 2025
Merged via the queue into operator-framework:main with commit 029d19f Mar 12, 2025
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants