diff --git a/pkg/cloud/services/iamauth/reconcile.go b/pkg/cloud/services/iamauth/reconcile.go index f33fca1d5c..fe1806ca44 100644 --- a/pkg/cloud/services/iamauth/reconcile.go +++ b/pkg/cloud/services/iamauth/reconcile.go @@ -19,6 +19,7 @@ package iamauth import ( "context" "fmt" + "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/iam" @@ -124,7 +125,9 @@ func (s *Service) getRolesForMachineDeployments(ctx context.Context, allRoles ma } err := s.client.List(ctx, deploymentList, selectors...) if err != nil { - return fmt.Errorf("failed to list machine deployments for cluster %s/%s: %w", s.scope.Namespace(), s.scope.Name(), err) + if !containsTimeoutSyncError(err) { + return fmt.Errorf("failed to list machine deployments for cluster %s/%s: %w", s.scope.Namespace(), s.scope.Name(), err) + } } for _, deployment := range deploymentList.Items { @@ -208,3 +211,19 @@ func (s *Service) getRolesForAWSManagedMachinePool(ctx context.Context, ref core } return nil } + +// Check if a specific Timeout sync error message is in the error chain. +func containsTimeoutSyncError(err error) bool { + for { + if err == nil { + return false + } + // Check if the current error message contains the target message + if strings.Contains(err.Error(), "Timeout: failed waiting for *v1beta1.MachineDeployment Informer to sync") { + return true + } + + // Unwrap to check the next error in the chain + err = errors.Unwrap(err) + } +}