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 when deleting bigquery_dataset_access and modifying bigquery_dataset in same apply #13779

Open
roaks3 opened this issue Feb 17, 2023 · 0 comments

Comments

@roaks3
Copy link
Collaborator

roaks3 commented Feb 17, 2023

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 the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Affected Resource(s)

  • google_bigquery_dataset
  • google_bigquery_dataset_access

Terraform Configuration Files

Step 1:

resource "google_bigquery_dataset" "public" {
  dataset_id  = "%{public_dataset}"
  description = "This dataset is public"
}

resource "google_bigquery_routine" "public" {
  dataset_id      = google_bigquery_dataset.public.dataset_id
  routine_id      = "%{public_routine}"
  routine_type    = "TABLE_VALUED_FUNCTION"
  language        = "SQL"
  definition_body = <<-EOS
    SELECT 1 + value AS value
  EOS
  arguments {
    name          = "value"
    argument_kind = "FIXED_TYPE"
    data_type     = jsonencode({ "typeKind" = "INT64" })
  }
  return_table_type = jsonencode({ "columns" = [
    { "name" = "value", "type" = { "typeKind" = "INT64" } },
  ] })
}

resource "google_bigquery_dataset" "private" {
  dataset_id  = "%{private_dataset}"
  description = "This dataset is private"
}

resource "google_bigquery_dataset_access" "authorized_routine" {
  dataset_id = google_bigquery_dataset.private.dataset_id
  routine {
    project_id = google_bigquery_routine.public.project
    dataset_id = google_bigquery_routine.public.dataset_id
    routine_id = google_bigquery_routine.public.routine_id
  }
}

Step 2:

resource "google_bigquery_dataset" "private" {
  dataset_id  = "%{private_dataset}"
}

Debug Output

Error: Error updating Dataset "projects/ci-test-project-188019/datasets/tf_test_private_dataset_wrfzzyl3d7": googleapi: Error 400: Routine ci-test-project-188019:tf_test_public_dataset_dcbf92qyze.tf_test_public_routine_td7oeldldh to authorize not found., invalid

Panic Output

Expected Behavior

The Step 2 config should be applied as expected

Actual Behavior

The Step 2 config fails to update the private dataset with the error above. However, a subsequent apply does resolve the issue.

Steps to Reproduce

  1. terraform apply with Step 1 config
  2. terraform apply with Step 2 config

Important Factoids

This error came out of a test failure we saw #13023. Since this particular issue can be resolve with an additional apply, this specific problem seems less critical. However, there seems to be an underlying issue where the bigquery_dataset and bigquery_dataset_access cannot both be modified in the same apply, or they will compete for control over the access configuration. We are adding a note to the docs, but long-term if we see similar issues, we should fix this so that it doesn't error (possibly using a PATCH call instead of a PUT for bigquery_dataset updates).

References

b/299601059

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

No branches or pull requests

3 participants