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

✨ CAPD: add DockerClusterTemplate type #4903

Merged
merged 1 commit into from
Jul 23, 2021

Conversation

ykakarap
Copy link
Contributor

@ykakarap ykakarap commented Jul 8, 2021

What this PR does / why we need it:
Add DockerClusterTemplate type to CAPD provider. This type will be used by ClusterClass.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #4900

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 8, 2021
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 8, 2021
@sbueringer
Copy link
Member

Nothing additional from me, lgtm apart from @fabriziopandini's comments

@ykakarap ykakarap force-pushed the dockerclustertemplate branch from b202ff0 to 3b95493 Compare July 9, 2021 18:09
Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

Change lgtm pending adding web hook ensuring template are immutable.
Also, even do there are not yet validation rules on create, should we create an empty func called on creation by both DockerClusterTemplate and DockerCluster web hooks, so we ensure that future validation rules applies to both types consistently?

@ykakarap ykakarap force-pushed the dockerclustertemplate branch from 3b95493 to c46cbfd Compare July 14, 2021 00:15
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 14, 2021
@ykakarap
Copy link
Contributor Author

Also, even do there are not yet validation rules on create, should we create an empty func called on creation by both DockerClusterTemplate and DockerCluster web hooks, so we ensure that future validation rules applies to both types consistently?

+1 to this

@ykakarap ykakarap force-pushed the dockerclustertemplate branch 2 times, most recently from 83fe825 to 2b85978 Compare July 14, 2021 00:23
@ykakarap
Copy link
Contributor Author

/retest

@ykakarap ykakarap force-pushed the dockerclustertemplate branch from 2b85978 to a150e01 Compare July 14, 2021 02:48
@ykakarap
Copy link
Contributor Author

/retest

@ykakarap ykakarap force-pushed the dockerclustertemplate branch 4 times, most recently from 27c4b6e to 903c2cb Compare July 14, 2021 05:55
Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

only two small nits left, otherwise lgtm

Complete()
}

//+kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1alpha4-dockerclustertemplate,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=dockerclustertemplates,versions=v1alpha4,name=validation.dockerclustertemplate.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1
Copy link
Member

Choose a reason for hiding this comment

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

I think you have to put a space between // and +. So //+ => // +
I'm not sure if there are cases where those comments are not picked up without a space. (but saw similar issues with these kinds of magic comments)

Can you grep for occurrences of //+ there are two other cases in DockerMachinePool which we probably should also fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will make sure to fix all of them :)


// Default implements webhook.Defaulter so a webhook will be registered for the type.
func (r *DockerClusterTemplate) Default() {
dockerclustertemplatelog.Info("default", "name", r.Name)
Copy link
Member

Choose a reason for hiding this comment

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

In case we drop the logs in the other webhook, we should also drop them here

@@ -1,11 +1,100 @@

---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
Copy link
Member

Choose a reason for hiding this comment

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

I think adding this requires additions to webhookcainjection_patch.yaml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are there example of the kinds of additions I need to do?

Also do you think this could this be the reason for the piepline failing with the following error:

Error from server (InternalError): error when creating "STDIN": Internal error occurred: failed calling webhook "validation.dockercluster.infrastructure.cluster.x-k8s.io": Post "https://capd-webhook-service.capd-system.svc:443/mutate-infrastructure-cluster-x-k8s-io-v1alpha4-dockercluster?timeout=10s": x509: certificate signed by unknown authority

Copy link
Member

@sbueringer sbueringer Jul 15, 2021

Choose a reason for hiding this comment

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

Roughly: (we should also have it in the webhookcainjection_patch.yaml files of other controllers)

apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
  name: mutating-webhook-configuration
  annotations:
    cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)

P.S. Yup, that's the cause of the error :)

@ykakarap ykakarap force-pushed the dockerclustertemplate branch from 903c2cb to 90001cf Compare July 15, 2021 20:33
@ykakarap
Copy link
Contributor Author

/retest

@ykakarap ykakarap force-pushed the dockerclustertemplate branch from 90001cf to dd9ec25 Compare July 15, 2021 20:51
@ykakarap
Copy link
Contributor Author

/retest

@ykakarap ykakarap force-pushed the dockerclustertemplate branch from dd9ec25 to 53d4ef6 Compare July 15, 2021 21:45
@sbueringer
Copy link
Member

@ykakarap You have to run make generate-go

@ykakarap
Copy link
Contributor Author

/retest

@ykakarap
Copy link
Contributor Author

@fabriziopandini addressed all the comments on the PR and all pipelines are green.
Please review when you can.

@fabriziopandini
Copy link
Member

/lgtm
@sbueringer @stmcginnis PTAL

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 19, 2021
func (r *DockerClusterTemplate) ValidateUpdate(oldRaw runtime.Object) error {
old := oldRaw.(*DockerClusterTemplate)
if !reflect.DeepEqual(r.Spec, old.Spec) {
return errors.New("DockerClusterTemplateSpec is immutable")
Copy link
Member

Choose a reason for hiding this comment

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

nit: Maybe make this error text consistent to the one used in: https://github.com/kubernetes-sigs/cluster-api/pull/4904/files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit addressed.

@ykakarap ykakarap force-pushed the dockerclustertemplate branch from 5afc219 to ef6017d Compare July 19, 2021 22:17
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 19, 2021
return errors.New("DockerMachineTemplateSpec is immutable")
func (m *DockerMachineTemplate) ValidateUpdate(oldRaw runtime.Object) error {
var allErrs field.ErrorList
old := oldRaw.(*DockerMachineTemplate)
Copy link
Member

@sbueringer sbueringer Jul 20, 2021

Choose a reason for hiding this comment

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

Sorry last one. We usually seem to check if the type case works and then return an error (instead of a panic which would happen otherwise)

        oldM, ok := old.(*Machine)
	if !ok {
		return apierrors.NewBadRequest(fmt.Sprintf("expected a Machine but got a %T", old))
	}

Copy link
Member

Choose a reason for hiding this comment

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

(same for DockerClusterTemplate and the KubeadmControlPlaneTemplate PR)

@ykakarap ykakarap force-pushed the dockerclustertemplate branch from ef6017d to 565286f Compare July 20, 2021 15:30
@fabriziopandini
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 20, 2021
@ykakarap
Copy link
Contributor Author

/retest

1 similar comment
@ykakarap
Copy link
Contributor Author

/retest

@sbueringer
Copy link
Member

@ykakarap Thank you very much!

/lgtm

@stmcginnis
Copy link
Contributor

Just wondering - not saying it needs to happen, just looking to learn from the larger team - do we need to add any documentation about this to somewhere like docs/book/src/tasks/experimental-features/experimental-features.md?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2021
@ykakarap ykakarap force-pushed the dockerclustertemplate branch from 565286f to fce43ed Compare July 23, 2021 01:45
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 23, 2021
@ykakarap
Copy link
Contributor Author

@fabriziopandini had to rebase because of merge conflicts. Can you please re-lgtm this? 😄

@sbueringer
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 23, 2021
@fabriziopandini
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 23, 2021
@k8s-ci-robot k8s-ci-robot merged commit f85f37a into kubernetes-sigs:master Jul 23, 2021
@k8s-ci-robot k8s-ci-robot added this to the v0.4 milestone Jul 23, 2021
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add DockerClusterTemplate type
5 participants