Skip to content

Commit 9090786

Browse files
committed
fix(relay): staging director deploys set the admin identity the director trusts to gha-relay
Rebased onto main as one commit after its parent squash-merged.
1 parent b154baf commit 9090786

4 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎.github/workflows/cloud-deploy-relay-staging.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ jobs:
7474
IMAGE_NAME: relay
7575
EXPECTED_IMAGE_DIGEST: ${{ inputs.expected-image-digest }}
7676
CAPACITY_SERVICE_ACCOUNT: ${{ vars.STAGING_GCP_RELAY_CAPACITY_SERVICE_ACCOUNT }}
77+
# The director must trust the identity every staging Relay workflow authenticates as.
78+
DEPLOY_SERVICE_ACCOUNT: ${{ vars.STAGING_GCP_RELAY_DEPLOY_SERVICE_ACCOUNT }}
7779
ASIA_PROOF_SERVICE_ACCOUNT: ${{ vars.STAGING_GCP_RELAY_ASIA_PROOF_SERVICE_ACCOUNT }}
7880
REGIONAL_PLACEMENT_SECRET: orca-cloud-relay-regional-placement-enabled
7981
DIRECTOR_RUNTIME_SERVICE_ACCOUNT: orca-cloud-staging-relay-dir@onorca-cloud-staging.iam.gserviceaccount.com
@@ -199,6 +201,7 @@ jobs:
199201
--role director \
200202
--max-instances 2 \
201203
--capacity-service-account "${CAPACITY_SERVICE_ACCOUNT}" \
204+
--deploy-service-account "${DEPLOY_SERVICE_ACCOUNT}" \
202205
--asia-proof-service-account "${ASIA_PROOF_SERVICE_ACCOUNT}" \
203206
--regional-placement-secret-version "${regional_version}" \
204207
"${floor_args[@]}" \

‎cloud/dev/scripts/deploy-relay-blue-green.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ export function directorDeploymentEnvironment(config) {
263263
}
264264
const serviceAccount = projectServiceAccount(config, 'capacity-service-account')
265265
const asiaProofServiceAccount = projectServiceAccount(config, 'asia-proof-service-account')
266+
const deployServiceAccount = projectServiceAccount(config, 'deploy-service-account')
266267
const rehomeDirectorServiceAccount = projectServiceAccount(
267268
config,
268269
'rehome-director-service-account'
@@ -274,6 +275,10 @@ export function directorDeploymentEnvironment(config) {
274275
if (asiaProofServiceAccount !== undefined) {
275276
environment.ORCA_RELAY_ASIA_PROOF_SERVICE_ACCOUNT = asiaProofServiceAccount
276277
}
278+
// The admin identity the director trusts; omitted, the serving revision's value carries over.
279+
if (deployServiceAccount !== undefined) {
280+
environment.ORCA_RELAY_DEPLOY_SERVICE_ACCOUNT = deployServiceAccount
281+
}
277282
if (rehomeDirectorServiceAccount !== undefined) {
278283
environment[DIRECTOR_REHOME_IDENTITY_ENV] = rehomeDirectorServiceAccount
279284
environment[DIRECTOR_REHOME_AUDIENCE_ENV] = config['rehome-audience']
@@ -330,6 +335,7 @@ export function parseArguments(argv) {
330335
}
331336
if (
332337
values['capacity-service-account'] !== undefined ||
338+
values['deploy-service-account'] !== undefined ||
333339
values['director-cells-json'] !== undefined ||
334340
values['runtime-service-account'] !== undefined ||
335341
values['rehome-director-service-account'] !== undefined ||

‎cloud/dev/scripts/deploy-relay-blue-green.test.mjs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,30 @@ test('reads a director placement from runtime-status, and reports an image witho
10231023
}
10241024
})
10251025

1026+
// Why: staging drifted to a director that trusts gha-deploy while every staging workflow
1027+
// authenticates as gha-relay; the deploy, not Terraform, owns the live value.
1028+
test('a director deploy sets the trusted deploy identity only when asked', () => {
1029+
const config = { project: 'onorca-cloud-staging' }
1030+
const relay = 'orca-cloud-staging-gha-relay@onorca-cloud-staging.iam.gserviceaccount.com'
1031+
assert.equal(
1032+
directorDeploymentEnvironment({ ...config, 'deploy-service-account': relay })
1033+
.ORCA_RELAY_DEPLOY_SERVICE_ACCOUNT,
1034+
relay
1035+
)
1036+
assert.equal(
1037+
'ORCA_RELAY_DEPLOY_SERVICE_ACCOUNT' in directorDeploymentEnvironment(config),
1038+
false
1039+
)
1040+
assert.throws(
1041+
() =>
1042+
directorDeploymentEnvironment({
1043+
...config,
1044+
'deploy-service-account': 'foreign@other-project.iam.gserviceaccount.com'
1045+
}),
1046+
/selected project/
1047+
)
1048+
})
1049+
10261050
// Staging's director trusted gha-deploy while the workflow authenticated as gha-relay: a bare 401.
10271051
test('the guard names the deploy identity a drifted director trusts instead of reading into a 401', async () => {
10281052
const servingImageDigest = `sha256:${'f'.repeat(64)}`

‎cloud/dev/scripts/relay-staging-deploy-identity.test.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,5 @@ test('the staging director deploy runs as relay-dir with its rehome identity', (
232232
assert.match(block, /--runtime-service-account "\$\{DIRECTOR_RUNTIME_SERVICE_ACCOUNT\}"/)
233233
assert.match(block, /--rehome-director-service-account "\$\{DIRECTOR_RUNTIME_SERVICE_ACCOUNT\}"/)
234234
assert.match(source, /DIRECTOR_RUNTIME_SERVICE_ACCOUNT: orca-cloud-staging-relay-dir@/)
235+
assert.match(block, /--deploy-service-account "\$\{DEPLOY_SERVICE_ACCOUNT\}"/)
235236
})

0 commit comments

Comments
 (0)