jenkinsci / google-compute-engine-plugin

https://plugins.jenkins.io/google-compute-engine/
Apache License 2.0
57 stars 88 forks source link

Create snapshot defaulting to multi-region #393

Open bgp-sz opened 1 year ago

bgp-sz commented 1 year ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.387.2 OS: Linux - 5.14.0-162.18.1.el9_1.cloud.x86_64 Java: 11.0.19 - Red Hat, Inc. (OpenJDK 64-Bit Server VM) ... google-compute-engine:4.3.14 google-metadata-plugin:0.4 google-oauth-plugin:1.0.8 google-storage-plugin:1.5.8 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Linux jenkins 5.14.0-162.18.1.el9_1.cloud.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Mar 1 19:45:58 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Reproduction steps

Configure google-cloud vm with

  1. One-Shot enabled
  2. Create snapshot enabled
  3. Location "europe-west3"
  4. Zone "europe-west3-a"

Corresponding google project configured with "constraints/gcp.resourceLocations" set to europe-west3-b europe-west3-a europe-west3 europe-west3-locations europe-west3-c

Run a failing jenkins job e.g. "Simple Shell" with just "exit 1"

Expected Results

Snapshot being created in the same region as the VM was running.

Actual Results

Snapshot creation fails due to multi-region "EU" being used.

2023-05-16 12:10:19.214+0000 [id=11927] INFO    c.g.j.p.c.ComputeEngineInstance#_terminate: Creating snapshot for node ... docker-test-4xdjzm
2023-05-16 12:10:19.403+0000 [id=11927] WARNING c.g.c.g.p.p.client.ComputeClient#lambda$createSnapshotSync$10: Error in creati
ng snapshot.
com.google.api.client.googleapis.json.GoogleJsonResponseException: 412 Precondition Failed
POST https://compute.googleapis.com/compute/v1/projects/..../createSnapshot
{
  "code" : 412,
  "errors" : [ {
    "domain" : "global",
    "location" : "If-Match",
    "locationType" : "header",
    "message" : "Location EU violates constraint constraints/gcp.resourceLocations on the resource projects/.....",
    "reason" : "conditionNotMet"
  } ],
  "message" : "Location EU violates constraint constraints/gcp.resourceLocations on the resource projects/....."
}

Anything else?

No response