-
Notifications
You must be signed in to change notification settings - Fork 581
DO NOT MERGE: ClusterExtensionRevision API Review #2610
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Per Goncalves da Silva <[email protected]>
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Excluded labels (none allowed) (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
|
Skipping CI for Draft Pull Request. |
|
Hello @perdasilva! Some important instructions when contributing to openshift/api: |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Following up here - this is in my queue, but I'm working through reading the associated RFE first to ensure I've got full context before reviewing. I should have an initial review within the next day or so. |
everettraven
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass, a handful of comments.
It might be helpful to run the latest version of linter against this API to catch some of the smaller things our linter is good at catching :).
| // | ||
| // Once a revision is set to "Archived", it cannot be un-archived. | ||
| // | ||
| // +kubebuilder:default="Active" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a required input instead of defaulting to Active?
What does it mean for multiple ClusterExtensionRevision objects for the same ClusterExtension to be Active?
| // ClusterExtensionRevisionLifecycleStatePaused / "Paused" disables reconciliation of the ClusterExtensionRevision. | ||
| // Object changes will not be reconciled. However, status updates will be propagated. | ||
| ClusterExtensionRevisionLifecycleStatePaused ClusterExtensionRevisionLifecycleState = "Paused" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used in the API as an allowed value?
| // [RFC 1123]: https://tools.ietf.org/html/rfc1123 | ||
| // | ||
| // +kubebuilder:validation:MaxLength=63 | ||
| // +kubebuilder:validation:Pattern=`^[a-z]([-a-z0-9]*[a-z0-9])?$` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discourage the usage of the pattern marker because of the lack of helpful error messages that are returned to end-users (a regex string instead of a sentence explaining the constraints).
Instead, use a CEL expression that enforces this constraint and returns a helpful message like:
api/insights/v1alpha2/types_insights.go
Line 403 in c2a41ea
| // +kubebuilder:validation:XValidation:rule=`!format.dns1123Label().validate(self).hasValue()`,message="the value must consist of only lowercase alphanumeric characters and hyphens, and must start with an alphabetic character and end with an alphanumeric character." |
| // | ||
| // +kubebuilder:validation:MaxLength=63 | ||
| // +kubebuilder:validation:Pattern=`^[a-z]([-a-z0-9]*[a-z0-9])?$` | ||
| Name string `json:"name"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly mark the field as required.
| Name string `json:"name"` | |
| // +required | |
| Name string `json:"name"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the empty string a valid value?
| // +listType=map | ||
| // +listMapKey=name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the uniqueness constraint keyed on the phase name in the GoDoc.
|
|
||
| // collisionProtection controls whether the operator can adopt and modify objects | ||
| // that already exist on the cluster. | ||
| // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We normally try to follow a pattern where we explicitly introduce the allowed values as well with a sentence like:
Allowed values are Prevent, IfNoController, ...
before going into the When ... sections.
| // | ||
| // +kubebuilder:default="Prevent" | ||
| // +kubebuilder:validation:Enum=Prevent;IfNoController;None | ||
| // +optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be helpful context, could you elaborate for me why you want this field to be optional?
| // Use this setting with extreme caution as it may cause multiple controllers to fight over | ||
| // the same resource, resulting in increased load on the API server and etcd. | ||
| // | ||
| // +kubebuilder:default="Prevent" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you ever intend to modify the default behavior? Done this way, the defaulting logic becomes a part of your API contract.
| // | ||
| // +kubebuilder:validation:EmbeddedResource | ||
| // +kubebuilder:pruning:PreserveUnknownFields | ||
| Object unstructured.Unstructured `json:"object"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be wrong here, but IIRC most embedded resource types will use https://pkg.go.dev/k8s.io/kubernetes/pkg/runtime#RawExtension as the type there.
I don't have a strong opinion here though as I've not reviewed many APIs that are embedding another resource blob within them. If this is working, 👍
| - jsonPath: .metadata.creationTimestamp | ||
| name: Age | ||
| type: date | ||
| name: v1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v1? Have you shipped this API already? Typically, APIs for experimental type features will start as v1alpha1. In OpenShift, it is expected that TP APIs are v1alphaN until ready to be promoted.
OLMv1 ClusterExtensionRevision API Review
This PR is only to facilitate API review.
ClusterExtensionRevision API
ClusterExtensionRevision objects are created by the ClusterExtension controller for each install, upgrade, or reconfiguration operation. They are owned by a ClusterExtension. A ClusterExtensionRevision carries the objects of the revision (i.e. the resources of a package at a given version + any user supplied configuration). We don't expect users to create any clusterextensionrevision objects. We only expect users to interact with this API when something goes wrong, or, in the future, in approval flows (i.e. a revision is kept from rolling out until there's some manual intervention by an user).
Lifecycle
Revision Rollout Strategy
Available=True.status.replicas==.status.updatedReplicasObject ownership is transferred from previous to subsequent revisions.
Once a revision completes, it sets all previous revisions to
Archived. WhenArchivedthe revision will clean up any objects it still manages.Collision Control
Phase objects can be be configured to error on existing, adopt orphan resources, or force adopt resources.
Bundle Rollout Strategy Definition
registry+v1 bundles will have their rollout strategy defined by OLM in both phases and probes. If we directly support the Helm format, OLM will likey also define the rollout strategy.
Currently the registry+v1 bundle strategy defined by sorting the bundle manifests into different phases: namespaces, policies, rbac, crds, etc. with default probes, e.g. CRD has
Established=Truecondition, Deployment hasAvailable=True, etc.Known Upcoming Changes
collisionProtectionout of the object and up to the top levelKnown Limitations
The objects are currently defined inline in the CRD. In the (not so distant) future we will shard the resources across some kind of container (e.g. ConfigMap or Secret).
Future Work (beyond GA)
Open Questions