Skip to content

Conversation

raptorsun
Copy link
Contributor

Description

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up dependent library

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 25, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jul 25, 2025

@raptorsun: This pull request references OLS-1435 which is a valid jira issue.

In response to this:

Description

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up dependent library

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 25, 2025
@openshift-ci openshift-ci bot requested review from bparees and xrajesh July 25, 2025 21:24
Copy link

openshift-ci bot commented Jul 25, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign raptorsun for approval. For more information see the 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

@raptorsun raptorsun changed the title [WIP] OLS-1435: add validation webhook for OLSConfig CRD OLS-1435: add validation webhook for OLSConfig CRD Jul 28, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 28, 2025
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 31, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 31, 2025
@bparees
Copy link
Contributor

bparees commented Jul 31, 2025

@raptorsun did you look at using CRD schema validation rules to do this instead of a webhook? I'm pretty sure it's possible to define schema rules for most, if not all, of these checks and avoid running/managing the webhook (not to mention the webhook becomes a point of failure since the CR instances can't be managed if the webhook is down for some reason):

https://kubernetes.io/blog/2022/09/23/crd-validation-rules-beta/

even if you don't want to use the beta feature (CEL), there's also validation that can be done on things like field name (for the cluster name requirement):
https://book.kubebuilder.io/reference/markers/crd-validation

@raptorsun raptorsun force-pushed the ols-1435 branch 2 times, most recently from 7435be2 to 9b8dd73 Compare August 1, 2025 10:07
@raptorsun
Copy link
Contributor Author

/retest

@raptorsun
Copy link
Contributor Author

@raptorsun did you look at using CRD schema validation rules to do this instead of a webhook? I'm pretty sure it's possible to define schema rules for most, if not all, of these checks and avoid running/managing the webhook (not to mention the webhook becomes a point of failure since the CR instances can't be managed if the webhook is down for some reason):

https://kubernetes.io/blog/2022/09/23/crd-validation-rules-beta/

even if you don't want to use the beta feature (CEL), there's also validation that can be done on things like field name (for the cluster name requirement): https://book.kubebuilder.io/reference/markers/crd-validation

Yes, I have checked the validation tools provided by kubebuilder. CRD validation rules works well when all the required information comes from the object itself. Last year we have investigated several config problems reported by users, many of which leads to a reference to inexistent secret, configmap. CRD validation rules cannot verify reffered resources so I'd like to put a validation webhook here to prevent users mistakenly change the OLSConfig with reference to inexistent resources. This PR starts with the token secret. In future we will add reference to configmaps such as those containing TLS certs, too.

@bparees
Copy link
Contributor

bparees commented Aug 1, 2025

CRD validation rules cannot verify reffered resources so I'd like to put a validation webhook here to prevent users mistakenly change the OLSConfig with reference to inexistent resources. This PR starts with the token secret. In future we will add reference to configmaps such as those containing TLS certs, too.

If someone deletes the referenced configmap/secret, does the operator reconciliation flag that in status the next time it reconciles the olsconfig object?

@raptorsun
Copy link
Contributor Author

CRD validation rules cannot verify reffered resources so I'd like to put a validation webhook here to prevent users mistakenly change the OLSConfig with reference to inexistent resources. This PR starts with the token secret. In future we will add reference to configmaps such as those containing TLS certs, too.

If someone deletes the referenced configmap/secret, does the operator reconciliation flag that in status the next time it reconciles the olsconfig object?

yes, errors during reconciliation is put into the status of OLSConfig.

@@ -0,0 +1,29 @@
# This patch add annotation to admission webhook config and
Copy link
Contributor Author

Choose a reason for hiding this comment

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

leave these code blocks here in case we need mutation webhook in future

@raptorsun
Copy link
Contributor Author

/retest

@raptorsun
Copy link
Contributor Author

bundle is still using old operator image, we need merge this PR first and then quickly update the operator image in the bundle to deblock the integrations tests:

  • Red Hat Konflux / service-e2e-tests-417 / ols-bundle
  • Red Hat Konflux / operator-e2e-tests-417 / ols-bundle

@JoaoFula
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 13, 2025
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2025
Copy link

openshift-ci bot commented Aug 25, 2025

New changes are detected. LGTM label has been removed.

Copy link

openshift-ci bot commented Sep 3, 2025

@raptorsun: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants