GoogleCloudPlatform / scientific-computing-examples

Open Source examples using Google Cloud to solve various Scientific and Technical Computing problems.
Apache License 2.0
17 stars 11 forks source link

[flux] Error if policy exists #53

Open vsoch opened 1 year ago

vsoch commented 1 year ago

In the case that a user runs a particular config twice, I've hit this bug (twice now) that it tells me the collocation policy (I think this is for compact) already exists:

╷
│ Error: Error creating ResourcePolicy: googleapi: Error 409: The resource 'projects/llnl-flux/regions/us-central1/resourcePolicies/gffw-compute-a-collocated-policy' already exists, alreadyExists
│ 
│   with module.cluster.module.compute_nodes["gffw-compute-a"].google_compute_resource_policy.collocated[0],
│   on .terraform/modules/cluster/fluxfw-gcp/tf/modules/compute/main.tf line 45, in resource "google_compute_resource_policy" "collocated":
│   45: resource "google_compute_resource_policy" "collocated" {
│ 
╵

I'm not sure if there is a way to say "get or create" but I think we need that here! I did find where they live in the GCP console, but as far as I can tell, there is no DELETE button (and likely it needs to be done with an API). I think the terraform recipe in theory should clean everything up, but if there was ever a blurp it could be left not cleaned up, and then the user gets this bug.

To get around it I'm going to just rename the prefix and get a different policy name, although for the future it would be good to not have to do that! I can imagine my GCP policy page is going to fill up fast :laughing: