Skip to content

Commit

Permalink
wait for networks to delete when destroying networks
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwillis committed Nov 23, 2023
1 parent 1386d76 commit 0ea8740
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/provider/network_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func waitForNetworkStop(ctx context.Context, projectID string, networkID string,
}

if _, err := stateConf.WaitForState(ctx); err != nil {
return nil, fmt.Errorf("error waiting for network %s in project %s to be deleted: %w", networkID, projectID, err)
return nil, fmt.Errorf("error waiting for network %s in project %s to be stopped: %w", networkID, projectID, err)
}

return nil, nil
Expand All @@ -206,6 +206,10 @@ func waitForNetworkDelete(ctx context.Context, projectID string, networkID strin
tflog.Error(ctx, fmt.Sprintf("error getting network %s in project %s: %v", networkID, projectID, err))
return nil, "", err
}
if res.Payload.Network.ShortState == "" {
tflog.Debug(ctx, fmt.Sprintf("Network %s in project %s is stopped: ", networkID, projectID))
return res, "stop", nil
}

tflog.Trace(ctx, fmt.Sprintf("pending network %s in project %s state: %s", networkID, projectID, res.Payload.Network.ShortState))
return res, res.Payload.Network.ShortState, nil
Expand Down

0 comments on commit 0ea8740

Please sign in to comment.