Skip to content

Commit 0b3fa84

Browse files
committed
rebase main
1 parent d9d523c commit 0b3fa84

File tree

5 files changed

+151
-72
lines changed

5 files changed

+151
-72
lines changed

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanetemplates.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ spec:
5353
description: AWSManagedControlPlaneSpec defines the desired state
5454
of an Amazon EKS Cluster.
5555
properties:
56+
accessConfig:
57+
description: AccessConfig specifies the access configuration
58+
information for the cluster
59+
properties:
60+
authenticationMode:
61+
default: CONFIG_MAP
62+
description: |-
63+
AuthenticationMode specifies the desired authentication mode for the cluster
64+
Defaults to CONFIG_MAP
65+
enum:
66+
- CONFIG_MAP
67+
- API
68+
- API_AND_CONFIG_MAP
69+
type: string
70+
type: object
5671
additionalTags:
5772
additionalProperties:
5873
type: string

controlplane/eks/api/v1beta1/zz_generated.conversion.go

Lines changed: 26 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/eks/api/v1beta2/zz_generated.deepcopy.go

Lines changed: 95 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cloud/services/eks/cluster.go

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (s *Service) reconcileCluster(ctx context.Context) error {
121121
return errors.Wrap(err, "failed reconciling cluster config")
122122
}
123123

124-
if err := s.reconcileAccessConfig(cluster.AccessConfig); err != nil {
124+
if err := s.reconcileAccessConfig(ctx, cluster.AccessConfig); err != nil {
125125
return errors.Wrap(err, "failed reconciling access config")
126126
}
127127

@@ -429,7 +429,7 @@ func (s *Service) createCluster(ctx context.Context, eksClusterName string) (*ek
429429
var accessConfig *ekstypes.CreateAccessConfigRequest
430430
if s.scope.ControlPlane.Spec.AccessConfig != nil && s.scope.ControlPlane.Spec.AccessConfig.AuthenticationMode != "" {
431431
accessConfig = &ekstypes.CreateAccessConfigRequest{
432-
AuthenticationMode: string(s.scope.ControlPlane.Spec.AccessConfig.AuthenticationMode),
432+
AuthenticationMode: ekstypes.AuthenticationMode(string(s.scope.ControlPlane.Spec.AccessConfig.AuthenticationMode)),
433433
}
434434
}
435435

@@ -485,10 +485,6 @@ func (s *Service) createCluster(ctx context.Context, eksClusterName string) (*ek
485485
BootstrapSelfManagedAddons: bootstrapAddon,
486486
}
487487

488-
if err := input.Validate(); err != nil {
489-
return nil, errors.Wrap(err, "created invalid CreateClusterInput")
490-
}
491-
492488
var out *eks.CreateClusterOutput
493489
if err := wait.WaitForWithRetryable(wait.NewBackoff(), func() (bool, error) {
494490
if out, err = s.EKSClient.CreateCluster(ctx, input); err != nil {
@@ -558,40 +554,34 @@ func (s *Service) reconcileClusterConfig(ctx context.Context, cluster *ekstypes.
558554
return nil
559555
}
560556

561-
func (s *Service) reconcileAccessConfig(accessConfig *ekstypes.AccessConfigResponse) error {
557+
func (s *Service) reconcileAccessConfig(ctx context.Context, accessConfig *ekstypes.AccessConfigResponse) error {
562558
input := &eks.UpdateClusterConfigInput{Name: aws.String(s.scope.KubernetesClusterName())}
563559

564560
if s.scope.ControlPlane.Spec.AccessConfig == nil || s.scope.ControlPlane.Spec.AccessConfig.AuthenticationMode == "" {
565561
return nil
566562
}
567563

568-
expectedAuthenticationMode := string(s.scope.ControlPlane.Spec.AccessConfig.AuthenticationMode)
564+
expectedAuthenticationMode := ekstypes.AuthenticationMode(string(s.scope.ControlPlane.Spec.AccessConfig.AuthenticationMode))
569565
s.scope.Debug("Reconciling EKS Access Config for cluster", "cluster-name", s.scope.KubernetesClusterName(), "expected", expectedAuthenticationMode, "current", accessConfig.AuthenticationMode)
570566
if expectedAuthenticationMode != accessConfig.AuthenticationMode {
571-
input.AccessConfig = &eks.UpdateAccessConfigRequest{
572-
AuthenticationMode: aws.String(expectedAuthenticationMode),
567+
input.AccessConfig = &ekstypes.UpdateAccessConfigRequest{
568+
AuthenticationMode: expectedAuthenticationMode,
573569
}
574570
}
575571

576572
if input.AccessConfig != nil {
577-
if err := input.Validate(); err != nil {
578-
return errors.Wrap(err, "created invalid UpdateClusterConfigInput")
579-
}
580-
581573
if err := wait.WaitForWithRetryable(wait.NewBackoff(), func() (bool, error) {
582-
if _, err := s.EKSClient.UpdateClusterConfig(input); err != nil {
583-
if aerr, ok := err.(awserr.Error); ok {
584-
return false, aerr
585-
}
574+
if _, err := s.EKSClient.UpdateClusterConfig(ctx, input); err != nil {
586575
return false, err
587576
}
588577

589578
// Wait until status transitions to UPDATING because there's a short
590579
// window after UpdateClusterConfig returns where the cluster
591580
// status is ACTIVE and the update would be tried again
592581
if err := s.EKSClient.WaitUntilClusterUpdating(
582+
ctx,
593583
&eks.DescribeClusterInput{Name: aws.String(s.scope.KubernetesClusterName())},
594-
request.WithWaiterLogger(&awslog{s.GetLogger()}),
584+
s.scope.MaxWaitActiveUpdateDelete,
595585
); err != nil {
596586
return false, err
597587
}

0 commit comments

Comments
 (0)