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

google_cloud_run_v2_service : container-dependencies incorrect when container name is omitted #21035

Open
romaninsh opened this issue Jan 24, 2025 · 1 comment
Assignees
Labels

Comments

@romaninsh
Copy link

romaninsh commented Jan 24, 2025

With the following setup:

resource "google_cloud_run_v2_service" "app" {
  name     = "frontend"
  location = "europe-west1"

  template {
    containers {
      image = var.image
      #name="main"
      depends_on = ["redis"]
    }
    containers {
        name  = "redis"
        image = "redis:latest"
    }
  }
}

The name on the main container is commented out. GCP assigns it name "frontend-1" automatically. The problem is with the dependency.

gcloud run services describe frontend

Would output the following annotation:

  "spec": {
    "template": {
      "metadata": {
        "annotations": {
          "run.googleapis.com/container-dependencies": "{\"\":[\"redis\"]}",
...

GCP considers name "" above invalid if updated.

ERROR: (gcloud.run.services.update) spec.template.metadata.annotations[run.googleapis.com/container-dependencies]: Invalid container name ''. Must conform to RFC 1123: only lowercase letters, digits, hyphens, and periods are allowed, must begin and end with a letter or digit, and be less than 64 characters

When set manually through UI, the container-dependencies are:

          "run.googleapis.com/container-dependencies": "{\"frontend-1\":[\"redis\"]}",

Terraform Version & Provider Version(s)

Terraform v1.10.3
on darwin_arm64

  • provider registry.terraform.io/hashicorp/google v6.15.0

Affected Resource(s)

google_cloud_run_v2_service

Terraform Configuration

Debug Output

No response

Expected Behavior

          "run.googleapis.com/container-dependencies": "{\"frontend-1\":[\"redis\"]}",

Actual Behavior

          "run.googleapis.com/container-dependencies": "{\"\":[\"redis\"]}",

Steps to reproduce

  1. terraform apply

Important Factoids

No response

References

No response

@romaninsh romaninsh added the bug label Jan 24, 2025
@github-actions github-actions bot added forward/review In review; remove label to forward service/run labels Jan 24, 2025
@ggtisc ggtisc self-assigned this Jan 24, 2025
@ggtisc
Copy link
Collaborator

ggtisc commented Jan 24, 2025

Hi @romaninsh

Since we don't have access to your own redis code and configuration we can't go beyond, but I tried to replicate this issue with a public redis image with the following code and don't have any errors:

resource "google_cloud_run_v2_service" "clourdrun_service_v2_21035" {
  name                = "clourdrun-service-v2-21035"
  location            = "us-central1"
  deletion_protection = false

  template {
    containers { # container without name
      image = "redis:latest" 
    }
    containers {
        name  = "something"
        image = "redis:latest"

        ports {
          container_port = 8080
        }
    }
  }
}

I suggest you check your redis image configuration and try again

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

No branches or pull requests

2 participants