@@ -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
@@ -421,7 +425,7 @@ func (s *Service) createCluster(eksClusterName string) (*eks.Cluster, error) {
421
425
conditions .MarkTrue (s .scope .ControlPlane , ekscontrolplanev1 .EKSControlPlaneCreatingCondition )
422
426
record .Eventf (s .scope .ControlPlane , "InitiatedCreateEKSControlPlane" , "Initiated creation of a new EKS control plane %s" , s .scope .KubernetesClusterName ())
423
427
return true , nil
424
- }, awserrors .ResourceNotFound ); err != nil { //TODO: change the error that can be retried
428
+ }, awserrors .ResourceNotFound ); err != nil { // TODO: change the error that can be retried
425
429
record .Warnf (s .scope .ControlPlane , "FailedCreateEKSControlPlane" , "Failed to initiate creation of a new EKS control plane: %v" , err )
426
430
return nil , errors .Wrapf (err , "failed to create EKS cluster" )
427
431
}
@@ -457,11 +461,6 @@ func (s *Service) reconcileClusterConfig(cluster *eks.Cluster) error {
457
461
var needsUpdate bool
458
462
input := eks.UpdateClusterConfigInput {Name : aws .String (s .scope .KubernetesClusterName ())}
459
463
460
- if updateLogging := s .reconcileLogging (cluster .Logging ); updateLogging != nil {
461
- needsUpdate = true
462
- input .Logging = updateLogging
463
- }
464
-
465
464
updateVpcConfig , err := s .reconcileVpcConfig (cluster .ResourcesVpcConfig )
466
465
if err != nil {
467
466
return errors .Wrap (err , "couldn't create vpc config for cluster" )
@@ -493,15 +492,39 @@ func (s *Service) reconcileClusterConfig(cluster *eks.Cluster) error {
493
492
return nil
494
493
}
495
494
496
- func (s * Service ) reconcileLogging (logging * eks.Logging ) * eks.Logging {
495
+ func (s * Service ) reconcileLogging (logging * eks.Logging ) error {
496
+ input := eks.UpdateClusterConfigInput {Name : aws .String (s .scope .KubernetesClusterName ())}
497
+
497
498
for _ , logSetup := range logging .ClusterLogging {
498
499
for _ , l := range logSetup .Types {
499
500
enabled := s .scope .ControlPlane .Spec .Logging .IsLogEnabled (* l )
500
501
if enabled != * logSetup .Enabled {
501
- return makeEksLogging (s .scope .ControlPlane .Spec .Logging )
502
+ input .Logging = makeEksLogging (s .scope .ControlPlane .Spec .Logging )
503
+ }
504
+ }
505
+ }
506
+
507
+ if input .Logging != nil {
508
+ if err := input .Validate (); err != nil {
509
+ return errors .Wrap (err , "created invalid UpdateClusterConfigInput" )
510
+ }
511
+
512
+ if err := wait .WaitForWithRetryable (wait .NewBackoff (), func () (bool , error ) {
513
+ if _ , err := s .EKSClient .UpdateClusterConfig (& input ); err != nil {
514
+ if aerr , ok := err .(awserr.Error ); ok {
515
+ return false , aerr
516
+ }
517
+ return false , err
502
518
}
519
+ conditions .MarkTrue (s .scope .ControlPlane , ekscontrolplanev1 .EKSControlPlaneUpdatingCondition )
520
+ record .Eventf (s .scope .ControlPlane , "InitiatedUpdateEKSControlPlane" , "Initiated logging update for EKS control plane %s" , s .scope .KubernetesClusterName ())
521
+ return true , nil
522
+ }); err != nil {
523
+ record .Warnf (s .scope .ControlPlane , "FailedUpdateEKSControlPlane" , "Failed to update EKS control plane logging: %v" , err )
524
+ return errors .Wrapf (err , "failed to update EKS cluster" )
503
525
}
504
526
}
527
+
505
528
return nil
506
529
}
507
530
0 commit comments