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
CNV-34094: Add validating webhook #3132
Conversation
@nunnatsa: This pull request references CNV-34094 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.15.0" version, but no target version was set. In response to this:
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/test-infra repository. |
1 similar comment
@nunnatsa: This pull request references CNV-34094 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.15.0" version, but no target version was set. In response to this:
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/test-infra repository. |
5e10041
to
ab7b9ea
Compare
/test e2e-aws |
/retest |
/test e2e-aws |
/retest |
ab7b9ea
to
ad53696
Compare
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.
looks great! i made some minor comments. I also want to get Alberto's thoughts on removing the code that deletes the validation webhook. We obviously can't delete the validation webhook or else your logic here wouldn't work, but i want to make sure we account for whatever he was needing that deletion logic for. it's possible we might need to still delete the webhook but only if we are not explicitly having it enabled
Makefile
Outdated
@@ -242,6 +242,7 @@ ci-install-hypershift-private: | |||
--oidc-storage-provider-s3-credentials=/etc/hypershift-pool-aws-credentials/credentials \ | |||
--oidc-storage-provider-s3-bucket-name=hypershift-ci-oidc \ | |||
--oidc-storage-provider-s3-region=us-east-1 \ | |||
--enable-validating-webhook \ |
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 don't want to add the validating webhook here. This is used for CI jobs not related to kubevirt or self managed
hcPath := "/validate-hypershift-openshift-io-v1beta1-hostedcluster" | ||
npPath := "/validate-hypershift-openshift-io-v1beta1-nodepool" | ||
sideEffects := admissionregistrationv1.SideEffectClassNone | ||
timeout := int32(10) |
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.
The mutating webhook uses a 15 second timeout. it would be good to be consistent
hypershift-operator/main.go
Outdated
// Since we dropped the validation webhook server we need to ensure this resource doesn't exist | ||
// otherwise it will intercept kas requests and fail. | ||
// TODO (alberto): dropped in 4.14. | ||
validatingWebhookConfiguration := &admissionregistrationv1.ValidatingWebhookConfiguration{ | ||
TypeMeta: metav1.TypeMeta{ | ||
Kind: "ValidatingWebhookConfiguration", | ||
APIVersion: admissionregistrationv1.SchemeGroupVersion.String(), | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Namespace: opts.Namespace, | ||
Name: hyperv1.GroupVersion.Group, | ||
}, | ||
} | ||
if err := mgr.GetClient().Delete(ctx, validatingWebhookConfiguration); err != nil { | ||
if !apierrors.IsNotFound(err) { | ||
return err | ||
} | ||
} | ||
|
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.
@enxebre will we cause any issues by removing this code that deletes the validation webhook?
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.
yes, we might have some envs running on versions where going through this is still necessary. So this would need to gate on if webhookNotEnabled kind of thing.
Also in addition please consider using ignore fail policy.
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.
Thanks @enxebre.
I'm not sure how to handle this. The flag is only known to the cli, and this is where the webhook is created. Main is running inside the cluster, knowing nothing about the installation and its configuration, AFAIK.
The only thing I can think of, is to use different webhook name for the new one. I don't like this idea and I find it confusing and error prompt. Also, not sure it's possible. The current name is hyperv1.GroupVersion.Group
Do you have any other idea?
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 can explore either move the logic out to "install" or propagate the input into the HO options
|
||
if _, isTimeout := ctx.Deadline(); !isTimeout { | ||
var cancel context.CancelFunc | ||
ctx, cancel = context.WithTimeout(ctx, time.Second*3) |
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'd feel better if we extended this to a 5 second timeout... it likely doesn't matter, but i'm more on the conservative side when it comes to timing out operations.
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'll make it 10, to be closer to the webhook T/O (15 sec)
eg.Go(func() error { | ||
var err error | ||
cnvVersion, err = cl.GetInfraKubevirtVersion(egCtx) | ||
return err | ||
}) | ||
|
||
eg.Go(func() error { | ||
var err error | ||
k8sVersion, err = cl.GetInfraK8sVersion() | ||
return err | ||
}) | ||
|
||
err := eg.Wait() | ||
if err != nil { | ||
return err | ||
} |
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.
that's kind of neat. I haven't seen this usage of errgroups before. looks good
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.
ad53696
to
d6c8587
Compare
Add validating webhook for HostedClusters and NodePools, to check if kubevirt external infra cluster is with sufficient CNV and K8s versions. This is already checked on the operator, but adding this logic to the webhook will prevent the creating of resources in insufficient environment, in advance. Fixing this error is not an easy task and require upgrading the infra cluster, or the CNV installation, and we prefer to fail fast in this case. Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
d6c8587
to
d95a109
Compare
/rest e2e-aws |
/test e2e-aws |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: davidvossel, nunnatsa 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 |
/retest |
@nunnatsa: 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/test-infra repository. I understand the commands that are listed here. |
What this PR does / why we need it:
Add validating webhook for HostedClusters and NodePools, to check if kubevirt external infra cluster is with sufficient CNV and K8s versions.
This is already checked on the operator, but adding this logic to the webhook will prevent the creating of resources in insufficient environment, in advance. Fixing this error is not an easy task and require upgrading the infra cluster, or the CNV installation, and we prefer to fail fast in this case.
Which issue(s) this PR fixes
Fixes #CNV-34094
Checklist