Skip to content

genmedia-for-commerce: shorter media bucket name, MEDIA_BUCKET honoured by setup-infra, wait for new APIs - #2859

Merged
lspataroG merged 2 commits into
mainfrom
genmedia-for-commerce-short-bucket
Nov 3, 2026
Merged

lspataroG merged 2 commits into
mainfrom
genmedia-for-commerce-short-bucket

Conversation

@lspataroG

@lspataroG lspataroG commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • The media bucket is now <PROJECT_ID>-gfc-media (at most 40 characters). The old <PROJECT_ID>-genmedia-for-commerce-media-payloads passed the 63-character limit for project ids over 26 characters, so make setup-infra failed with "Use of this bucket name is restricted".
  • Existing deployments: Terraform forgets the old bucket without deleting it (a removed block), creates the new one and moves the app's grants to it. Older runs and studios stay in the old bucket.
  • MEDIA_BUCKET in config.env now also names the bucket Terraform creates or adopts (it was read by the app only). Naming the old bucket keeps using it and its data; when it names another bucket than the one in the state, the state's one is forgotten, never deleted.
  • make setup-infra enables the APIs first and waits (up to 5 minutes) until Artifact Registry and IAM answer, so a new project no longer fails with "Artifact Registry API has not been used ... or it is disabled". The 3-attempt retry stays.

Tested live

  • New project with a 29-character id: setup and deploy pass, a try-on writes to the new bucket.
  • An existing deployment upgraded: the old bucket and its files are kept; setup and deploy pass.
  • That deployment then set MEDIA_BUCKET to its old bucket: setup adopted it and moved the grants, the other bucket kept its files, Cloud Run uses the old bucket.
  • A new project's setup with the API check passes.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated House Rules review — 0 finding(s).

Also, on lines this PR does not change:

  • core/python/genmedia-for-commerce/genmedia4commerce/core/settings.py:169 — [MINOR] env read carries a hardcoded default (second argument is a hardcoded default); 4 occurrence(s) across 1 file(s). Defaults belong in .env.example, not in the code (core/python/genmedia-for-commerce/genmedia4commerce/core/settings.py:169; and 3 more)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Maintainability review — 3 finding(s).


Round 1 · 0 of this PR's 25 automated comments used · this round is capped at 20 across all reviewers.

}

# Step 3: at most 5 minutes; on a re-run the APIs answer at once.
apis() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MINOR] Perhaps this should be named enable_apis() instead of apis()? The other functions in this script use verbs like adopt() and plan_and_apply().

tr -d '"')
# shellcheck disable=SC2086 # one argument per API
gcloud services enable $list --project="$PROJECT" --quiet
for n in $(seq 30); do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MINOR] Is there a reason 30 is hardcoded here? Can we extract this retry count into a named variable?

echo "Waiting for the new APIs to be ready (a new project" \
"takes a minute or two)..."
fi
sleep 10

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MINOR] hardcoded sleep interval here

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Hygiene review — 1 finding(s).


Round 1 · 0 of this PR's 25 automated comments used · this round is capped at 20 across all reviewers.

# 2. The resources with a fixed name that exist but are not in the state
# (made by a run whose state is lost) are imported, not created again.
# 3. terraform plan, then "Apply these changes ...? [Y/n]" on a terminal
# 3. The APIs of terraform/main.tf are enabled first, then the script

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MINOR] It seems apis runs first in the execution pipeline rather than as step 3. Should the list of steps here reflect that?

@lspataroG lspataroG changed the title genmedia-for-commerce: shorter media bucket name; setup-infra waits until new APIs answer genmedia-for-commerce: shorter media bucket name, MEDIA_BUCKET honoured by setup-infra, wait for new APIs Nov 3, 2026

@giuliosalierno giuliosalierno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lspataroG
lspataroG merged commit e7391ed into main Nov 3, 2026
44 checks passed
@lspataroG
lspataroG deleted the genmedia-for-commerce-short-bucket branch November 3, 2026 14:11
tommywagz pushed a commit that referenced this pull request Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants