Skip to content

fix(tke): [118133957] support retry #2735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2735.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_kubernetes_scale_worker: support retry
```
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,19 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)

// check instances status
tmpInstanceSet := result.Response.InstanceSet
if tmpInstanceSet == nil || len(tmpInstanceSet) == 0 {
if tmpInstanceSet == nil {
return resource.NonRetryableError(fmt.Errorf("there is no instances in set"))
} else {
var stop int
var (
stop int
flag bool
)
for _, v := range instanceIds {
for _, instance := range tmpInstanceSet {
if v == *instance.InstanceId {
if *instance.InstanceState == "running" {
stop += 1
flag = true
} else if *instance.InstanceState == "failed" {
stop += 1
log.Printf("instance:%s status is failed.", v)
Expand All @@ -476,17 +480,20 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
}
}

if stop == len(instanceIds) {
if stop == len(instanceIds) && flag {
return nil
} else if stop == len(instanceIds) && !flag {
return resource.NonRetryableError(fmt.Errorf("cluster all instances state is failed"))
} else {
e = fmt.Errorf("cluster instances is still initializing.")
return tccommon.RetryError(e)
}
}

e = fmt.Errorf("cluster instances is still initializing.")
return tccommon.RetryError(e)
})

if err != nil {
log.Printf("[CRITAL] kubernetes scale worker instances status error, reason:%+v", err)
return err
}

return nil
Expand Down
Loading