Skip to content

fix: make race-safe layer publishing opt-in for the e2e sandbox job - #1367

Draft
lucaspimentel wants to merge 2 commits into
mainfrom
lpimentel/race-safe-layer-publish
Draft

fix: make race-safe layer publishing opt-in for the e2e sandbox job#1367
lucaspimentel wants to merge 2 commits into
mainfrom
lpimentel/race-safe-layer-publish

Conversation

@lucaspimentel

@lucaspimentel lucaspimentel commented Sep 10, 2026

Copy link
Copy Markdown
Member

Overview

Automatic layer publishing (AUTOMATICALLY_BUMP_VERSION=1) predicted the next layer version by listing the current latest and adding 1, then ran a strict publish loop that fails the job when AWS assigns a higher version than predicted. Because layer versions are assigned atomically by AWS at publish time, a concurrent pipeline publishing to the same layer between the list call and the publish call makes the prediction stale, and the job fails with Published version N is greater than the desired version N-1 even though the published version holds this job's own binary.

This PR adds an explicit USE_AWS_ASSIGNED_VERSION flag that publishes once and adopts the version AWS returns, and enables it only for the publish layer e2e sandbox job, which is the job that blocks serverless e2e tests when it fails. All other auto-publishing callers (sandbox, serverless_testing, self-monitoring, govcloud us1-staging-fed) keep the previous latest-plus-one prediction and strict behavior. Fixed-version publishing (prod tags, explicit VERSION) is unchanged and remains strict.

For the e2e job, the exported EXTENSION_LAYER_ARN dotenv artifact now always refers to the version this job actually published, so the downstream e2e-test trigger jobs test the binary from this pipeline.

Testing

  • bash -n .gitlab/scripts/publish_layers.sh passes.
  • Regression tests with a stubbed aws CLI covering five scenarios, all passing:
    • auto mode + USE_AWS_ASSIGNED_VERSION=1 (latest 698, AWS assigns 700): exits 0, one publish-layer-version call, no list-layer-versions calls, dotenv exports the ARN of the AWS-assigned version.
    • auto mode without the flag, AWS assigns above the prediction: exits 1 with greater than the desired version, no dotenv (previous behavior preserved).
    • auto mode without the flag, happy path (latest 698, AWS assigns 699): exits 0, exports :699 ARN.
    • fixed mode VERSION=699, AWS assigns 700: still fails, no dotenv.
    • fixed mode VERSION=699, AWS assigns 699: succeeds, exports :699 ARN.
  • shellcheck findings limited to the pre-existing SC2086/SC2059/SC2016/SC2004 classes already present on main.

Automatic layer publishing predicted the next version by listing the
current latest, which races with concurrent pipelines and fails when AWS
assigns a higher version than predicted. Add a USE_AWS_ASSIGNED_VERSION
flag that publishes once and uses the version returned by this job's own
publish-layer-version call, and enable it only for the e2e sandbox
publish job so the exported layer ARN always refers to that job's
binary. All other auto-publishing jobs and scripts keep the previous
latest-plus-one prediction and strict publish behavior, and fixed-version
publishing for tags and manual versions is unchanged.
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Sep 10, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

DataDog/datadog-lambda-extension | e2e-test-status (amd64, fips) — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

ℹ️ Info

🔄 Datadog auto-retried 1 job - 1 passed on retry View in Datadog

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 767132a | Docs | View more details | Give us feedback!

Copilot AI 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.

🟡 Changes recommended

Uninitialized internal mode state can unintentionally bypass strict version handling.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds opt-in AWS-assigned layer versioning for e2e sandbox publishing.

Changes:

  • Publishes once and uses AWS’s returned version.
  • Enables this mode only for e2e sandbox jobs.
  • Preserves strict version handling elsewhere.
File summaries
File Description
.gitlab/templates/pipeline.yaml.tpl Enables AWS-assigned versions for e2e sandbox publishing.
.gitlab/scripts/publish_layers.sh Implements publish-once version adoption.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .gitlab/scripts/publish_layers.sh
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lucaspimentel

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-10T19:16:24.105352Z 767132a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 767132aaef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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