@@ -120,6 +120,10 @@ func (s *Service) reconcileCluster(ctx context.Context) error {
120120 return errors .Wrap (err , "failed reconciling cluster config" )
121121 }
122122
123+ if err := s .reconcileLogging (cluster .Logging ); err != nil {
124+ return errors .Wrap (err , "failed reconciling logging" )
125+ }
126+
123127 if err := s .reconcileEKSEncryptionConfig (cluster .EncryptionConfig ); err != nil {
124128 return errors .Wrap (err , "failed reconciling eks encryption config" )
125129 }
@@ -439,11 +443,6 @@ func (s *Service) reconcileClusterConfig(cluster *eks.Cluster) error {
439443 var needsUpdate bool
440444 input := eks.UpdateClusterConfigInput {Name : aws .String (s .scope .KubernetesClusterName ())}
441445
442- if updateLogging := s .reconcileLogging (cluster .Logging ); updateLogging != nil {
443- needsUpdate = true
444- input .Logging = updateLogging
445- }
446-
447446 updateVpcConfig , err := s .reconcileVpcConfig (cluster .ResourcesVpcConfig )
448447 if err != nil {
449448 return errors .Wrap (err , "couldn't create vpc config for cluster" )
@@ -475,15 +474,39 @@ func (s *Service) reconcileClusterConfig(cluster *eks.Cluster) error {
475474 return nil
476475}
477476
478- func (s * Service ) reconcileLogging (logging * eks.Logging ) * eks.Logging {
477+ func (s * Service ) reconcileLogging (logging * eks.Logging ) error {
478+ input := eks.UpdateClusterConfigInput {Name : aws .String (s .scope .KubernetesClusterName ())}
479+
479480 for _ , logSetup := range logging .ClusterLogging {
480481 for _ , l := range logSetup .Types {
481482 enabled := s .scope .ControlPlane .Spec .Logging .IsLogEnabled (* l )
482483 if enabled != * logSetup .Enabled {
483- return makeEksLogging (s .scope .ControlPlane .Spec .Logging )
484+ input .Logging = makeEksLogging (s .scope .ControlPlane .Spec .Logging )
485+ }
486+ }
487+ }
488+
489+ if input .Logging != nil {
490+ if err := input .Validate (); err != nil {
491+ return errors .Wrap (err , "created invalid UpdateClusterConfigInput" )
492+ }
493+
494+ if err := wait .WaitForWithRetryable (wait .NewBackoff (), func () (bool , error ) {
495+ if _ , err := s .EKSClient .UpdateClusterConfig (& input ); err != nil {
496+ if aerr , ok := err .(awserr.Error ); ok {
497+ return false , aerr
498+ }
499+ return false , err
484500 }
501+ conditions .MarkTrue (s .scope .ControlPlane , ekscontrolplanev1 .EKSControlPlaneUpdatingCondition )
502+ record .Eventf (s .scope .ControlPlane , "InitiatedUpdateEKSControlPlane" , "Initiated logging update for EKS control plane %s" , s .scope .KubernetesClusterName ())
503+ return true , nil
504+ }); err != nil {
505+ record .Warnf (s .scope .ControlPlane , "FailedUpdateEKSControlPlane" , "Failed to update EKS control plane logging: %v" , err )
506+ return errors .Wrapf (err , "failed to update EKS cluster" )
485507 }
486508 }
509+
487510 return nil
488511}
489512
0 commit comments