Skip to content

fix: prevent parallel Ginkgo processes from racing on func CLI download#135

Merged
creydr merged 2 commits into
functions-dev:mainfrom
creydr:fix/e2e-parallel-download-race
May 11, 2026
Merged

fix: prevent parallel Ginkgo processes from racing on func CLI download#135
creydr merged 2 commits into
functions-dev:mainfrom
creydr:fix/e2e-parallel-download-race

Conversation

@creydr
Copy link
Copy Markdown
Collaborator

@creydr creydr commented May 11, 2026

Summary

  • Fix flaky e2e test caused by parallel Ginkgo processes racing to download the same func CLI binary
  • Add syscall.Flock cross-process file locking with double-checked locking pattern to ensureFuncVersion
  • Use atomic temp-file-then-rename in downloadFuncVersion so partially-written binaries are never visible

Root cause

With ginkgo -p, tests run in 4 separate OS processes. Multiple processes can simultaneously detect the binary is missing and call os.Create on the same file path, corrupting the binary. The old code (pre #132) failed at checksum verification; the current code would fail when trying to execute the corrupted binary.

When e2e tests run with ginkgo -p, multiple OS processes can
simultaneously detect that the func CLI binary is missing and
attempt to download it concurrently. This causes flaky failures
from corrupted binaries or missing temp files.

Fix by using syscall.Flock for cross-process file locking with
double-checked locking, and writing to a temp file with atomic
rename so partially-written binaries are never visible.
@creydr creydr force-pushed the fix/e2e-parallel-download-race branch from 0aebb47 to 6e5fbf3 Compare May 11, 2026 12:11
@creydr
Copy link
Copy Markdown
Collaborator Author

creydr commented May 11, 2026

/cherry-pick release-0.2

@functions-dev-ci-bot
Copy link
Copy Markdown

Only merged pull requests can be cherry-picked.

@creydr creydr enabled auto-merge May 11, 2026 12:35
@creydr creydr added this pull request to the merge queue May 11, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 11, 2026
@creydr creydr added this pull request to the merge queue May 11, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 11, 2026
@creydr creydr added this pull request to the merge queue May 11, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 11, 2026
@creydr creydr added this pull request to the merge queue May 11, 2026
Merged via the queue into functions-dev:main with commit 45c44ab May 11, 2026
11 checks passed
@creydr creydr deleted the fix/e2e-parallel-download-race branch May 11, 2026 16:22
@functions-dev-ci-bot
Copy link
Copy Markdown

Cherry-pick failed for release-0.2, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-0.2
git worktree add -d .worktree/cherry-pick-135-to-release-0.2 origin/release-0.2
cd .worktree/cherry-pick-135-to-release-0.2
git switch --create cherry-pick-135-to-release-0.2
git cherry-pick -x 45c44ab2eac4894f4b9a7c8d4850503f2b7b5d0d

@creydr
Copy link
Copy Markdown
Collaborator Author

creydr commented May 12, 2026

/cherry-pick release-0.3

@functions-dev-ci-bot
Copy link
Copy Markdown

Successfully created cherry-pick PR for release-0.3:

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.

1 participant