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

Enable custom aws route controller manager if no provider config is specified. #612

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions pkg/webhook/controlplane/ensurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,25 +667,25 @@ func (c *controlPlaneMutator) Mutate(ctx context.Context, new, old client.Object
if greaterEqual122 {
switch x.Name {
case cluster.Shoot.Name:
config := &awsv1alpha1.ControlPlaneConfig{
TypeMeta: metav1.TypeMeta{
APIVersion: awsv1alpha1.SchemeGroupVersion.String(),
Kind: "ControlPlaneConfig",
},
}
if x.Spec.ProviderConfig != nil && x.Spec.ProviderConfig.Raw != nil {
config := &awsv1alpha1.ControlPlaneConfig{
TypeMeta: metav1.TypeMeta{
APIVersion: awsv1alpha1.SchemeGroupVersion.String(),
Kind: "ControlPlaneConfig",
},
}
if _, _, err := decoder.Decode(x.Spec.ProviderConfig.Raw, nil, config); err != nil {
return err
}
if config.CloudControllerManager == nil {
config.CloudControllerManager = &awsv1alpha1.CloudControllerManagerConfig{}
}
if config.CloudControllerManager.UseCustomRouteController == nil {
extensionswebhook.LogMutation(c.logger, x.Kind, x.Namespace, x.Name)
config.CloudControllerManager.UseCustomRouteController = pointer.Bool(true)
x.Spec.ProviderConfig = &runtime.RawExtension{
Object: config,
}
}
if config.CloudControllerManager == nil {
config.CloudControllerManager = &awsv1alpha1.CloudControllerManagerConfig{}
}
if config.CloudControllerManager.UseCustomRouteController == nil {
extensionswebhook.LogMutation(c.logger, x.Kind, x.Namespace, x.Name)
config.CloudControllerManager.UseCustomRouteController = pointer.Bool(true)
x.Spec.ProviderConfig = &runtime.RawExtension{
Object: config,
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/webhook/controlplane/ensurer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,20 @@ done
Expect(*controlPlane.Spec.ProviderConfig.Object.(*awsv1alpha1.ControlPlaneConfig).CloudControllerManager.UseCustomRouteController).To(BeTrue())
})

It("should enable for kubernetes >= 1.22 without provider config", func() {
controlPlane.Spec.DefaultSpec = extensionsv1alpha1.DefaultSpec{}
oldControlPlane := controlPlane.DeepCopy()

client.EXPECT().Get(ctx, clusterKey, &extensionsv1alpha1.Cluster{}).DoAndReturn(clientGet(newCluster))

err := mutator.Mutate(ctx, controlPlane, nil)
Expect(err).To(Not(HaveOccurred()))
Expect(oldControlPlane).To(Not(Equal(controlPlane)))
Expect(controlPlane.Spec.ProviderConfig.Object).ToNot(BeNil())
Expect(*controlPlane.Spec.ProviderConfig.Object.(*awsv1alpha1.ControlPlaneConfig).CloudControllerManager).ToNot(BeNil())
Expect(*controlPlane.Spec.ProviderConfig.Object.(*awsv1alpha1.ControlPlaneConfig).CloudControllerManager.UseCustomRouteController).To(BeTrue())
})

It("should not enable on update", func() {
oldControlPlane := controlPlane.DeepCopy()

Expand Down