github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/process/update/sc_migration_check_step.go (about) 1 package update 2 3 import ( 4 "fmt" 5 "time" 6 7 reconcilerApi "github.com/kyma-incubator/reconciler/pkg/keb" 8 "github.com/kyma-project/kyma-environment-broker/internal" 9 kebError "github.com/kyma-project/kyma-environment-broker/internal/error" 10 "github.com/kyma-project/kyma-environment-broker/internal/process" 11 "github.com/kyma-project/kyma-environment-broker/internal/reconciler" 12 "github.com/kyma-project/kyma-environment-broker/internal/storage" 13 "github.com/sirupsen/logrus" 14 ) 15 16 type CheckReconcilerState struct { 17 operationManager *process.OperationManager 18 reconcilerClient reconciler.Client 19 } 20 21 func NewCheckReconcilerState(os storage.Operations, reconcilerClient reconciler.Client) *CheckReconcilerState { 22 return &CheckReconcilerState{ 23 operationManager: process.NewOperationManager(os), 24 reconcilerClient: reconcilerClient, 25 } 26 } 27 28 func (s *CheckReconcilerState) Name() string { 29 return "CheckReconcilerState" 30 } 31 32 func (s *CheckReconcilerState) Run(operation internal.Operation, log logrus.FieldLogger) (internal.Operation, time.Duration, error) { 33 state, err := s.reconcilerClient.GetCluster(operation.RuntimeID, operation.ClusterConfigurationVersion) 34 35 if kebError.IsTemporaryError(err) { 36 log.Errorf("Reconciler GetCluster method failed (temporary error, retrying): %v", err) 37 return operation, 1 * time.Minute, nil 38 } else if err != nil { 39 return s.operationManager.OperationFailed(operation, "failed to get cluster status", err, log) 40 } 41 switch state.Status { 42 case reconcilerApi.StatusReconciling, reconcilerApi.StatusReconcilePending: 43 log.Infof("Reconciler status %v", state.Status) 44 return operation, 30 * time.Second, nil 45 case reconcilerApi.StatusReconcileErrorRetryable: 46 log.Infof("Reconciler failed with retryable, rechecking in 10 minutes.") 47 return operation, 10 * time.Minute, nil 48 case reconcilerApi.StatusReady: 49 return operation, 0, nil 50 case reconcilerApi.StatusError: 51 msg := fmt.Sprintf("Reconciler failed %v: %v", state.Status, reconciler.PrettyFailures(state)) 52 return s.operationManager.OperationFailed(operation, msg, nil, log) 53 default: 54 msg := fmt.Sprintf("Unknown reconciler cluster state %v, error: %v", state.Status, reconciler.PrettyFailures(state)) 55 return s.operationManager.OperationFailed(operation, msg, nil, log) 56 } 57 }