Skip to content

Conversation

@Danil-Grigorev
Copy link

@Danil-Grigorev Danil-Grigorev commented Jul 17, 2020

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-pkg contains e2e tests for such implementation too.

This PR is satisfying this requirement.

@Danil-Grigorev Danil-Grigorev changed the title Webhooks mao e2e OCPCLOUD-913 - Tests for webhook configurations provisioning by MAO Jul 17, 2020
@Danil-Grigorev
Copy link
Author

/retest

Copy link
Contributor

@JoelSpeed JoelSpeed left a 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 :)

Comment on lines 58 to 65
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
Copy link
Contributor

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?

Comment on lines 68 to 78
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
Copy link
Contributor

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?

Comment on lines 109 to 110
// IsMutatingWebhookConfigurationMatched expects a matching MutatingWebhookConfiguration to be present in the cluster
func IsMutatingWebhookConfigurationMatched(c client.Client) bool {
Copy link
Contributor

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?

}

// IsValidatingWebhookConfigurationMatched expects a matching MutatingWebhookConfiguration to be present in the cluster
func IsValidatingWebhookConfigurationMatched(c client.Client) bool {
Copy link
Contributor

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?

Comment on lines 70 to 82
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())
})
Copy link
Contributor

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())
Copy link
Contributor

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())
Copy link
Contributor

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?

Copy link
Author

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 :)

@Danil-Grigorev
Copy link
Author

/retest

1 similar comment
@Danil-Grigorev
Copy link
Author

/retest

Copy link
Contributor

@JoelSpeed JoelSpeed left a 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)
Copy link
Contributor

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)
Copy link
Contributor

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

@Danil-Grigorev
Copy link
Author

@JoelSpeed I added a small comment on the DeepDerivative usage.

@JoelSpeed
Copy link
Contributor

/approve

Thanks!

@openshift-ci-robot
Copy link

[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

Details 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-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 22, 2020
@Danil-Grigorev
Copy link
Author

/retest


// UpdateMutatingWebhookConfiguration updates the specified mutating webhook configuration
func UpdateMutatingWebhookConfiguration(c client.Client, updated *admissionregistrationv1.MutatingWebhookConfiguration) error {
return wait.PollImmediate(RetryShort, WaitMedium, func() (bool, error) {
Copy link
Member

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?

Copy link
Author

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.

Copy link
Author

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

@enxebre
Copy link
Member

enxebre commented Jul 23, 2020

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?
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2020
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

5 similar comments
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

10 similar comments
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@Danil-Grigorev
Copy link
Author

/hold until #181 passes

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 24, 2020
@Danil-Grigorev
Copy link
Author

/hold cancel
/retest

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 25, 2020
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

11 similar comments
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jul 26, 2020

@Danil-Grigorev: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-gcp-operator 52fcced link /test e2e-gcp-operator

Full PR test history. Your PR dashboard.

Details

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.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit d98f9a7 into openshift:master Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants