-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
✨ CAPD: add DockerClusterTemplate type #4903
Conversation
test/infrastructure/docker/config/rbac/dockerclustertemplate_editor_role.yaml
Outdated
Show resolved
Hide resolved
test/infrastructure/docker/config/rbac/dockerclustertemplate_viewer_role.yaml
Outdated
Show resolved
Hide resolved
Nothing additional from me, lgtm apart from @fabriziopandini's comments |
b202ff0
to
3b95493
Compare
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.
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?
3b95493
to
c46cbfd
Compare
+1 to this |
83fe825
to
2b85978
Compare
/retest |
2b85978
to
a150e01
Compare
/retest |
27c4b6e
to
903c2cb
Compare
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.
only two small nits left, otherwise lgtm
test/infrastructure/docker/api/v1alpha4/dockercluster_webhook.go
Outdated
Show resolved
Hide resolved
test/infrastructure/docker/api/v1alpha4/dockercluster_default.go
Outdated
Show resolved
Hide resolved
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 |
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.
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.
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.
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) |
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.
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 |
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.
I think adding this requires additions to webhookcainjection_patch.yaml
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.
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
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.
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 :)
903c2cb
to
90001cf
Compare
/retest |
90001cf
to
dd9ec25
Compare
/retest |
dd9ec25
to
53d4ef6
Compare
@ykakarap You have to run |
/retest |
@fabriziopandini addressed all the comments on the PR and all pipelines are green. |
/lgtm |
func (r *DockerClusterTemplate) ValidateUpdate(oldRaw runtime.Object) error { | ||
old := oldRaw.(*DockerClusterTemplate) | ||
if !reflect.DeepEqual(r.Spec, old.Spec) { | ||
return errors.New("DockerClusterTemplateSpec is immutable") |
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.
nit: Maybe make this error text consistent to the one used in: https://github.com/kubernetes-sigs/cluster-api/pull/4904/files
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.
nit addressed.
5afc219
to
ef6017d
Compare
return errors.New("DockerMachineTemplateSpec is immutable") | ||
func (m *DockerMachineTemplate) ValidateUpdate(oldRaw runtime.Object) error { | ||
var allErrs field.ErrorList | ||
old := oldRaw.(*DockerMachineTemplate) |
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.
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))
}
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.
(same for DockerClusterTemplate and the KubeadmControlPlaneTemplate PR)
ef6017d
to
565286f
Compare
/lgtm |
/retest |
1 similar comment
/retest |
@ykakarap Thank you very much! /lgtm |
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 |
565286f
to
fce43ed
Compare
@fabriziopandini had to rebase because of merge conflicts. Can you please re-lgtm this? 😄 |
/lgtm |
/approve |
[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 |
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