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

Traffic tags and URLs removed from Cloud Run traffic definition #8654

Comments

@jakubmiarka
Copy link

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 the 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 the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

When any change to Cloud Run resource (google_cloud_run_service) is triggered, the apply removes existing values from the Traffic property of the service definition.

In our set-up we use Terraform to manage the Cloud Run deployment (env vars, IAM, resources ...) but we use Cloud Build to deploy new revisions. For these revisions we assign a traffic tag using gcloud CLI. The YAML definition after a few deployments looks like:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
    ...
spec:
  template:
    metadata:
        ...
    spec:
      ...
  traffic:
  - revisionName: api-00001-kaz
    tag: dev-46351b6
  - revisionName: api-00002-goq
    tag: dev-7791b74
status:
  ...
  traffic:
  - revisionName: api-00001-kaz
    tag: dev-46351b6
    url: https://dev-46351b6---api-abcd-nw.a.run.app
  - revisionName: api-00002-goq
    tag: dev-7791b74
    url: https://dev-7791b74---api-abcd-nw.a.run.app
  url: https://api-abcd-nw.a.run.app
  address:
    url: https://api-abcd-nw.a.run.app

When terraform runs on an unrelated change (such as a change in env var), the plan shows only the env var change. However, when apply runs it removes all the tag and url properties, so the traffic then looks like:

...
traffic:
  - revisionName: api-00001-kaz
  - revisionName: api-00002-goq
...

and we lose our traffic tags and ability to hit/test specific revisions.

From a quick look, I believe the root cause is a mismatch in the schema of the traffic object. Google docs define it as

{
  "configurationName": string,
  "revisionName": string,
  "percent": integer,
  "tag": string,
  "latestRevision": boolean,
  "url": string
}

However, the provider seems to only have:

{
  "revisionName": string,
  "percent": integer,
  "latestRevision": boolean
}

as per the code here. And I suspect when this function runs it strips out everything except the 3 known properties:

transformed = append(transformed, map[string]interface{}{
"revision_name": flattenCloudRunServiceSpecTrafficRevisionName(original["revisionName"], d, config),
"percent": flattenCloudRunServiceSpecTrafficPercent(original["percent"], d, config),
"latest_revision": flattenCloudRunServiceSpecTrafficLatestRevision(original["latestRevision"], d, config),
})

Can the TF's schema be updated to match the GCP's one? Any suggested workarounds in the meantime?

New or Affected Resource(s)

  • google_cloud_run_service
@ghost ghost added the enhancement label Mar 11, 2021
@jakubmiarka jakubmiarka changed the title Cloud Run traffic definition removes tags and URLs from traffic definition Traffic tags and URLs removed from Cloud Run traffic definition Mar 11, 2021
@rileykarson rileykarson added this to the Goals milestone Mar 15, 2021
@george-oakling
Copy link

Today I found out this is blocking us to determine which version had originally the traffic so we can leave it as it is, if we want just to cold start new containers...is it difficult to implement? I would like to participate if needed :)

@george-oakling
Copy link

Hi! Can we expect this to be enhanced any time soon? How can I help to push this a bit? :) @rileykarson

@george-oakling
Copy link

Any news on this issue?

@github-actions
Copy link

github-actions bot commented Jun 4, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.