-
Notifications
You must be signed in to change notification settings - Fork 45
OCPCLOUD-913 - Tests for webhook configurations provisioning by MAO #176
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
OCPCLOUD-913 - Tests for webhook configurations provisioning by MAO #176
Conversation
|
/retest |
JoelSpeed
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.
Looks good, not sure about a couple of the tests, left some minor suggestions otherwise :)
pkg/framework/webhooks.go
Outdated
| if err := c.Delete(context.TODO(), webhookConfiguraiton); err != nil { | ||
| klog.Errorf("error querying api for ValidatingWebhookConfiguration object %q: %v, retrying...", webhookConfiguraiton.Name, err) | ||
| return false, nil | ||
| } | ||
| return true, nil |
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.
What about trying to delete a resource that doesn't exist? Should we account for that?
| return wait.PollImmediate(RetryShort, WaitShort, func() (bool, error) { | ||
| if err := c.Delete(context.TODO(), webhookConfiguraiton); err != nil { | ||
| klog.Errorf("error querying api for MutatingWebhookConfiguration object %q: %v, retrying...", webhookConfiguraiton.Name, err) | ||
| return false, nil | ||
| } | ||
| return true, nil |
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.
What about trying to delete a resource that doesn't exist? Should we account for that?
pkg/framework/webhooks.go
Outdated
| // IsMutatingWebhookConfigurationMatched expects a matching MutatingWebhookConfiguration to be present in the cluster | ||
| func IsMutatingWebhookConfigurationMatched(c client.Client) bool { |
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.
Maybe this should be called Synced rather than Matched, since we are checking if MAO has synced it to what we expect right?
pkg/framework/webhooks.go
Outdated
| } | ||
|
|
||
| // IsValidatingWebhookConfigurationMatched expects a matching MutatingWebhookConfiguration to be present in the cluster | ||
| func IsValidatingWebhookConfigurationMatched(c client.Client) bool { |
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.
Maybe this should be called Synced rather than Matched, since we are checking if MAO has synced it to what we expect right?
| It("reconcile webhook configuration", func() { | ||
| client, err := framework.LoadClient() | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| Expect(framework.IsMutatingWebhookConfigurationMatched(client)).To(BeTrue()) | ||
| }) | ||
|
|
||
| It("reconcile validating webhook configuration", func() { | ||
| client, err := framework.LoadClient() | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| Expect(framework.IsValidatingWebhookConfigurationMatched(client)).To(BeTrue()) | ||
| }) |
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.
One of these specifies the type, the other doesn't, should we make them both specify?
|
|
||
| Expect(framework.UpdateMutatingWebhookConfiguration(client, toUpdate)).To(Succeed()) | ||
|
|
||
| Expect(framework.IsMutatingWebhookConfigurationMatched(client)).To(BeTrue()) |
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.
Surely after updating it can never match the default again, because there will be no CA Bundle in there?
|
|
||
| Expect(framework.UpdateValidatingWebhookConfiguration(client, toUpdate)).To(Succeed()) | ||
|
|
||
| Expect(framework.IsValidatingWebhookConfigurationMatched(client)).To(BeTrue()) |
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.
Surely after updating it can never match the default again, because there will be no CA Bundle in there?
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.
It's the place where DeepDerivative would still fit, as it will ignore differences with empty field on the default resource. So it will still match :)
f537152 to
a1fe11c
Compare
|
/retest |
1 similar comment
|
/retest |
JoelSpeed
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.
Ok, LGTM, added a couple of suggestions for adding a comment, WDYT?
| return false, nil | ||
| } | ||
|
|
||
| equal := equality.Semantic.DeepDerivative(DefaultMutatingWebhookConfiguration.Webhooks, existing.Webhooks) |
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 worth a note that this will should the CABundle field that has been set by the injector and that's why we are using DeepDerivative
| return false, nil | ||
| } | ||
|
|
||
| equal := equality.Semantic.DeepDerivative(DefaultValidatingWebhookConfiguration.Webhooks, existing.Webhooks) |
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 worth a note that this will should the CABundle field that has been set by the injector and that's why we are using DeepDerivative
a1fe11c to
343c357
Compare
|
@JoelSpeed I added a small comment on the |
|
/approve Thanks! |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JoelSpeed The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
pkg/framework/webhooks.go
Outdated
|
|
||
| // UpdateMutatingWebhookConfiguration updates the specified mutating webhook configuration | ||
| func UpdateMutatingWebhookConfiguration(c client.Client, updated *admissionregistrationv1.MutatingWebhookConfiguration) error { | ||
| return wait.PollImmediate(RetryShort, WaitMedium, func() (bool, error) { |
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.
why WaitMedium here?
this is GetMutatingWebhookConfiguration and so nesting wait.PollImmediate calls.
I think the only purpose of using wait.PollImmediate in this library funcs is to protect and don't fail the test on a transient network issue? to that end we could may be just wait a few seconds? wdyt?
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.
Sounds good to me. Webhooks are ready to react as soon as they are updated in the cluster. I could see potential to use apply method from library-ho, but short wait should be enough in any case.
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 I decreased both wait periods to be at 1 min at max, in case of the client throttling appears, and 3 min for waiting on webhook configuration to be synced, PTAL
343c357 to
52fcced
Compare
|
thanks, not a blocker for this PR but my point is that I think even WaitShort is too much here. This are not eventually consistent functions. This are atomic actions, the only reason to wait.poll here, if any, is protection against network transient issues. For that a shorter e.g 5s wait period would be reasonable. WDYT? |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
5 similar comments
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
10 similar comments
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/hold until #181 passes |
|
/hold cancel |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
11 similar comments
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
@Danil-Grigorev: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
Currently, we are managing webhooks from MAO, as CVO is not expected to handle resources with changing spec by another operator at the upgrade time. The implementation is covered with unit tests, but we need to ensure
cluster-actuator-pkgcontains e2e tests for such implementation too.This PR is satisfying this requirement.