-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update concurrency rules and limit build queue to one #2932
Open
bmorelli25
wants to merge
11
commits into
master
Choose a base branch
from
move-concurrency
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ba7c407
Update build_pipeline.yml
bmorelli25 22f63a9
add group to each step
bmorelli25 de67bd4
cancel build if there’s a queue
bmorelli25 12172c7
remove concurrency gate from queue step
bmorelli25 0219016
comment out for testing purposes
bmorelli25 4d62453
fix concurrency gate
bmorelli25 5a059e2
the fix for the fix
bmorelli25 e01aafd
look three builds back
bmorelli25 31a5e1c
fix rookie mistake
bmorelli25 a4b8790
rookie mistake here, there, everywhere
bmorelli25 ab1b944
Use BUILDKITE_BUILD_NUMBER instead of BUILDKITE_BUILD_ID
bmorelli25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,45 @@ | ||
steps: | ||
- input: "Build parameters" | ||
if: build.source == "ui" | ||
fields: | ||
- select: "Rebuild?" | ||
key: "REBUILD" | ||
default: "" | ||
required: false | ||
options: | ||
- label: "no" | ||
value: "" | ||
- label: "yes" | ||
value: "rebuild" | ||
hint: "Should all books be rebuilt, regardless of what has changed? Build once with this set to true after every release." | ||
- select: "How should broken links be handled?" | ||
key: "BROKEN_LINKS" | ||
default: "" | ||
required: false | ||
options: | ||
- label: "Continue without warning" | ||
value: "skiplinkcheck" | ||
- label: "Continue, but log a warning" | ||
value: "warnlinkcheck" | ||
- label: "Fail the build" | ||
value: "" | ||
hint: "Should we ignore checking broken links? Should we allow to run the build without failing if there's a broken link? Ignoring broken links is dangerous not just because bad links will leak into the public site but because subsequent builds and pull requests that do not fix the links fail." | ||
# - input: "Build parameters" | ||
# if: build.source == "ui" | ||
# fields: | ||
# - select: "Rebuild?" | ||
# key: "REBUILD" | ||
# default: "" | ||
# required: false | ||
# options: | ||
# - label: "no" | ||
# value: "" | ||
# - label: "yes" | ||
# value: "rebuild" | ||
# hint: "Should all books be rebuilt, regardless of what has changed? Build once with this set to true after every release." | ||
# - select: "How should broken links be handled?" | ||
# key: "BROKEN_LINKS" | ||
# default: "" | ||
# required: false | ||
# options: | ||
# - label: "Continue without warning" | ||
# value: "skiplinkcheck" | ||
# - label: "Continue, but log a warning" | ||
# value: "warnlinkcheck" | ||
# - label: "Fail the build" | ||
# value: "" | ||
# hint: "Should we ignore checking broken links? Should we allow to run the build without failing if there's a broken link? Ignoring broken links is dangerous not just because bad links will leak into the public site but because subsequent builds and pull requests that do not fix the links fail." | ||
# - wait | ||
# This step is purposefully outside of the concurrency gate | ||
- label: "Check for queue" | ||
key: check-queue | ||
# if: build.source == "schedule" | ||
command: ".buildkite/scripts/check_queue.sh" | ||
- wait | ||
- label: "Start of concurrency gate" | ||
command: echo "Start of concurrency gate" | ||
concurrency_group: gate/docs-build-${BUILDKITE_BRANCH} | ||
concurrency: 1 | ||
- wait | ||
- label: "Full rebuild or incremental build?" | ||
if: build.source == "schedule" | ||
# if: build.source == "schedule" | ||
command: ".buildkite/scripts/compare_commits.sh" | ||
- wait | ||
- label: ":white_check_mark: Build docs" | ||
command: | | ||
export REBUILD="$(buildkite-agent meta-data get REBUILD --default '' --log-level fatal)" | ||
|
@@ -37,7 +49,10 @@ steps: | |
provider: "gcp" | ||
image: family/docs-ubuntu-2204 | ||
machineType: ${BUILD_MACHINE_TYPE} | ||
concurrency_group: build-docs-${BUILDKITE_BRANCH} | ||
- wait | ||
- label: "End of concurrency gate" | ||
command: echo "End of concurrency gate" | ||
concurrency_group: gate/docs-build-${BUILDKITE_BRANCH} | ||
concurrency: 1 | ||
notify: | ||
- email: "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
build_data_url="https://api.buildkite.com/v2/organizations/elastic/pipelines/${BUILDKITE_PIPELINE_SLUG}/builds?branch=${BUILDKITE_BRANCH}" | ||
cancel_build_url="https://api.buildkite.com/v2/organizations/elastic/pipelines/${BUILDKITE_PIPELINE_SLUG}/builds/${BUILDKITE_BUILD_NUMBER}/cancel" | ||
|
||
# Don't look at this build (it's running now!) | ||
# Don't look at the last build (it's okay if it's still running!) | ||
# Look three builds back instead (if this build is still running, | ||
# it means there's already one in the queue and we can safely cancel this one) | ||
THIRD_TO_LAST_BUILD_STATE=$(curl -s -H "Authorization: Bearer ${BUILDKITE_API_TOKEN}" $build_data_url | jq -r '.[2].state') | ||
|
||
echo "Determining if there are multiple builds waiting." | ||
if [[ "$THIRD_TO_LAST_BUILD_STATE" == "running" ]]; then | ||
echo "The pipeline is congested. Canceling this build." | ||
curl -sX PUT -H "Authorization: Bearer ${BUILDKITE_API_TOKEN}" $cancel_build_url | ||
else | ||
echo "The pipeline is ready for a new build." | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewer: All of this is commented out so we can test this PR. Once a reviewer has tested this PR, I'll uncomment this out and we can merge.