feat: Use GetService over ListServices during traffic lookup
feat: Use GetService over ListServices during traffic lookup
This also avoids flakiness when the asset inventory reports differently from cloud run.
As experienced by duo-workflow during the initial deployment in https://gitlab.com/gitlab-com/gl-infra/platform/runway/deployments/duo-workflow/-/jobs/7568339776#L175 where traffic map was traffic_map="{\"us-east1\":{\"@NEW@\":{\"traffic_pct\":0,\"tag\":\"canary\"}}}"
Since it was a first deployment, we should expect stable revision to be set at 100% traffic pct. However, prior to this job, there was a failure due to a bad container https://gitlab.com/gitlab-com/gl-infra/platform/runway/deployments/duo-workflow/-/jobs/7568163609#L1042. There was no cloud run revision soon after since it got removed.
I believe that the asset inventory lookup gave a non-empty response and was used subsequently for cloud run revision lookup where nothing was found:
- stale asset inventory lookup: https://gitlab.com/gitlab-com/gl-infra/platform/runway/runwayctl/-/blob/c98b2ca726be5d9b6d4149a0752acce4e5612f0d/cmd/deploy/deploy.go#L429
- regions passed for trafficmap lookup: https://gitlab.com/gitlab-com/gl-infra/platform/runway/runwayctl/-/blob/c98b2ca726be5d9b6d4149a0752acce4e5612f0d/cmd/deploy/deploy.go#L434
- where an empty
Region{}
withnil
error is returned if nothing is found https://gitlab.com/gitlab-com/gl-infra/platform/runway/runwayctl/-/blob/c98b2ca726be5d9b6d4149a0752acce4e5612f0d/internal/traffic/traffic.go#L149 - in
RegionsByState
, an update is set sincehave
would have a single region: https://gitlab.com/gitlab-com/gl-infra/platform/runway/runwayctl/-/blob/c98b2ca726be5d9b6d4149a0752acce4e5612f0d/internal/traffic/traffic.go#L187 - which leads to canary getting set to 0% alongside an empty stable revision in https://gitlab.com/gitlab-com/gl-infra/platform/runway/runwayctl/-/blob/c98b2ca726be5d9b6d4149a0752acce4e5612f0d/internal/traffic/traffic.go#L209
- when
trafficmap
was marshalled to json, stable gets omitted since there is no revision inRevision{}
: https://gitlab.com/gitlab-com/gl-infra/platform/runway/runwayctl/-/blob/c98b2ca726be5d9b6d4149a0752acce4e5612f0d/internal/traffic/traffic.go#L302