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

Create webhook for NIM enablement #288

Merged

Conversation

xieshenzh
Copy link
Contributor

@xieshenzh xieshenzh commented Nov 5, 2024

Create the validation webhook for NIM Account.

Description

  1. Created the webhook
  2. Updated the manifests to include the webhook
  3. Check the DSC flag to decide whether to enable the webhook

How Has This Been Tested?

  1. Deploy the controller in Openshift
  2. Create an Account CR.
    2.1 Check if the Account is created when the api key secret is not created
    2.2 Check if the Account is created when there is already an Account CR in the namespace
    2.3 Check if the Account is created when the api key secret is created and there is no other Account in the namespace
  3. Update an Account CR
    3.1 Check if the Account is updated when updating the api key secret and the new api key secret is not created
    3.2 Check if the Account is updated when updating the api key secret and the new api key secret is created

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link
Contributor

openshift-ci bot commented Nov 5, 2024

Hi @xieshenzh. Thanks for your PR.

I'm waiting for a opendatahub-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@xieshenzh xieshenzh force-pushed the nim-account-webhook branch 3 times, most recently from 09288d1 to 6a12973 Compare November 6, 2024 20:28
@xieshenzh xieshenzh marked this pull request as ready for review November 6, 2024 20:30
main.go Outdated Show resolved Hide resolved
@Jooho
Copy link
Contributor

Jooho commented Nov 6, 2024

Could you please write tests for this webhook?

@xieshenzh
Copy link
Contributor Author

@Jooho
Copy link
Contributor

Jooho commented Nov 6, 2024

oh I missed it. thanks for the tests. I will review this.

return field.Invalid(field.NewPath("spec").Child("apiKeySecret").Child("name"), newAccount.Spec.APIKeySecret.Name, msg)
}
name := newAccount.Spec.APIKeySecret.Name
namespace := newAccount.Spec.APIKeySecret.Namespace
Copy link
Contributor

Choose a reason for hiding this comment

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

namespace can be different from where it is created?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, the namespace of the Secret can be different from the namespace of the Account.
If there is a requirement to disallow this scenario, this webhook should reject Account creation or update in this case.
But I have not received such requirement so far.

Copy link
Contributor

Choose a reason for hiding this comment

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

odh-model-controller can access to all namespaces and also so can get secret but it is for internal usage for odh-model-controller. But if it is available to access all secrets in the cluster by this cr, I think it is not a good idea for security reasons. @etirelli @terrytangyuan @israel-hdez wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Jooho The webhook is updated. It won't check the Secret anymore.
If you still have security concerns on the usage of the Secret.
Please add your comments and requests in PR #289 instead.
Thanks.

controllers/webhook/nim_account_webhook.go Outdated Show resolved Hide resolved
controllers/utils/utils.go Outdated Show resolved Hide resolved
controllers/webhook/nim_account_webhook.go Outdated Show resolved Hide resolved
@@ -116,7 +116,8 @@ var _ = BeforeSuite(func() {
By("Bootstrapping test environment")
envTest = &envtest.Environment{
CRDInstallOptions: envtest.CRDInstallOptions{
Paths: []string{filepath.Join("..", "config", "crd", "external")},
Paths: []string{filepath.Join("..", "config", "crd", "external"),
filepath.Join("..", "config", "crd", "bases")},
Copy link
Member

Choose a reason for hiding this comment

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

tbh, i would think this new CRD to be shipped out by kserve as an overlay not by odh-model-controller.
say, kserve is disabled, modelmesh is enabled, CRD would still be installed in the cluster, should it?

or not include "crd/bases" from "base/kustomization.yaml".
instead, in Operator to create it on kserve demand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@etirelli @israel-hdez @lburgazzoli @TomerFi @Jooho @mpaulgreen
Any thoughts on the suggestions?

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

@zdtsw I believe this was discussed before, and the overall agreement was that odh-model-controller is the best choice at the moment. I think you are correct on the model-mesh case, but at the same time, I believe the idea is to eventually remove model-mesh, so it would be a non-issue. But I defer to the model serving team if they think otherwise.

Copy link
Member

Choose a reason for hiding this comment

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

i do not have objection to place CRD in such a way

Copy link
Member

Choose a reason for hiding this comment

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

No strong preference on this. I think it's fine keep it as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm OK with having the CRD in this repo.

main.go Outdated Show resolved Hide resolved
@xieshenzh xieshenzh force-pushed the nim-account-webhook branch 2 times, most recently from 90473a2 to 77f564c Compare November 8, 2024 04:29
@@ -116,7 +116,8 @@ var _ = BeforeSuite(func() {
By("Bootstrapping test environment")
envTest = &envtest.Environment{
CRDInstallOptions: envtest.CRDInstallOptions{
Paths: []string{filepath.Join("..", "config", "crd", "external")},
Paths: []string{filepath.Join("..", "config", "crd", "external"),
filepath.Join("..", "config", "crd", "bases")},
Copy link
Member

Choose a reason for hiding this comment

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

No strong preference on this. I think it's fine keep it as is.

controllers/webhook/nim_account_webhook.go Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot requested a review from rnetser November 12, 2024 18:15
@xieshenzh
Copy link
Contributor Author

@Jooho I don't think there is any outstanding concerns on this PR.
Could you please add /ok-to-test?

@israel-hdez
Copy link
Contributor

/ok-to-test

Copy link
Contributor

@israel-hdez israel-hdez left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link
Contributor

openshift-ci bot commented Nov 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: israel-hdez, TomerFi, xieshenzh

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

The pull request process is described 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

@openshift-merge-bot openshift-merge-bot bot merged commit ee5f3df into opendatahub-io:main Nov 14, 2024
5 checks passed
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.

8 participants