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

Add support for conversion webhook 🍸 #2413

Merged
merged 2 commits into from
Apr 27, 2020

Conversation

vdemeester
Copy link
Member

@vdemeester vdemeester commented Apr 16, 2020

Changes

This adds a new webhook controller : ConversionController.
The HubVersion is the stored version, and Zygotes stores the types
of supported versions.

The CRDs are updated to setup the conversion strategy to webhook,
pointing to the tekton-pipelines-webhook.

An update in the webhook clusterrole is required for customresourcedefinitions.

Closes #2047

/cc @sbwsg @bobcatfish @mattmoor

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

Add support for conversion webhook for tektoncd/pipeline CRDs

@tekton-robot tekton-robot requested a review from a user April 16, 2020 11:58
@tekton-robot
Copy link
Collaborator

@vdemeester: GitHub didn't allow me to request PR reviews from the following users: mattmoor.

Note that only tektoncd members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

Changes

This adds a new webhook controller : ConversionController.
The HubVersion is the stored version, and Zygotes stores the types
of supported versions.

The CRDs are updated to setup the conversion strategy to webhook,
pointing to the tekton-pipelines-webhook.

An update in the webhook clusterrole is required for customresourcedefinitions.

Closes #2047

/cc @sbwsg @bobcatfish @mattmoor

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

Add support for conversion webhook for tektoncd/pipeline CRDs

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.

@tekton-robot tekton-robot requested a review from bobcatfish April 16, 2020 11:58
@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Apr 16, 2020
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 16, 2020
@vdemeester vdemeester force-pushed the 2047-conversion-webhook branch from 8186199 to cb1960c Compare April 16, 2020 12:35
@vdemeester
Copy link
Member Author

/test pull-tekton-pipeline-build-tests

@vdemeester
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

cc @dprotaso

This generally LGTM, but calling in the big guns :)


// A function that infuses the context passed to ConvertTo/ConvertFrom/SetDefaults with custom metadata
func(ctx context.Context) context.Context {
return ctx
Copy link
Member

Choose a reason for hiding this comment

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

Did you want the ctx stuff here too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I followed what was in knative/serving 😝

@vdemeester
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@vdemeester
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

3 similar comments
@vdemeester
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@vdemeester
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@vdemeester
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@vdemeester vdemeester force-pushed the 2047-conversion-webhook branch from cb1960c to b49e956 Compare April 20, 2020 13:38
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 20, 2020
@vdemeester
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

1 similar comment
@vdemeester
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@@ -98,7 +103,7 @@ func NewValidationAdmissionController(ctx context.Context, cmw configmap.Watcher

// A function that infuses the context passed to Validate/SetDefaults with custom metadata.
func(ctx context.Context) context.Context {
return ctx
return contexts.WithUpgradeViaDefaulting(store.ToContext(ctx))
Copy link
Contributor

Choose a reason for hiding this comment

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

contexts.WithUpgradeViaDefaulting

Are you using this upgrade marker for anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah we do

@vdemeester vdemeester force-pushed the 2047-conversion-webhook branch from b49e956 to da932a2 Compare April 22, 2020 08:07
@vdemeester
Copy link
Member Author

The error is legit in this PR, see #2468

@vdemeester
Copy link
Member Author

/hold

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 22, 2020
@vdemeester vdemeester force-pushed the 2047-conversion-webhook branch from da932a2 to f3a8be7 Compare April 22, 2020 12:42
@vdemeester
Copy link
Member Author

yay it is green 🌞

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

I think all of my feedback is just asking for some more detail in comments - I think it'll be worthwhile for folks like me who don't really know what's going on :D

but i also understand if you want to merge as is and add that afterward - would like to see it tho if possible!

/approve

@@ -124,6 +129,68 @@ func NewConfigValidationController(ctx context.Context, cmw configmap.Watcher) *
)
}

func NewConversionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
// nolint: golint
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we not want to lint this?

Copy link
Member Author

Choose a reason for hiding this comment

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

😅 well, I need to find a better name than v1beta1_ for the variable.. and I was lazy 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure what variable name to use to be honest 🙃

// The path on which to serve the webhook
"/resource-conversion",

// Specify the types of custom resource definitions that should be converted
Copy link
Collaborator

Choose a reason for hiding this comment

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

so the keys are the types to convert TO and the zygotes are the version to convert FROM is that right? im not 100% clear either way tho so maybe some more detail in the comment might help?

@@ -63,6 +63,12 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tekton-pipelines-webhook-cluster-access
rules:
# The webhook needs to be able to list and update customresourcedefinitions,
# mainly to update the webhook certificates.ku
Copy link
Collaborator

Choose a reason for hiding this comment

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

ku i think is a typo?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is 🤦‍♂️

- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions", "customresourcedefinitions/status"]
verbs: ["get", "list", "update", "patch", "watch"]
# verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we can remove this line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed 😅

# this is a work around so we don't need to flush out the
# schema for each version at this time
#
# see issue: https://github.com/knative/serving/issues/912
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible to get a bit more detail here on how this works? looking at the issue it's not immediately clear to me, and im wondering how x-kubernetes-preserve-unknown-fields affect unknown fields / typos (making me think of tektoncd/triggers#526)

Copy link
Member Author

Choose a reason for hiding this comment

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

Right preserveUnknownFields and this one seems to be required to work with k8s 1.18 and the conversion webhook somehow.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the comments 👼

Group: GroupName,
Resource: "conditions",
}
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

im not 100% clear on why these are required now or where they are used? does the conversion webhook automatically detect these?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do here : https://github.com/tektoncd/pipeline/pull/2413/files#diff-58de452513b7e8d8d3cfea23eb4ae6a8R170 (and we might do at other parts of the code). It makes it a bit easier to get conditions.tekton.dev or pipelineruns.tekton.dev in code without hard coding those.

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bobcatfish

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 22, 2020
@vdemeester
Copy link
Member Author

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 23, 2020
@vdemeester vdemeester force-pushed the 2047-conversion-webhook branch from f3a8be7 to 0dbd57e Compare April 23, 2020 14:01
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
This adds a new webhook controller : ConversionController.
The `HubVersion` is the stored version, and Zygotes stores the types
of supported versions.

The CRDs are updated to setup the conversion strategy to webhook,
pointing to the tekton-pipelines-webhook.

An update in the webhook clusterrole is required for customresourcedefinitions.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@vdemeester vdemeester force-pushed the 2047-conversion-webhook branch from 0dbd57e to 82a934d Compare April 24, 2020 07:48
@vdemeester
Copy link
Member Author

ping @sbwsg @bobcatfish @imjasonh this is ready for review and updated

@ghost
Copy link

ghost commented Apr 27, 2020

/lgtm

/meow rocketship

@tekton-robot tekton-robot assigned ghost Apr 27, 2020
@tekton-robot
Copy link
Collaborator

@sbwsg: cat image

In response to this:

/lgtm

/meow rocketship

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.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 27, 2020
@tekton-robot tekton-robot merged commit 8213475 into tektoncd:master Apr 27, 2020
@vdemeester vdemeester deleted the 2047-conversion-webhook branch April 28, 2020 08:24
@afrittoli afrittoli added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 30, 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. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Latest knative.dev/pkg adds support for conversion webhooks
7 participants