@@ -457,15 +457,19 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
457457
458458 // check instances status
459459 tmpInstanceSet := result .Response .InstanceSet
460- if tmpInstanceSet == nil || len ( tmpInstanceSet ) == 0 {
460+ if tmpInstanceSet == nil {
461461 return resource .NonRetryableError (fmt .Errorf ("there is no instances in set" ))
462462 } else {
463- var stop int
463+ var (
464+ stop int
465+ flag bool
466+ )
464467 for _ , v := range instanceIds {
465468 for _ , instance := range tmpInstanceSet {
466469 if v == * instance .InstanceId {
467470 if * instance .InstanceState == "running" {
468471 stop += 1
472+ flag = true
469473 } else if * instance .InstanceState == "failed" {
470474 stop += 1
471475 log .Printf ("instance:%s status is failed." , v )
@@ -476,17 +480,20 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
476480 }
477481 }
478482
479- if stop == len (instanceIds ) {
483+ if stop == len (instanceIds ) && flag {
480484 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 )
481490 }
482491 }
483-
484- e = fmt .Errorf ("cluster instances is still initializing." )
485- return tccommon .RetryError (e )
486492 })
487493
488494 if err != nil {
489495 log .Printf ("[CRITAL] kubernetes scale worker instances status error, reason:%+v" , err )
496+ return err
490497 }
491498
492499 return nil
0 commit comments