Skip to content

fix(gcp-metadata): detect Cloud Run worker pools as serverless - #9331

Open
LucasLeao18 wants to merge 1 commit into
googleapis:mainfrom
LucasLeao18:fix-gcp-metadata-worker-pool
Open

LucasLeao18 wants to merge 1 commit into
googleapis:mainfrom
LucasLeao18:fix-gcp-metadata-worker-pool

Conversation

@LucasLeao18

Copy link
Copy Markdown

Problema

isGoogleCloudServerless() (gcp-metadata) não reconhece Cloud Run Worker Pools: só checa CLOUD_RUN_JOB, FUNCTION_NAME e K_SERVICE. Com apenas CLOUD_RUN_WORKER_POOL setado, retorna false quando deveria retornar true. Inclui reprodução mínima na issue.

Solução

  • core/packages/gcp-metadata/src/gcp-residency.ts: adiciona process.env.CLOUD_RUN_WORKER_POOL à checagem, com comentário/doc-link no padrão existente.
  • test/utils/gcp-residency.ts: inclui a nova variável em removeServerlessEnvironmentVariables() para manter o helper consistente.
  • test/gcp-residency.test.ts: novo caso should return true if CLOUD_RUN_WORKER_POOL env is set.

Validação

  • npm run compile (tsc) limpo.
  • Novo teste falha sem o fix e passa com o fix.
  • Suíte completa do pacote: 69 passing, 0 failing.
  • Reprodução da issue (env simulado via gist): isGoogleCloudServerless() retorna true.
  • Prettier limpo nos arquivos alterados.

Referência

Fixes #9225

@LucasLeao18
LucasLeao18 requested a review from a team as a code owner September 14, 2026 22:00
@google-cla

google-cla Bot commented Sep 14, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request updates the isGoogleCloudServerless function in gcp-residency.ts to include the CLOUD_RUN_WORKER_POOL environment variable when detecting if the application is running in a Google Cloud Serverless environment. It also adds corresponding unit tests and updates the test utility to clean up this environment variable. There are no review comments, and I have no feedback to provide.

@github-actions
github-actions Bot requested a review from feywind September 14, 2026 22:05
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.

IsGoogleCloudServerless function is missing check for Cloud Run Worker Pools

1 participant