-
Notifications
You must be signed in to change notification settings - Fork 514
ci: run a composition's ci-cleanup workflow after every mzcompose job #38681
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
base: main
Are you sure you want to change the base?
Changes from all commits
bc2c104
f9a784f
8fe835b
876db8e
8066797
517377b
afd85f6
52fa425
6e03754
890744e
158bb3a
fcf9e0f
827327a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -145,6 +145,33 @@ cleanup() { | |||||||||||||||||
| printf "\n%s" "$BUILDKITE_LABEL: test timed out" >> run.log | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: no trailing newline, and the cleanup's
Suggested change
|
||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| # A composition that holds resources outside of Docker, such as a Cloud | ||||||||||||||||||
| # region, can declare a `ci-cleanup` workflow. It runs here, before the Docker | ||||||||||||||||||
| # teardown, with the arguments of the main workflow. A cancelled or timed-out | ||||||||||||||||||
| # job reaches this trap through SIGTERM, which ends the mzcompose process | ||||||||||||||||||
| # without running the composition's own cleanup path, so this is the only | ||||||||||||||||||
| # cleanup such a run gets. A failure goes to run.log, where ci-annotate-errors | ||||||||||||||||||
| # turns it into an error annotation and fails an otherwise green job. | ||||||||||||||||||
| if echo "$workflows" | grep -x "ci-cleanup" > /dev/null; then | ||||||||||||||||||
| ci_unimportant_heading ":docker: Running the composition's ci-cleanup workflow" | ||||||||||||||||||
| # The main workflow's containers can outlive its process: SIGTERM ends | ||||||||||||||||||
| # mzcompose, but a `docker compose run` container it started keeps going, | ||||||||||||||||||
| # and an in-flight `mz region enable` could re-create the region after the | ||||||||||||||||||
| # cleanup deleted it. Only this composition's compose project (named after | ||||||||||||||||||
| # the composition): other jobs' containers, and containers a composition | ||||||||||||||||||
| # drives outside compose, such as kind nodes, keep running for the log | ||||||||||||||||||
| # collection below. Killed containers keep their logs for services.log; | ||||||||||||||||||
| # `mzcompose down` removes them. | ||||||||||||||||||
| docker ps --quiet --filter "label=com.docker.compose.project=$BUILDKITE_PLUGIN_MZCOMPOSE_COMPOSITION" | xargs --no-run-if-empty docker kill > /dev/null || true | ||||||||||||||||||
|
Comment on lines
+164
to
+165
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Problem. Scope. cluster-spec-sheet does not run under coverage, so nothing breaks today. This is for the next composition that adopts Fix. Skip the kill when
Suggested change
|
||||||||||||||||||
| # 15m keeps a hung cleanup from eating the agents' 40-minute cancel grace | ||||||||||||||||||
| # period before the artifacts and the error annotation. Normal disables | ||||||||||||||||||
| # take about 30 s. The output also goes to run.log so that the artifact | ||||||||||||||||||
| # shows why a cleanup failed. | ||||||||||||||||||
| if ! bin/ci-builder run "$builder" timeout --signal=TERM --kill-after=30s 15m bin/mzcompose --find "$BUILDKITE_PLUGIN_MZCOMPOSE_COMPOSITION" run ci-cleanup "${run_args[@]:1}" |& sed -u -r 's/\x1B\[[0-9;]*[A-Za-z]//g' | tee -a run.log; then | ||||||||||||||||||
| printf "\n%s" "$BUILDKITE_LABEL: ci-cleanup workflow failed" >> run.log | ||||||||||||||||||
| fi | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| ci_unimportant_heading "Post command steps" | ||||||||||||||||||
| # Run before potential "run down" in coverage | ||||||||||||||||||
| docker ps --all --quiet | xargs --no-run-if-empty docker inspect | jq ' | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -869,7 +869,7 @@ def handle_composition( | |
| workflow_name, *args.unknown_subargs[1:], *extra_args | ||
| ) | ||
|
|
||
| if self.shall_generate_junit_report(args.find, composition): | ||
| if self.shall_generate_junit_report(args.find, workflow_name, composition): | ||
| junit_suite = self.generate_junit_suite(composition) | ||
| self.write_junit_report_to_file(junit_suite) | ||
|
|
||
|
|
@@ -880,8 +880,16 @@ def handle_composition( | |
| raise UIError("at least one test case failed") | ||
|
|
||
| def shall_generate_junit_report( | ||
| self, composition_name: str | None, composition: Composition | ||
| self, | ||
| composition_name: str | None, | ||
| workflow_name: str | None, | ||
| composition: Composition, | ||
| ) -> bool: | ||
| if workflow_name == "ci-cleanup": | ||
| # Runs from the CI plugin's exit trap after the main workflow, under | ||
| # the same BUILDKITE_JOB_ID, so its report would overwrite the main | ||
| # run's. Its outcome is reported through run.log instead. | ||
| return False | ||
|
Comment on lines
+888
to
+892
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Design point rather than a defect: the reason for the suppression is a property of how the plugin invokes the workflow (same |
||
| if composition.has_testdrive_junit: | ||
| # Testdrive already produced a junit.xml with detailed errors; | ||
| # skip the mzcompose-level junit to avoid duplicate annotations. | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,9 +4,12 @@ Reproduce data for the cluster spec sheet effort. | |||||
|
|
||||||
| # Usage | ||||||
|
|
||||||
| `bin/mzcompose --find cluster-spec-sheet run default` | ||||||
| `bin/mzcompose --find cluster-spec-sheet run default --target=<target>` | ||||||
|
|
||||||
| This will run all scenarios currently defined for the cluster spec sheet. | ||||||
| `--target` is required: `cloud-production`, `cloud-staging`, or `docker`. | ||||||
| There is deliberately no default, because the CI cleanup below destroys the | ||||||
| target's region unattended. | ||||||
|
|
||||||
| Pass `--cleanup` to disable the region after the test. | ||||||
|
|
||||||
|
|
@@ -15,19 +18,24 @@ Pass `--cleanup` to disable the region after the test. | |||||
|
|
||||||
| ## Running via Buildkite | ||||||
|
|
||||||
| The workload runs as part of the release qualification pipeline in Buildkite. | ||||||
| The workload runs in the `spec-sheet` Buildkite pipeline. After a CI job | ||||||
| ends, however it ends, the mzcompose plugin runs the `ci-cleanup` workflow | ||||||
| with the job's arguments; for a Cloud target started with `--cleanup` it | ||||||
| disables the region. A canceled or timed-out job never reaches the | ||||||
| composition's own cleanup, so this is what keeps canceled runs from leaving | ||||||
| regions behind. | ||||||
|
|
||||||
| ## Running manually in Cloud | ||||||
|
|
||||||
| To run the cloud canary test manually, you can specify either `--target=cloud-production` (which is hardcoded to aws/us-east-1) or `--target=cloud-staging` (which is hardcoded to aws/eu-west-1). For production, you need to set the environment variables `NIGHTLY_MZ_USERNAME` and `MZ_CLI_APP_PASSWORD`. For staging, you need to set the environment variables `NIGHTLY_CANARY_USERNAME` and `NIGHTLY_CANARY_APP_PASSWORD`. | ||||||
| To run the cloud canary test manually, you can specify either `--target=cloud-production` (which is hardcoded to aws/us-east-1) or `--target=cloud-staging` (which is hardcoded to aws/eu-west-1). For production, you need to set the environment variables `NIGHTLY_MZ_USERNAME` and `MZ_CLI_APP_PASSWORD`. For staging, the run uses one account from the E2E database pool: set `E2E_STAGING_TEST_FRONTEGG_DATABASE_APP_PASSWORD_<n>` for the pool index `<n>` and select it with `CI_CONCURRENCY_POOL_SLOT=<n>` (outside CI, index 0 is used when the slot is unset); the username is derived from the index. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A manual staging run also needs
Suggested change
|
||||||
|
|
||||||
| The username is an email address, the app password is a password generated in the cloud console (something like `mzp_...`). | ||||||
|
|
||||||
| Once the environment variables have been set, you can run: | ||||||
|
|
||||||
| ``` | ||||||
| cd test/cluster-spec-sheet | ||||||
| ./mzcompose run default | ||||||
| ./mzcompose run default --target=cloud-production | ||||||
| ``` | ||||||
|
|
||||||
| ## Running in Docker | ||||||
|
|
@@ -55,11 +63,11 @@ bin/mzcompose --find cluster-spec-sheet run default envd_qps_scalability --targ | |||||
| ``` | ||||||
| or | ||||||
| ``` | ||||||
| bin/mzcompose --find cluster-spec-sheet run default cluster | ||||||
| bin/mzcompose --find cluster-spec-sheet run default cluster --target=cloud-production | ||||||
| ``` | ||||||
| or | ||||||
| ``` | ||||||
| bin/mzcompose --find cluster-spec-sheet run default envd_objects_scalability | ||||||
| bin/mzcompose --find cluster-spec-sheet run default envd_objects_scalability --target=cloud-production | ||||||
| ``` | ||||||
| or | ||||||
| ``` | ||||||
|
|
||||||
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.
The section is missing the three things the next adopter cannot infer from the hook.
test/mz-e2eandtest/cloud-canary, which the description names as follow-ups, would hit all three on their first attempt:args:list plusCI_EXTRA_ARGS, so it must useparse_known_args. Withparse_argsit exits 2 on every run, the marker fires, and every green job of that composition turns red.check-mzcompose-files.shfails atest/composition with more than onedef workflow_unlessdefaultloops overc.workflows, and both of those compositions have exactly one workflow today and are not on its exclusion list. The remedy the lint prints would makedefaultrunci-cleanupmid-run. Worth fixing the lint to skipworkflow_ci_cleanupin this PR (see the review body), and saying so here either way.docker kill, so SIGKILL, and it runs on green jobs too. UnderCI_COVERAGE_ENABLEDthe hook deliberately uses a gracefulmzcompose downso the.profrawfiles get written at exit; the kill would lose them silently. The 15m budget is also only in a hook comment.