Skip to content
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

feat: restrict UIPlugin CRD names to allow a single instance per type #481

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jgbernalp
Copy link
Contributor

OU-402
COO-164

This PR adds a pattern restriction for the UIPlugin name so only a single instance of a specific plugin is allowed

@jgbernalp jgbernalp requested a review from a team as a code owner May 14, 2024 09:54
@jgbernalp jgbernalp requested review from jan--f and slashpai and removed request for a team May 14, 2024 09:54
@openshift-ci openshift-ci bot requested a review from simonpasquier May 14, 2024 09:55
@jan--f
Copy link
Collaborator

jan--f commented May 14, 2024

/lgtm

Nice! We'll have to chat about OCP specific integration tests soon.

@simonpasquier
Copy link
Contributor

AFAIU you can still create conflicting objects if you mess up the names and the types, right? For instance:

apiVersion: observability.openshift.io/v1alpha1
kind: UIPlugin
metadata:
  name: ui-dashboards
spec:
  type: Dashboards
---
apiVersion: observability.openshift.io/v1alpha1
kind: UIPlugin
metadata:
  name: ui-logging
spec:
  type: Dashboards

I don't think that it's possible to validate this case with OpenAPI but we might want the operator to stop reconciliation when it detects the issue?

@jan--f
Copy link
Collaborator

jan--f commented May 30, 2024

Ahh I think I might have been (or still am) confused what needs to be done. So there can always only be a single dashboard UI plugin? An for logging a new type is added, going by #477?

In that case can we not tie the name to the type? Something like

// +kubebuilder:validation:XValidation:rule="self.name == self.spec.type",message="Name is invalid"

@simonpasquier
Copy link
Contributor

@jan--f this would be neat if it works indeed.

@jgbernalp
Copy link
Contributor Author

Will do some tests based on @jan--f suggestion and update the PR

@xperimental
Copy link
Contributor

Just a nitpick, but I think I would get rid of the ui- prefix for the names. First it mirrors the name of the resource type (UIPlugin) and it also currently causes the deployments to be named observability-ui-ui-* (which could be changed in the operator though).

@jgbernalp jgbernalp force-pushed the restrict-ui-plugin-crd-names branch from 3d749fb to 7cbdc07 Compare June 7, 2024 09:32
@openshift-ci openshift-ci bot removed the lgtm label Jun 7, 2024
Copy link

openshift-ci bot commented Jun 7, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jgbernalp
Once this PR has been reviewed and has the lgtm label, please ask for approval from jan--f. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jgbernalp
Copy link
Contributor Author

/hold

@csibbitt please check if changes are needed for STF

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold

👍

@csibbitt
Copy link
Contributor

/hold

@csibbitt please check if changes are needed for STF

STF does not use the UIPlugin, but Telemetry Operator does. I'll take care of this ASAP on OSPRH-7600

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants