Skip to content

Commit

Permalink
Enable custom aws route controller manager if no provider config is s…
Browse files Browse the repository at this point in the history
…pecified.

The custom aws route controller manager is essential to the shoot cluster
working without overlay network. Therefore, it needs to be enabled regardless
if there is a provider configuration or not. Otherwise, shoot clusters will
get no overlay, but no pod routes.
  • Loading branch information
ScheererJ committed Sep 19, 2022
1 parent 315d219 commit f28fe0d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
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

0 comments on commit f28fe0d

Please sign in to comment.