@@ -128,7 +128,7 @@ func (s *Service[C, D]) CreateOrUpdateResource(ctx context.Context, spec azure.R
128128 return result , nil
129129}
130130
131- // DeleteResource deletes a resource asynchronously with idempotent DELETE pattern .
131+ // DeleteResource deletes a resource asynchronously.
132132func (s * Service [C , D ]) DeleteResource (ctx context.Context , spec azure.ResourceSpecGetter , serviceName string ) (err error ) {
133133 ctx , log , done := tele .StartSpanWithLogger (ctx , "async.Service.DeleteResource" )
134134 defer done ()
@@ -148,7 +148,7 @@ func (s *Service[C, D]) DeleteResource(ctx context.Context, spec azure.ResourceS
148148 resumeToken = t
149149 }
150150
151- // Attempt to delete the resource.
151+ // Delete the resource.
152152 log .V (2 ).Info ("deleting resource" , "service" , serviceName , "resource" , resourceName , "resourceGroup" , rgName )
153153 poller , err := s .Deleter .DeleteAsync (ctx , spec , resumeToken )
154154 if poller != nil && azure .IsContextDeadlineExceededOrCanceledError (err ) {
@@ -160,10 +160,10 @@ func (s *Service[C, D]) DeleteResource(ctx context.Context, spec azure.ResourceS
160160 return azure .WithTransientError (azure .NewOperationNotDoneError (future ), requeueTime (s .Scope ))
161161 }
162162
163- // Once the operation is done, delete the long-running operation state.
163+ // Once the operation is done, delete the long-running operation state. Even if the operation ended with
164+ // an error, clear out any lingering state to try the operation again.
164165 s .Scope .DeleteLongRunningOperationState (resourceName , serviceName , futureType )
165166
166- // Handle DELETE result
167167 if err != nil && ! azure .ResourceNotFound (err ) {
168168 return errors .Wrapf (err , "failed to delete resource %s/%s (service: %s)" , rgName , resourceName , serviceName )
169169 }
0 commit comments