@@ -457,15 +457,19 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
457
457
458
458
// check instances status
459
459
tmpInstanceSet := result .Response .InstanceSet
460
- if tmpInstanceSet == nil || len ( tmpInstanceSet ) == 0 {
460
+ if tmpInstanceSet == nil {
461
461
return resource .NonRetryableError (fmt .Errorf ("there is no instances in set" ))
462
462
} else {
463
- var stop int
463
+ var (
464
+ stop int
465
+ flag bool
466
+ )
464
467
for _ , v := range instanceIds {
465
468
for _ , instance := range tmpInstanceSet {
466
469
if v == * instance .InstanceId {
467
470
if * instance .InstanceState == "running" {
468
471
stop += 1
472
+ flag = true
469
473
} else if * instance .InstanceState == "failed" {
470
474
stop += 1
471
475
log .Printf ("instance:%s status is failed." , v )
@@ -476,17 +480,20 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
476
480
}
477
481
}
478
482
479
- if stop == len (instanceIds ) {
483
+ if stop == len (instanceIds ) && flag {
480
484
return nil
485
+ } else if stop == len (instanceIds ) && ! flag {
486
+ return resource .NonRetryableError (fmt .Errorf ("cluster all instances state is failed" ))
487
+ } else {
488
+ e = fmt .Errorf ("cluster instances is still initializing." )
489
+ return tccommon .RetryError (e )
481
490
}
482
491
}
483
-
484
- e = fmt .Errorf ("cluster instances is still initializing." )
485
- return tccommon .RetryError (e )
486
492
})
487
493
488
494
if err != nil {
489
495
log .Printf ("[CRITAL] kubernetes scale worker instances status error, reason:%+v" , err )
496
+ return err
490
497
}
491
498
492
499
return nil
0 commit comments