Repository navigation
fix(fast): match stage-links.sh impersonation patterns to the real stage service accounts - #300
Merged
aghassemlouei merged 3 commits intoOct 20, 2026
Conversation
The 2-networking stages expected an account ID ending in networking-0, but 1-resman creates the networking stage service account as <prefix>-prod-resman-net-0. The stale impersonation warning therefore fired for the correct account. The 3-security read-only account <prefix>-prod-resman-sec-0r also triggered a false warning. Each stage now lists its read-write and read-only account ID suffixes, taken from 0-bootstrap/automation.tf and the 1-resman branch files, and the match is anchored to the @ separator. The tests use the real account names and cover correct and stale impersonation per stage.
The troubleshooting table listed <prefix>-prod-networking-0 and <prefix>-prod-security-0, which no stage creates. The networking and security stages run as <prefix>-prod-resman-net-0 and <prefix>-security-0.
The stale impersonation warning now names the read-write and read-only account ID suffixes, and the match loop quotes both patterns and skips an empty one. The stale-account tests also cover the 2-networking-b-il5-ngfw stage and the CLOUDSDK_AUTH_IMPERSONATE_SERVICE_ACCOUNT variable, and the new test code follows the repository yapf style.
15 of 26 tasks
aghassemlouei
approved these changes
Oct 20, 2026
aghassemlouei
left a comment
Member
There was a problem hiding this comment.
Verified that the stage service account suffixes in fast/stage-links.sh and docs/ddg.md match the accounts provisioned in 0-bootstrap/automation.tf, 1-resman/branch-networking.tf, and 1-resman/branch-security.tf, and that anchoring the suffix check to @ prevents substring false positives while accepting the read-only -0r variants.
Merged
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.
Description
This change makes the stale-impersonation warning in the
fast/stage-links.shscript reliable. Before, it fired when the shell impersonated the correct networking stage service account.networking-0. Thebranch-networking.tffile in thefast/stages-aw/1-resman/stage creates<prefix>-prod-resman-net-0, so the correct account always raised a warning.<prefix>-prod-resman-sec-0r, because that name does not containsecurity-0.<prefix>-prod-bootstrap-0-oldpassed the bootstrap check.test_stage_links.pytest module hid the networking defect because it used a made-uptest-prod-networking-0account.The fix works as follows.
nameof a service account in theautomation.tffile in thefast/stages-aw/0-bootstrap/stage, or in thebranch-networking.tfandbranch-security.tffiles in thefast/stages-aw/1-resman/stage.@separator, so longer account IDs no longer match.fast/stages-aw/.docs/ddg.mdguide now lists<prefix>-prod-resman-net-0and<prefix>-security-0for the networking and security stages.The
0-bootstrap-tenantand1-resman-tenantcases keep their existing suffixes. The script gains only the matching read-only variants for them, which the old substring match already accepted. Neither stage exists underfast/stages-aw/, so this change does not verify their account names.No tracking issue exists for this defect.
Rebase note
Open pull request #299 moves
tests/tools/test_stage_links.pyto the flattests/directory. If #299 merges first, this branch needs a rebase that applies the test changes to the moved file. The changes do not overlap the open pull request #286, which changes thetools/lint.shscript.Type of Change
Deployment & Compliance Impact
Checklist
Code Quality & Reusability
modules/orfast/stages-aw/can be leveraged for this change.docs/naming-convention.md.Documentation
README.mdof the modified module or blueprint.Security
Testing
Testing Performed
pytest -q tests/tools/test_stage_links.pypasses all 5 tests.origin/mainversion offast/stage-links.sh, the same test module reports 24 failures.pytest -qfrom the repository root passes all 68 tests.bash -n fast/stage-links.shandshellcheck fast/stage-links.shreport no findings.pyflakes tests/tools/test_stage_links.pyreports no findings.yapf -dwith the repository style reports no changes to the lines this change adds.bash tests/scripts/test_shell_syntax.shpasses.python3 tools/check_links.py --no-show-summary docsreports no errors in thedocs/ddg.mdguide. It still reports existing broken/docs/artifacts/links in thedocs/path-to-authorization.mdguide, andorigin/maingives the same result.python3 tools/check_boilerplate.py fast testsreports only the existing missing header in thefast/stages-aw/1-resman/branch-tenants.tffile, andorigin/maingives the same result. This change adds no new files.3-securitydirectory with the networking account impersonated prints the read-only pattern line and a stale-impersonation warning that names both accepted suffixes.