Repository navigation
pick the url of the traffic target we asked for - #599
Open
rootkiller6788 wants to merge 3 commits into
Open
rootkiller6788 wants to merge 3 commits into
rootkiller6788 wants to merge 3 commits into
Conversation
gcloud returns tags as objects ({tag, url, inSpec, inStatus}), not strings.
Our own test fixtures already use the object form, so the declared type was
just wrong. Making the other fields optional too, since gcloud omits some of
them depending on the version.
The parser walked the output and grabbed the first url it found, but gcloud prints every traffic target of the service, not just the one we changed. So with `--to-revisions LATEST=100` on a service that also has an old tagged revision at 0% traffic, the output url could be the tag url of that unrelated revision. Now we pass revision_traffic/tag_traffic into the parser and match on the target that was requested. For a revision we return the service url, for a tag we return that tag's url. If the target isn't in the output we keep the old behavior.
Covers the LATEST=100 case from google-github-actions#589 (a tagged revision at 0% traffic listed first), picking a specific tag, and the fallbacks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #589.
The url output of the action came from whichever traffic target gcloud happened to print first with a url, but gcloud prints every target of the service, not just the one we changed. So deploying with
revision_traffic: 'LATEST=100'on a service that also has an older revision tagged at 0% traffic could hand you back that older revision's tag url - a url that has nothing to do with the deploy that just ran.parseUpdateTrafficResponsenow takes therevision_traffic/tag_trafficstring we passed to gcloud and matches the entry it refers to. For a revision target it returns the service url; for a tag target it returns that tag's url. When nothing matches (for example if the target was set throughupdate_traffic_flags) it keeps the old behavior, so existing callers are unaffected.Two things worth calling out:
urloutput is documented as "the URL of the Cloud Run service", and a revision can carry tags unrelated to this deploy. An explicitly requested tag is the case where a tag url is what you want.tagsfield in the gcloud response is a list of{tag, url, inSpec, inStatus}objects, not strings. The declared type was wrong (our own fixtures already used the object form), so I fixed the type while I was in there.Tests: 4 new cases in tests/unit/output-parser.test.ts (the LATEST=100 case from the issue, selecting a specific tag, and the two fallbacks). All 54 unit tests pass, eslint and the ncc build are clean. Reverting the parser change makes exactly the 4 new cases fail, so they do cover the bug.