@@ -17,10 +17,11 @@ package cloud
1717import (
1818 "context"
1919 "fmt"
20+ "github.com/hashicorp/terraform-plugin-log/tflog"
21+ "k8s.io/apimachinery/pkg/api/errors"
2022 "strings"
2123 "time"
2224
23- "github.com/hashicorp/terraform-plugin-log/tflog"
2425 apierrors "k8s.io/apimachinery/pkg/api/errors"
2526
2627 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -463,7 +464,7 @@ func resourcePulsarClusterCreate(ctx context.Context, d *schema.ResourceData, me
463464 return resourcePulsarClusterRead (ctx , d , meta )
464465 }
465466 }
466- err = retry .RetryContext (ctx , 20 * time . Minute , func () * retry.RetryError {
467+ err = retry .RetryContext (ctx , d . Timeout ( schema . TimeoutCreate ) , func () * retry.RetryError {
467468 dia := resourcePulsarClusterRead (ctx , d , meta )
468469 if dia .HasError () {
469470 return retry .NonRetryableError (fmt .Errorf ("ERROR_RETRY_READ_PULSAR_CLUSTER: %s" , dia [0 ].Summary ))
@@ -683,7 +684,7 @@ func resourcePulsarClusterUpdate(ctx context.Context, d *schema.ResourceData, me
683684 }
684685 // Delay 10 seconds to wait for api server start reconcile.
685686 time .Sleep (10 * time .Second )
686- err = retry .RetryContext (ctx , 20 * time . Minute , func () * retry.RetryError {
687+ err = retry .RetryContext (ctx , d . Timeout ( schema . TimeoutUpdate ) , func () * retry.RetryError {
687688 dia := resourcePulsarClusterRead (ctx , d , meta )
688689 if dia .HasError () {
689690 return retry .NonRetryableError (fmt .Errorf ("ERROR_RETRY_READ_PULSAR_CLUSTER: %s" , dia [0 ].Summary ))
@@ -717,6 +718,23 @@ func resourcePulsarClusterDelete(ctx context.Context, d *schema.ResourceData, me
717718 if err != nil {
718719 return diag .FromErr (fmt .Errorf ("ERROR_DELETE_PULSAR_CLUSTER: %w" , err ))
719720 }
721+ err = retry .RetryContext (ctx , d .Timeout (schema .TimeoutDelete ), func () * retry.RetryError {
722+ _ , err = clientSet .CloudV1alpha1 ().PulsarClusters (namespace ).Get (ctx , name , metav1.GetOptions {})
723+ if err != nil {
724+ if statusErr , ok := err .(* errors.StatusError ); ok && errors .IsNotFound (statusErr ) {
725+ return nil
726+ }
727+ return retry .NonRetryableError (err )
728+ }
729+
730+ e := fmt .Errorf ("pulsarcluster (%s) still exists" , d .Id ())
731+ return retry .RetryableError (e )
732+ })
733+ if err != nil {
734+ return diag .FromErr (fmt .Errorf ("ERROR_RETRY_READ_PULSAR_CLUSTER: %w" , err ))
735+ }
736+
737+ d .SetId ("" )
720738 return nil
721739}
722740
0 commit comments