fix(postgresflexalpha): add work around for FAILURE retry
This commit is contained in:
parent
3790894563
commit
f84399f5a3
1 changed files with 37 additions and 2 deletions
|
|
@ -59,6 +59,8 @@ func CreateInstanceWaitHandler(
|
||||||
maxWait := time.Minute * 45
|
maxWait := time.Minute * 45
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
extendedTimeout := 0
|
extendedTimeout := 0
|
||||||
|
maxFailedCount := 3
|
||||||
|
failedCount := 0
|
||||||
|
|
||||||
handler := wait.New(
|
handler := wait.New(
|
||||||
func() (waitFinished bool, response *v3alpha1api.GetInstanceResponse, err error) {
|
func() (waitFinished bool, response *v3alpha1api.GetInstanceResponse, err error) {
|
||||||
|
|
@ -132,8 +134,17 @@ func CreateInstanceWaitHandler(
|
||||||
instanceCreated = true
|
instanceCreated = true
|
||||||
instanceGetResponse = s
|
instanceGetResponse = s
|
||||||
case InstanceStateFailed:
|
case InstanceStateFailed:
|
||||||
tflog.Warn(ctx, fmt.Sprintf("Wait handler got status FAILURE for instance: %s", instanceId))
|
if failedCount < maxFailedCount {
|
||||||
return false, nil, nil
|
failedCount++
|
||||||
|
tflog.Warn(
|
||||||
|
ctx, "got failed status from API retry", map[string]interface{}{
|
||||||
|
"failedCount": failedCount,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
return false, nil, nil
|
||||||
|
}
|
||||||
|
return true, s, fmt.Errorf("update got status FAILURE for instance with id %s", instanceId)
|
||||||
// API responds with FAILURE for some seconds and then the instance goes to READY
|
// API responds with FAILURE for some seconds and then the instance goes to READY
|
||||||
// return true, s, fmt.Errorf("create failed for instance with id %s", instanceId)
|
// return true, s, fmt.Errorf("create failed for instance with id %s", instanceId)
|
||||||
}
|
}
|
||||||
|
|
@ -170,6 +181,8 @@ func PartialUpdateInstanceWaitHandler(
|
||||||
ctx context.Context, a APIClientInstanceInterface, projectID, region,
|
ctx context.Context, a APIClientInstanceInterface, projectID, region,
|
||||||
instanceID string,
|
instanceID string,
|
||||||
) *wait.AsyncActionHandler[v3alpha1api.GetInstanceResponse] {
|
) *wait.AsyncActionHandler[v3alpha1api.GetInstanceResponse] {
|
||||||
|
maxFailedCount := 3
|
||||||
|
failedCount := 0
|
||||||
handler := wait.New(
|
handler := wait.New(
|
||||||
func() (waitFinished bool, response *v3alpha1api.GetInstanceResponse, err error) {
|
func() (waitFinished bool, response *v3alpha1api.GetInstanceResponse, err error) {
|
||||||
s, err := a.GetInstanceRequest(ctx, projectID, region, instanceID).Execute()
|
s, err := a.GetInstanceRequest(ctx, projectID, region, instanceID).Execute()
|
||||||
|
|
@ -195,6 +208,16 @@ func PartialUpdateInstanceWaitHandler(
|
||||||
case InstanceStateUnknown:
|
case InstanceStateUnknown:
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
case InstanceStateFailed:
|
case InstanceStateFailed:
|
||||||
|
if failedCount < maxFailedCount {
|
||||||
|
failedCount++
|
||||||
|
tflog.Warn(
|
||||||
|
ctx, "got failed status from API retry", map[string]interface{}{
|
||||||
|
"failedCount": failedCount,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
return false, nil, nil
|
||||||
|
}
|
||||||
return true, s, fmt.Errorf("update got status FAILURE for instance with id %s", instanceID)
|
return true, s, fmt.Errorf("update got status FAILURE for instance with id %s", instanceID)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -295,6 +318,8 @@ func DeleteInstanceWaitHandler(
|
||||||
instanceID string,
|
instanceID string,
|
||||||
timeout, sleepBeforeWait time.Duration,
|
timeout, sleepBeforeWait time.Duration,
|
||||||
) error {
|
) error {
|
||||||
|
maxFailedCount := 3
|
||||||
|
failedCount := 0
|
||||||
handler := wait.New(
|
handler := wait.New(
|
||||||
func() (waitFinished bool, response *v3alpha1api.GetInstanceResponse, err error) {
|
func() (waitFinished bool, response *v3alpha1api.GetInstanceResponse, err error) {
|
||||||
s, err := a.GetInstanceRequest(ctx, projectID, region, instanceID).Execute()
|
s, err := a.GetInstanceRequest(ctx, projectID, region, instanceID).Execute()
|
||||||
|
|
@ -314,6 +339,16 @@ func DeleteInstanceWaitHandler(
|
||||||
case InstanceStateEmpty, InstanceStatePending, InstanceStateUnknown, InstanceStateProgressing, InstanceStateSuccess:
|
case InstanceStateEmpty, InstanceStatePending, InstanceStateUnknown, InstanceStateProgressing, InstanceStateSuccess:
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
case InstanceStateFailed:
|
case InstanceStateFailed:
|
||||||
|
if failedCount < maxFailedCount {
|
||||||
|
failedCount++
|
||||||
|
tflog.Warn(
|
||||||
|
ctx, "got failed status from API retry", map[string]interface{}{
|
||||||
|
"failedCount": failedCount,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
return false, nil, nil
|
||||||
|
}
|
||||||
return true, nil, fmt.Errorf("wait handler got status FAILURE for instance: %s", instanceID)
|
return true, nil, fmt.Errorf("wait handler got status FAILURE for instance: %s", instanceID)
|
||||||
default:
|
default:
|
||||||
return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceID, s.Status)
|
return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceID, s.Status)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue