@@ -121,6 +121,10 @@ func (s *Service) reconcileCluster(ctx context.Context) error {
121
121
return errors .Wrap (err , "failed reconciling cluster config" )
122
122
}
123
123
124
+ if err := s .reconcileLogging (cluster .Logging ); err != nil {
125
+ return errors .Wrap (err , "failed reconciling logging" )
126
+ }
127
+
124
128
if err := s .reconcileEKSEncryptionConfig (cluster .EncryptionConfig ); err != nil {
125
129
return errors .Wrap (err , "failed reconciling eks encryption config" )
126
130
}
@@ -230,7 +234,7 @@ func makeEksEncryptionConfigs(encryptionConfig *ekscontrolplanev1.EncryptionConf
230
234
if encryptionConfig == nil {
231
235
return cfg
232
236
}
233
- //TODO: change EncryptionConfig so that provider and resources are required if encruptionConfig is specified
237
+ // TODO: change EncryptionConfig so that provider and resources are required if encruptionConfig is specified
234
238
if encryptionConfig .Provider == nil || len (* encryptionConfig .Provider ) == 0 {
235
239
return cfg
236
240
}
@@ -312,8 +316,8 @@ func makeEksLogging(loggingSpec *ekscontrolplanev1.ControlPlaneLoggingSpec) *eks
312
316
if loggingSpec == nil {
313
317
return nil
314
318
}
315
- var on = true
316
- var off = false
319
+ on : = true
320
+ off : = false
317
321
var enabledTypes []string
318
322
var disabledTypes []string
319
323
@@ -413,7 +417,7 @@ func (s *Service) createCluster(eksClusterName string) (*eks.Cluster, error) {
413
417
conditions .MarkTrue (s .scope .ControlPlane , ekscontrolplanev1 .EKSControlPlaneCreatingCondition )
414
418
record .Eventf (s .scope .ControlPlane , "InitiatedCreateEKSControlPlane" , "Initiated creation of a new EKS control plane %s" , s .scope .KubernetesClusterName ())
415
419
return true , nil
416
- }, awserrors .ResourceNotFound ); err != nil { //TODO: change the error that can be retried
420
+ }, awserrors .ResourceNotFound ); err != nil { // TODO: change the error that can be retried
417
421
record .Warnf (s .scope .ControlPlane , "FailedCreateEKSControlPlane" , "Failed to initiate creation of a new EKS control plane: %v" , err )
418
422
return nil , errors .Wrapf (err , "failed to create EKS cluster" )
419
423
}
@@ -449,11 +453,6 @@ func (s *Service) reconcileClusterConfig(cluster *eks.Cluster) error {
449
453
var needsUpdate bool
450
454
input := eks.UpdateClusterConfigInput {Name : aws .String (s .scope .KubernetesClusterName ())}
451
455
452
- if updateLogging := s .reconcileLogging (cluster .Logging ); updateLogging != nil {
453
- needsUpdate = true
454
- input .Logging = updateLogging
455
- }
456
-
457
456
updateVpcConfig , err := s .reconcileVpcConfig (cluster .ResourcesVpcConfig )
458
457
if err != nil {
459
458
return errors .Wrap (err , "couldn't create vpc config for cluster" )
@@ -485,15 +484,39 @@ func (s *Service) reconcileClusterConfig(cluster *eks.Cluster) error {
485
484
return nil
486
485
}
487
486
488
- func (s * Service ) reconcileLogging (logging * eks.Logging ) * eks.Logging {
487
+ func (s * Service ) reconcileLogging (logging * eks.Logging ) error {
488
+ input := eks.UpdateClusterConfigInput {Name : aws .String (s .scope .KubernetesClusterName ())}
489
+
489
490
for _ , logSetup := range logging .ClusterLogging {
490
491
for _ , l := range logSetup .Types {
491
492
enabled := s .scope .ControlPlane .Spec .Logging .IsLogEnabled (* l )
492
493
if enabled != * logSetup .Enabled {
493
- return makeEksLogging (s .scope .ControlPlane .Spec .Logging )
494
+ input .Logging = makeEksLogging (s .scope .ControlPlane .Spec .Logging )
495
+ }
496
+ }
497
+ }
498
+
499
+ if input .Logging != nil {
500
+ if err := input .Validate (); err != nil {
501
+ return errors .Wrap (err , "created invalid UpdateClusterConfigInput" )
502
+ }
503
+
504
+ if err := wait .WaitForWithRetryable (wait .NewBackoff (), func () (bool , error ) {
505
+ if _ , err := s .EKSClient .UpdateClusterConfig (& input ); err != nil {
506
+ if aerr , ok := err .(awserr.Error ); ok {
507
+ return false , aerr
508
+ }
509
+ return false , err
494
510
}
511
+ conditions .MarkTrue (s .scope .ControlPlane , ekscontrolplanev1 .EKSControlPlaneUpdatingCondition )
512
+ record .Eventf (s .scope .ControlPlane , "InitiatedUpdateEKSControlPlane" , "Initiated logging update for EKS control plane %s" , s .scope .KubernetesClusterName ())
513
+ return true , nil
514
+ }); err != nil {
515
+ record .Warnf (s .scope .ControlPlane , "FailedUpdateEKSControlPlane" , "Failed to update EKS control plane logging: %v" , err )
516
+ return errors .Wrapf (err , "failed to update EKS cluster" )
495
517
}
496
518
}
519
+
497
520
return nil
498
521
}
499
522
0 commit comments