@@ -476,7 +476,7 @@ func resourceTencentCloudKubernetesClusterCreatePostHandleResponse0(ctx context.
476476 }
477477 }
478478
479- //Modify node pool global config
479+ //Modify node pool global config(sync)
480480 if _ , ok := d .GetOk ("node_pool_global_config" ); ok {
481481 request := tkeGetNodePoolGlobalConfig (d )
482482 request .ClusterId = & id
@@ -492,20 +492,45 @@ func resourceTencentCloudKubernetesClusterCreatePostHandleResponse0(ctx context.
492492 }
493493 }
494494
495+ // sync
495496 if v , ok := d .GetOk ("acquire_cluster_admin_role" ); ok && v .(bool ) {
496497 err := service .AcquireClusterAdminRole (ctx , id )
497498 if err != nil {
498499 return err
499500 }
500501 }
501502
503+ // async
502504 if _ , ok := d .GetOk ("auth_options" ); ok {
503505 request := tkeGetAuthOptions (d , id )
504506 if err := service .ModifyClusterAuthenticationOptions (ctx , request ); err != nil {
505507 return err
506508 }
509+
510+ // wait
511+ err = resource .Retry (3 * tccommon .ReadRetryTimeout , func () * resource.RetryError {
512+ resp , inErr := service .DescribeKubernetesAuthAttachmentById (ctx , id )
513+ if inErr != nil {
514+ return tccommon .RetryError (inErr )
515+ }
516+
517+ if resp == nil {
518+ return resource .NonRetryableError (fmt .Errorf ("Describe cluster aauthentication options failed, Response is nil." ))
519+ }
520+
521+ if resp .LatestOperationState != nil || * resp .LatestOperationState == "Success" {
522+ return nil
523+ }
524+
525+ return resource .RetryableError (fmt .Errorf ("Modify auth options running..." ))
526+ })
527+
528+ if err != nil {
529+ return err
530+ }
507531 }
508532
533+ // async
509534 if v , ok := helper .InterfacesHeadMap (d , "log_agent" ); ok {
510535 enabled := v ["enabled" ].(bool )
511536 rootDir := v ["kubelet_root_dir" ].(string )
@@ -515,9 +540,33 @@ func resourceTencentCloudKubernetesClusterCreatePostHandleResponse0(ctx context.
515540 if err != nil {
516541 return err
517542 }
543+
544+ // wait
545+ err = resource .Retry (3 * tccommon .ReadRetryTimeout , func () * resource.RetryError {
546+ resp , inErr := service .DescribeLogSwitches (ctx , id )
547+ if inErr != nil {
548+ return tccommon .RetryError (inErr )
549+ }
550+
551+ if resp == nil || len (resp ) < 1 {
552+ return resource .NonRetryableError (fmt .Errorf ("Describe log switches failed, Response is nil." ))
553+ }
554+
555+ ret := resp [0 ]
556+ if ret .Log != nil && ret .Log .Status != nil && * ret .Log .Status == "opened" {
557+ return nil
558+ }
559+
560+ return resource .RetryableError (fmt .Errorf ("Modify log agent running..." ))
561+ })
562+
563+ if err != nil {
564+ return err
565+ }
518566 }
519567 }
520568
569+ // async
521570 if v , ok := helper .InterfacesHeadMap (d , "event_persistence" ); ok {
522571 enabled := v ["enabled" ].(bool )
523572 logSetId := v ["log_set_id" ].(string )
@@ -527,6 +576,29 @@ func resourceTencentCloudKubernetesClusterCreatePostHandleResponse0(ctx context.
527576 if err != nil {
528577 return err
529578 }
579+
580+ // wait
581+ err = resource .Retry (3 * tccommon .ReadRetryTimeout , func () * resource.RetryError {
582+ resp , inErr := service .DescribeLogSwitches (ctx , id )
583+ if inErr != nil {
584+ return tccommon .RetryError (inErr )
585+ }
586+
587+ if resp == nil || len (resp ) < 1 {
588+ return resource .NonRetryableError (fmt .Errorf ("Describe event persistence failed, Response is nil." ))
589+ }
590+
591+ ret := resp [0 ]
592+ if ret .Event != nil && ret .Event .Status != nil && * ret .Event .Status == "opened" {
593+ return nil
594+ }
595+
596+ return resource .RetryableError (fmt .Errorf ("Modify event persistence running..." ))
597+ })
598+
599+ if err != nil {
600+ return err
601+ }
530602 }
531603 }
532604
@@ -539,6 +611,29 @@ func resourceTencentCloudKubernetesClusterCreatePostHandleResponse0(ctx context.
539611 if err != nil {
540612 return err
541613 }
614+
615+ // wait
616+ err = resource .Retry (3 * tccommon .ReadRetryTimeout , func () * resource.RetryError {
617+ resp , inErr := service .DescribeLogSwitches (ctx , id )
618+ if inErr != nil {
619+ return tccommon .RetryError (inErr )
620+ }
621+
622+ if resp == nil || len (resp ) < 1 {
623+ return resource .NonRetryableError (fmt .Errorf ("Describe cluster audit failed, Response is nil." ))
624+ }
625+
626+ ret := resp [0 ]
627+ if ret .Audit != nil && ret .Audit .Status != nil && * ret .Audit .Status == "opened" {
628+ return nil
629+ }
630+
631+ return resource .RetryableError (fmt .Errorf ("Modify cluster audit running..." ))
632+ })
633+
634+ if err != nil {
635+ return err
636+ }
542637 }
543638 }
544639 return nil
0 commit comments