Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error updating ResourcePolicy "projects/X/regions/us-central1/resourcePolicies/daily-backup-policy": googleapi: Error 400: Patching guest_flush field is not supported., badRequest #20499

Comments

@runa
Copy link

runa commented Nov 27, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version & Provider Version(s)

Terraform v1.9.5
on linux_amd64

  • provider registry.terraform.io/hashicorp/archive v2.6.0
  • provider registry.terraform.io/hashicorp/google v6.12.0
  • provider registry.terraform.io/hashicorp/google-beta v6.12.0

Affected Resource(s)

google_compute_resource_policy

Terraform Configuration

Before the change:

resource "google_compute_resource_policy" "backup_policy" {
  name    = "n8n-daily-backup-policy"
  region  = var.google_region
  project = var.google_project
  snapshot_schedule_policy {
    schedule {
      daily_schedule {

        days_in_cycle = 1
        start_time    = "05:00"
      }
    }
    retention_policy {
      max_retention_days    = 30
      on_source_disk_delete = "KEEP_AUTO_SNAPSHOTS"
    }
  }
}

after the change

resource "google_compute_resource_policy" "backup_policy" {
  name    = "n8n-daily-backup-policy"
  region  = var.google_region
  project = var.google_project
  snapshot_schedule_policy {
    schedule {
      daily_schedule {

        days_in_cycle = 1
        start_time    = "05:00"
      }
    }
    snapshot_properties {
      labels = {
        app_name = "n8n"
      }
    }
    retention_policy {
      max_retention_days    = 30
      on_source_disk_delete = "KEEP_AUTO_SNAPSHOTS"
    }
  }
}

Debug Output

Encrypted with your PK and uploaded here: https://drive.google.com/file/d/1o2_aJuZ5m29FU3cgmljH-9zVvxE6QkoS/view?usp=sharing

Expected Behavior

I wanted to add a label to a snapshot

Actual Behavior

it failed:

module.n8n.google_compute_resource_policy.backup_policy: Modifying... [id=projects/retco9/regions/us-central1/resourcePolicies/n8n-daily-backup-policy]
╷
│ Error: Error updating ResourcePolicy "projects/retco9/regions/us-central1/resourcePolicies/n8n-daily-backup-policy": googleapi: Error 400: Patching guest_flush field is not supported., badRequest
│ 
│   with module.n8n.google_compute_resource_policy.backup_policy,
│   on modules/n8n/main.tf line 93, in resource "google_compute_resource_policy" "backup_policy":
│   93: resource "google_compute_resource_policy" "backup_policy" {
│ 

Steps to reproduce

  1. terraform apply

Important Factoids

No response

References

No response

b/381430194

@runa runa added the bug label Nov 27, 2024
@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-instances labels Nov 27, 2024
@ggtisc ggtisc self-assigned this Nov 28, 2024
@ggtisc
Copy link
Collaborator

ggtisc commented Nov 28, 2024

Confirmed issue!

But I can't determine if this is an enhancement or a bug, because in terraform registry there isn't any advice explaining that it is not possible to update the argument guest_flush which is auto managed, since the user is not setting any value for the guest_flush argument of the snapshot_properties block code, but in the other hand in the API documentation the guestFlush field is not listed in the available Patch methods.

I'm forwarding this issue for a deep review

@ggtisc ggtisc removed the forward/review In review; remove label to forward label Nov 28, 2024
@ggtisc ggtisc removed their assignment Nov 28, 2024
@karolgorc
Copy link

karolgorc commented Dec 6, 2024

The guest_flush value gets defaulted to null when the snapshot_properties block is created and then null is treated as false. The provider then takes every field in the block and sends it to the API (guest_flush included). This is seen as an attempt to patch even tough it wasn't set previously.

Basically there is no nullFields logic in place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment