Skip to content

Conversation

@sebgl
Copy link
Contributor

@sebgl sebgl commented Jan 7, 2020

The v1 webhook did work as expected, but not the v1beta1 webhook before
this commit.

To fix this, it:

  • creates 2 distinct webhooks with distinct names
    (elastic-es-validation-v1beta1.k8s.elastic.co and
    elastic-es-validation-v1.k8s.elastic.co) in the
    ValidatingWebhookConfiguration
  • ensures the v1beta1 webhook is created along with the v1 webhook at
    operator startup
  • registers v1beta1 resources in the schema, required for the v1beta1
    webhook to run

To test it, I deployed the operator and webhook configurations, then:

  • tried applying a v1beta1 resource: the v1beta1 webhook was triggered,
    returning an error mentioning v1beta1.NodeSet
  • tried applying a v1 resource: the v1 webhook was triggered, returning
    an error mentioning v1.NodeSet

Fixes #2355.

The v1 webhook did work as expected, but not the v1beta1 webhook before
this commit.

To fix this, it:

* creates 2 distinct webhooks with distinct names
(`elastic-es-validation-v1beta1.k8s.elastic.co` and
`elastic-es-validation-v1.k8s.elastic.co`) in the
ValidatingWebhookConfiguration
* ensures the v1beta1 webhook is created along with the v1 webhook at
operator startup
* registers v1beta1 resources in the schema, required for the v1beta1
webhook to run

To test it, I deployed the operator and webhook configurations, then:
- tried applying a v1beta1 resource: the v1beta1 webhook was triggered,
returning an error mentioning v1beta1.NodeSet
- tried applying a v1 resource: the v1 webhook was triggered, returning
an error mentioning v1.NodeSet
@sebgl sebgl added >bug Something isn't working v1.0.0 labels Jan 7, 2020
Copy link
Contributor

@thbkrkr thbkrkr left a comment

Choose a reason for hiding this comment

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

LGTM

The webhook is composed of 4 main components. Here is a brief description of each of them to understand how they interact, their naming, and how they are managed.

. A `ValidatingWebhookConfiguration` object that defines the validating webhook, named `elastic-es-validation.k8s.elastic.co`. It must be created before starting the operator. The `caBundle` field can be automatically managed as part of the automatic certificate management _(see below)_.
. A `ValidatingWebhookConfiguration` object that defines the validating webhook, named `elastic-es-validation-{eck_crd_version}.k8s.elastic.co`. It must be created before starting the operator. The `caBundle` field can be automatically managed as part of the automatic certificate management _(see below)_.
Copy link
Contributor

Choose a reason for hiding this comment

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

The ValidatingWebhookConfiguration object is named elastic-webhook.k8s.elastic.co
It is the clientConfig that is named elastic-es-validation-{eck_crd_version}.k8s.elastic.co

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ValidatingWebhookConfiguration contains a webhooks array of Webhook, for which we define the name. That's not the name of the clientConfig.

I think in "A ValidatingWebhookConfiguration object that defines the validating webhook, named elastic-es-validation-{eck_crd_version}.k8s.elastic.co", named refers to the inner validating webhook, not to the ValidatingWebhookConfiguration.

WDYT?

Copy link
Contributor Author

@sebgl sebgl Jan 7, 2020

Choose a reason for hiding this comment

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

We can maybe simplify that sentence to A ValidatingWebhookConfiguration object that defines the validating webhooks(without any name reference) so we avoid the confusion?
I think the user can name them any way they want as long as they point to the correct path.

Copy link
Contributor

@barkbay barkbay left a comment

Choose a reason for hiding this comment

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

Just left a nit in the doc, otherwise lgtm

@sebgl sebgl merged commit 5ddff7a into elastic:master Jan 7, 2020
sebgl added a commit to sebgl/cloud-on-k8s that referenced this pull request Jan 7, 2020
* Fix v1beta1 webhook

The v1 webhook did work as expected, but not the v1beta1 webhook before
this commit.

To fix this, it:

* creates 2 distinct webhooks with distinct names
(`elastic-es-validation-v1beta1.k8s.elastic.co` and
`elastic-es-validation-v1.k8s.elastic.co`) in the
ValidatingWebhookConfiguration
* ensures the v1beta1 webhook is created along with the v1 webhook at
operator startup
* registers v1beta1 resources in the schema, required for the v1beta1
webhook to run

To test it, I deployed the operator and webhook configurations, then:
- tried applying a v1beta1 resource: the v1beta1 webhook was triggered,
returning an error mentioning v1beta1.NodeSet
- tried applying a v1 resource: the v1 webhook was triggered, returning
an error mentioning v1.NodeSet

* Remove ambiguity in webhooks docs
sebgl added a commit that referenced this pull request Jan 7, 2020
* Fix v1beta1 webhook

The v1 webhook did work as expected, but not the v1beta1 webhook before
this commit.

To fix this, it:

* creates 2 distinct webhooks with distinct names
(`elastic-es-validation-v1beta1.k8s.elastic.co` and
`elastic-es-validation-v1.k8s.elastic.co`) in the
ValidatingWebhookConfiguration
* ensures the v1beta1 webhook is created along with the v1 webhook at
operator startup
* registers v1beta1 resources in the schema, required for the v1beta1
webhook to run

To test it, I deployed the operator and webhook configurations, then:
- tried applying a v1beta1 resource: the v1beta1 webhook was triggered,
returning an error mentioning v1beta1.NodeSet
- tried applying a v1 resource: the v1 webhook was triggered, returning
an error mentioning v1.NodeSet

* Remove ambiguity in webhooks docs
mjmbischoff pushed a commit to mjmbischoff/cloud-on-k8s that referenced this pull request Jan 13, 2020
* Fix v1beta1 webhook

The v1 webhook did work as expected, but not the v1beta1 webhook before
this commit.

To fix this, it:

* creates 2 distinct webhooks with distinct names
(`elastic-es-validation-v1beta1.k8s.elastic.co` and
`elastic-es-validation-v1.k8s.elastic.co`) in the
ValidatingWebhookConfiguration
* ensures the v1beta1 webhook is created along with the v1 webhook at
operator startup
* registers v1beta1 resources in the schema, required for the v1beta1
webhook to run

To test it, I deployed the operator and webhook configurations, then:
- tried applying a v1beta1 resource: the v1beta1 webhook was triggered,
returning an error mentioning v1beta1.NodeSet
- tried applying a v1 resource: the v1 webhook was triggered, returning
an error mentioning v1.NodeSet

* Remove ambiguity in webhooks docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug Something isn't working v1.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webhook does not return any error for resources deployed in version v1beta1

3 participants