Skip to content

🌱 OPRUN-4138 ClusterExtensionRevision.spec.revision must be positive - #2231

Merged
openshift-merge-bot[bot] merged 1 commit into
operator-framework:mainfrom
pedjak:cer-revision-non-negative
Sep 24, 2025
Merged

🌱 OPRUN-4138 ClusterExtensionRevision.spec.revision must be positive#2231
openshift-merge-bot[bot] merged 1 commit into
operator-framework:mainfrom
pedjak:cer-revision-non-negative

Conversation

@pedjak

Copy link
Copy Markdown
Contributor

Description

Added the validation rules and the unit tests.

Reviewer Checklist

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

Added the validation rules and the unit tests.
@pedjak
pedjak requested a review from a team as a code ownerSeptember 23, 2025 13:11
@netlify

netlifyBot commented Sep 23, 2025

Copy link
Copy Markdown

Deploy Preview for olmv1 ready!

NameLink
🔨 Latest commitc648a1f
🔍 Latest deploy loghttps://app.netlify.com/projects/olmv1/deploys/68d29c96db8d0a0008eb45b8
😎 Deploy Previewhttps://deploy-preview-2231--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 project configuration.

@pedjakpedjak changed the title 🌱 ClusterExtensionRevision.spec.revision must be positive🌱 OPRUN-4138 ClusterExtensionRevision.spec.revision must be positiveSep 23, 2025
@codecov

codecovBot commented Sep 23, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.16%. Comparing base (16d1089) to head (c648a1f).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #2231 +/- ##
=======================================
Coverage 72.16% 72.16% =======================================
Files 85 85 Lines 8440 8440 =======================================
Hits 6091 6091 Misses 1948 1948 Partials 401 401 
FlagCoverage Δ
e2e39.11% <ø> (ø)
experimental-e2e46.17% <ø> (ø)
unit57.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.

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

Comment on lines +53 to +54
// Must be positive. Each ClusterExtensionRevision of the same parent ClusterExtension needs to have
// a unique value assigned. It is immutable after creation. The new revision number must always be previous revision +1.

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.

We can validate uniqueness if we require the metadata.name to have a pattern that matches <ceName>-<revNumber>, right?

But I assume there's no way to guarantee "new rev must be previous rev +1"?

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.

In theory you could add a webhook, but I'd like to avoid webhooks as much as possible.
I don't think you can add a validation rule to .metadata.name, but we could add a CEL transition rule where .spec.revision must be equal to -digit suffix of the name. 🤔

But I'd add that in a new PR.

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.

we could probably do that, but for that we need a validation webhook where we could fetch all existing revisions, sort them by creation date and compare their revisions with the one we got in the payload. Not sure if the effort would be justified.

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.

It is possible to have a CEL validation rule for metadata.name. You just have to declare the validation against the root struct that embeds ObjectMeta.

We could use ValidationAdmissionPolicy, which is now preferred over webhooks in general, but there's still the problem that when there are multiple apiserver replicas, they are each acting independently when making validation decisions and (I'm pretty sure) without holding a lock or transaction against etcd for all the data used to make the validation decision.

@openshift-ciopenshift-ciBot added the lgtm Indicates that a PR is ready to be merged. label Sep 23, 2025
@openshift-ci

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: perdasilva, thetechnick

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ciopenshift-ciBot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 24, 2025
@openshift-merge-bot
openshift-merge-botBot merged commit 0faf118 into operator-framework:mainSep 24, 2025
26 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by an approver from all required OWNERS files.lgtmIndicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@pedjak@joelanford@perdasilva@thetechnick