Skip to content

⚠ minor API improvements #1250

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
Sep 12, 2024

Conversation

joelanford
Copy link
Member

@joelanford joelanford commented Sep 11, 2024

Description

More minor improvements to the API in preparation for 1.0.0.

Fixes #1251

Reviewer Checklist

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

@joelanford joelanford requested a review from a team as a code owner September 11, 2024 11:56
Copy link

netlify bot commented Sep 11, 2024

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 13d5309
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/66e203e52c579b0008f7fcae
😎 Deploy Preview https://deploy-preview-1250--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.

@@ -23,8 +23,7 @@ import (
)

var (
ClusterExtensionGVK = SchemeBuilder.GroupVersion.WithKind("ClusterExtension")
Copy link
Member Author

Choose a reason for hiding this comment

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

ClusterExtensionGVK is unused, and is not really necessary for inclusion as an exported global variable in the API.

Callers can construct themselves like this:

gvk := ocv1alpha1.GroupVersion.WithKind(v1alpha1.ClusterExtensionKind)

// - "Unpacked", represents whether or not the bundle contents have been successfully unpacked
//
// When the ClusterExtension is sourced from a catalog, the following conditions are also possible:
Copy link
Member Author

Choose a reason for hiding this comment

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

I grouped the Deprecated* conditions into their own section for two reasons:

  1. I think it is helpful to see the other "main" conditions without the "noise" of these being intermingled.
  2. Deprecation metadata comes from catalogs, and while we currently only support sourcing from catalogs, I thought it might be good to call out the fact that deprecations will only ever show up if the ClusterExtension is sourced from a catalog.

// - "Deprecated", represents an aggregation of the PackageDeprecated, ChannelDeprecated, and BundleDeprecated condition types
// - "PackageDeprecated", represents whether or not the package specified in the spec.source.catalog.packageName field has been deprecated
// - "ChannelDeprecated", represents whether or not any channel specified in spec.source.catalog.channels has been deprecated
// - "BundleDeprecated", represents whether or not the installed bundle is deprecated
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm pretty sure this line is not true, but want to double check. A quick glance at the code makes me think we should make the following edit as well:

Suggested change
// - "BundleDeprecated", represents whether or not the installed bundle is deprecated
// - "BundleDeprecated", represents whether or not the resolved bundle is deprecated

However, I think the original sentiment of having this condition be based on the installed bundle is what we actually want. That might require a bit more conversation and consideration though, as it isn't clear to me how exactly we would assess the deprecation status of an installed bundle during subsequent reconciles after it is installed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we'd have two possibilities:

  1. You want to install a bundle from the catalog, and it's deprecated - which is straightforward
  2. You install a bundle that isn't deprecated, and in the next catalog version it is (I guess this is only meaningful for version ranges that don't let the bundle upgrade to the next (non-deprecated) version.

In the 2nd case, shouldn't it pick up the condition during reconcile? Maybe it's OK that we only express deprecated conditions for resolved bundles (and not worry about the the installed bundles) since either the CE will get upgraded, or if it can't/won't, we'd anyway resolve to the installed bundle?

Copy link
Member Author

Choose a reason for hiding this comment

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

My initial thought is that we only touch the BundleDeprecated condition when:

  1. We successfully install a bundle. In this case the resolved bundle and the installed bundle are the same, so the resolved deprecation is applicable to the installed bundle.
  2. We detect that a bundle is somehow no longer installed, in which case we unset (or set to Unknown) the BundleDeprecated condition.

//
//+optional
Bundle *BundleMetadata `json:"bundle,omitempty"`
Bundle BundleMetadata `json:"bundle"`
Copy link
Member Author

@joelanford joelanford Sep 11, 2024

Choose a reason for hiding this comment

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

I removed the pointer here because the parent struct is a pointer. If the parent struct is non-nil, this field is always expected to be set.

Bundle *BundleMetadata `json:"bundle,omitempty"`
// A "bundle" is a versioned set of content that represents the resources that
// need to be applied to a cluster to install a package.
Bundle BundleMetadata `json:"bundle"`
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

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

Project coverage is 76.18%. Comparing base (78a6c00) to head (13d5309).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
api/v1alpha1/zz_generated.deepcopy.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1250      +/-   ##
==========================================
- Coverage   76.49%   76.18%   -0.32%     
==========================================
  Files          40       40              
  Lines        2336     2330       -6     
==========================================
- Hits         1787     1775      -12     
- Misses        392      398       +6     
  Partials      157      157              
Flag Coverage Δ
e2e 57.21% <70.00%> (-0.37%) ⬇️
unit 52.53% <40.00%> (+0.13%) ⬆️

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.

@joelanford joelanford force-pushed the minor-api-updates branch 2 times, most recently from dc80a94 to a21d458 Compare September 11, 2024 17:53
Signed-off-by: Joe Lanford <[email protected]>
- "PackageDeprecated", represents whether or not the package specified in the spec.source.catalog.packageName field has been deprecated
- "ChannelDeprecated", represents whether or not any channel specified in spec.source.catalog.channels has been deprecated
- "BundleDeprecated", represents whether or not the installed bundle is deprecated

The current set of reasons are:
- "Success", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when unpacking a bundle's content, resolution and installation/upgrading is successful
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to call out the reasons for the deprecated conditions?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. The "Reason" for these conditions are basically 1-to-1 with the Status. "The reason this is deprecated is because the author provided a deprecation"

Copy link
Contributor

@perdasilva perdasilva left a comment

Choose a reason for hiding this comment

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

Nice one! Thank you ^^

I left a question about whether we ought to call out the Deprecated* condition reasons in the docs. If not, take the approval, if yes, happy to approve again =D

@joelanford joelanford added this pull request to the merge queue Sep 12, 2024
Merged via the queue into operator-framework:main with commit f61ffb4 Sep 12, 2024
17 of 19 checks passed
@skattoju skattoju mentioned this pull request Sep 25, 2024
4 tasks
@joelanford joelanford deleted the minor-api-updates branch October 22, 2024 13:02
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.

🐛 More API cleanups
2 participants