57
57
// Default waiting setup in seconds
58
58
defaultUpgradeStatusCheckInterval = 30
59
59
defaultUpgradeStatusCheckTimeout = 3600
60
- defaultUpgradeStatusCheckDelay = 300
61
- defaultUpgradeStatusCheckMaxRetries = 100
60
+ defaultUpgradeStatusCheckDelay = 30
61
+ defaultUpgradeStatusCheckMaxRetries = 150
62
62
)
63
63
64
64
var staticComponentUpgradeStatus = []string {
@@ -480,15 +480,11 @@ func prepareUpgrade(upgradeClientSet *upgradeClientSet, d *schema.ResourceData,
480
480
upgradeClientSet .PlanClient .Pause ()
481
481
}
482
482
//#nosec G601 Ignore implicit memory aliasing in for loop temporarily
483
- err = waitUpgradeForStatus (upgradeClientSet , & component , inFlightComponentUpgradeStatus , staticComponentUpgradeStatus )
483
+ curStatus , err : = waitUpgradeForStatus (upgradeClientSet , & component , inFlightComponentUpgradeStatus , staticComponentUpgradeStatus , false )
484
484
if err != nil {
485
485
return err
486
486
}
487
- status , err = getUpgradeStatus (upgradeClientSet .StatusClient , & component )
488
- if err != nil {
489
- return err
490
- }
491
- if status .Status == model .ComponentUpgradeStatus_STATUS_SUCCESS {
487
+ if curStatus == model .ComponentUpgradeStatus_STATUS_SUCCESS {
492
488
return fmt .Errorf ("unexpected status 'SUCCESS' for component '%s. Possibly there is a concurrent upgrade run'" , component )
493
489
}
494
490
@@ -574,7 +570,11 @@ func getUpgradeStatus(statusClient upgrade.StatusSummaryClient, component *strin
574
570
}
575
571
576
572
// Wait component upgrade status to become target status. Using nil component for overall upgrade status.
577
- func waitUpgradeForStatus (upgradeClientSet * upgradeClientSet , component * string , pending , target []string ) error {
573
+ func waitUpgradeForStatus (upgradeClientSet * upgradeClientSet , component * string , pending , target []string , doDelay bool ) (string , error ) {
574
+ delay := time .Duration (0 )
575
+ if doDelay {
576
+ delay = time .Duration (upgradeClientSet .Delay ) * time .Second
577
+ }
578
578
stateConf := & resource.StateChangeConf {
579
579
Pending : pending ,
580
580
Target : target ,
@@ -597,7 +597,7 @@ func waitUpgradeForStatus(upgradeClientSet *upgradeClientSet, component *string,
597
597
},
598
598
Timeout : time .Duration (upgradeClientSet .Timeout ) * time .Second ,
599
599
PollInterval : time .Duration (upgradeClientSet .Interval ) * time .Second ,
600
- Delay : time . Duration ( upgradeClientSet . Delay ) * time . Second ,
600
+ Delay : delay ,
601
601
NotFoundChecks : upgradeClientSet .MaxRetries ,
602
602
}
603
603
statusI , err := stateConf .WaitForState ()
@@ -608,9 +608,13 @@ func waitUpgradeForStatus(upgradeClientSet *upgradeClientSet, component *string,
608
608
status := statusI .(* upgradeStatusAndDetail )
609
609
statusDetail = fmt .Sprintf (" Current status: %s. Details: %s" , status .Status , status .Detail )
610
610
}
611
- return fmt .Errorf ("failed to wait Upgrade to be %s: %v. %s" , target , err , statusDetail )
611
+ return "" , fmt .Errorf ("failed to wait Upgrade to be %s: %v. %s" , target , err , statusDetail )
612
612
}
613
- return nil
613
+ status := ""
614
+ if statusI != nil {
615
+ status = statusI .(* upgradeStatusAndDetail ).Status
616
+ }
617
+ return status , nil
614
618
}
615
619
616
620
func updateUpgradeUnitGroups (upgradeClientSet * upgradeClientSet , d * schema.ResourceData , component string , preResetGroupList model.UpgradeUnitGroupListResult , hasVLCM * bool ) error {
@@ -825,10 +829,12 @@ func runUpgrade(upgradeClientSet *upgradeClientSet, partialUpgradeMap map[string
825
829
// there is a period that overall status is still IN_PROGRESS, which will prevent us to start the upgrade of next component.
826
830
// Wait here for the overall status become stable. Because there is potential upgrade triggered before, we wait here also
827
831
// for the first component for safety.
828
- err = waitUpgradeForStatus (upgradeClientSet , nil , inFlightComponentUpgradeStatus , staticComponentUpgradeStatus )
832
+ _ , err = waitUpgradeForStatus (upgradeClientSet , nil , inFlightComponentUpgradeStatus , staticComponentUpgradeStatus , false )
829
833
if err != nil {
830
834
return err
831
835
}
836
+
837
+ // Retrieve the component status - this is different from the general status which is fetched above
832
838
status , err = getUpgradeStatus (upgradeClientSet .StatusClient , & component )
833
839
if err != nil {
834
840
return err
@@ -880,10 +886,15 @@ func runUpgrade(upgradeClientSet *upgradeClientSet, partialUpgradeMap map[string
880
886
if err != nil {
881
887
return err
882
888
}
883
- err = waitUpgradeForStatus (upgradeClientSet , & component , pendingStatus , targetStatus )
889
+ curStatus , err : = waitUpgradeForStatus (upgradeClientSet , & component , pendingStatus , targetStatus , true )
884
890
if err != nil {
885
891
return err
886
892
}
893
+
894
+ if partialUpgradeMap [component ] && curStatus == model .ComponentUpgradeStatus_STATUS_SUCCESS {
895
+ log .Printf ("[INFO] Upgrade of component %s is complete, pausing" , component )
896
+ return nil
897
+ }
887
898
log .Print (completeLog )
888
899
}
889
900
return nil
0 commit comments