From c16a09e8ce10cae3f982cf463e3d14645ccc2d24 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Wed, 21 Oct 2026 18:05:46 +0000 Subject: [PATCH 1/8] feat: add optional unique mock roots Add the global --unique-mockroot flag and pass mock a stable --uniqueext for each runner. Limit extensions to 24 characters with component labels of up to 12 characters and a six-character random suffix. Use bld, rndr, qry, and shl for build, render, query, and shell actions. Preserve the extension across runner clones and cleanup without changing default root naming. Propagate component labels through builds, rendering, queries, custom source preparation, and advanced mock commands. Add lifecycle and label boundary tests, update user and agent guidance, and refresh generated CLI docs and help snapshots. Quality checks and affected unit packages pass. Help snapshots were refreshed from verified CLI output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 086236b0-c4cd-4289-ace7-c82d78940883 --- docs/user/how-to/build-component.md | 34 ++++ docs/user/reference/cli/azldev.md | 1 + docs/user/reference/cli/azldev_advanced.md | 1 + .../cli/azldev_advanced_download-sources.md | 1 + .../user/reference/cli/azldev_advanced_mcp.md | 1 + .../reference/cli/azldev_advanced_mock.md | 1 + .../cli/azldev_advanced_mock_build-rpms.md | 1 + .../cli/azldev_advanced_mock_shell.md | 1 + .../reference/cli/azldev_advanced_wget.md | 1 + docs/user/reference/cli/azldev_completion.md | 1 + .../reference/cli/azldev_completion_bash.md | 1 + .../reference/cli/azldev_completion_fish.md | 1 + .../cli/azldev_completion_powershell.md | 1 + .../reference/cli/azldev_completion_zsh.md | 1 + docs/user/reference/cli/azldev_component.md | 1 + .../reference/cli/azldev_component_add.md | 1 + .../reference/cli/azldev_component_build.md | 1 + .../reference/cli/azldev_component_changed.md | 1 + .../cli/azldev_component_diff-sources.md | 1 + .../reference/cli/azldev_component_history.md | 1 + .../reference/cli/azldev_component_list.md | 1 + .../cli/azldev_component_metadata.md | 1 + .../cli/azldev_component_prepare-sources.md | 1 + .../reference/cli/azldev_component_query.md | 1 + .../reference/cli/azldev_component_render.md | 1 + .../reference/cli/azldev_component_test.md | 1 + .../reference/cli/azldev_component_update.md | 1 + docs/user/reference/cli/azldev_config.md | 1 + docs/user/reference/cli/azldev_config_dump.md | 1 + .../cli/azldev_config_generate-schema.md | 1 + docs/user/reference/cli/azldev_docs.md | 1 + docs/user/reference/cli/azldev_docs_agent.md | 1 + .../cli/azldev_docs_agent_install.md | 1 + .../reference/cli/azldev_docs_agent_show.md | 1 + .../reference/cli/azldev_docs_markdown.md | 1 + docs/user/reference/cli/azldev_image.md | 1 + docs/user/reference/cli/azldev_image_boot.md | 1 + docs/user/reference/cli/azldev_image_build.md | 1 + .../reference/cli/azldev_image_customize.md | 1 + .../cli/azldev_image_inject-files.md | 1 + docs/user/reference/cli/azldev_image_list.md | 1 + docs/user/reference/cli/azldev_image_test.md | 1 + docs/user/reference/cli/azldev_package.md | 1 + .../user/reference/cli/azldev_package_list.md | 1 + docs/user/reference/cli/azldev_project.md | 1 + .../user/reference/cli/azldev_project_init.md | 1 + docs/user/reference/cli/azldev_project_new.md | 1 + docs/user/reference/cli/azldev_repo.md | 1 + .../user/reference/cli/azldev_repo_compare.md | 1 + docs/user/reference/cli/azldev_repo_query.md | 1 + docs/user/reference/cli/azldev_version.md | 1 + .../app/azldev/agentskill/agentskill_test.go | 12 ++ .../content/build-component.md.tmpl | 8 + .../azldev/agentskill/content/mock.md.tmpl | 6 +- internal/app/azldev/app.go | 4 + internal/app/azldev/app_test.go | 36 ++++ internal/app/azldev/cmds/advanced/mock.go | 10 ++ .../app/azldev/cmds/advanced/mock_test.go | 52 ++++++ internal/app/azldev/cmds/component/build.go | 5 + .../app/azldev/cmds/component/diffsources.go | 2 +- .../azldev/cmds/component/preparesources.go | 2 +- internal/app/azldev/cmds/component/query.go | 2 + .../cmds/component/refreshupstreamcommit.go | 5 +- internal/app/azldev/cmds/component/render.go | 4 +- internal/app/azldev/cmds/component/update.go | 5 +- internal/app/azldev/core/workdir/workdir.go | 2 +- .../app/azldev/core/workdir/workdir_test.go | 26 +++ internal/app/azldev/env.go | 19 ++ internal/app/azldev/env_test.go | 33 ++++ internal/rpm/mock/mock.go | 56 +++--- internal/rpm/mock/uniqueroot.go | 106 ++++++++++++ internal/rpm/mock/uniqueroot_test.go | 163 ++++++++++++++++++ ...pshotsContainer_--bogus-flag_stderr_1.snap | 1 + ...estSnapshotsContainer_--help_stdout_1.snap | 1 + .../TestSnapshotsContainer_help_stdout_1.snap | 1 + .../TestSnapshots_--bogus-flag_stderr_1.snap | 1 + .../TestSnapshots_--help_stdout_1.snap | 1 + ...tSnapshots_--help_with_color_stdout_1.snap | 1 + .../TestSnapshots_help_stdout_1.snap | 1 + 79 files changed, 620 insertions(+), 29 deletions(-) create mode 100644 internal/rpm/mock/uniqueroot.go create mode 100644 internal/rpm/mock/uniqueroot_test.go diff --git a/docs/user/how-to/build-component.md b/docs/user/how-to/build-component.md index 8cb5701ef..1907b2704 100644 --- a/docs/user/how-to/build-component.md +++ b/docs/user/how-to/build-component.md @@ -32,6 +32,7 @@ Built packages are placed in structured subdirectories under the project's outpu | `--srpm-only` | Build only the SRPM, not the binary RPMs | | `--preserve-buildenv on-failure` | Keep the mock chroot on build failure for debugging | | `--continue-on-error` / `-k` | Continue building remaining components if one fails | +| `--unique-mockroot` | Use distinct mock roots instead of the shared default root | | `--local-repo ` | Add a local RPM repository for build dependencies | | `--local-repo-with-publish ` | Use a local repo and publish built RPMs into it | @@ -49,6 +50,39 @@ azldev comp build --local-repo-with-publish ./base/out -p dep-package -p main-pa 2. Enter the chroot with `azldev adv mock shell` to inspect the build environment 3. Check build logs in the project's log directory +## Isolate Mock Roots + +Use the global `--unique-mockroot` flag to avoid sharing mock roots with other +azldev operations: + +```bash +azldev --unique-mockroot comp build -p curl +azldev --unique-mockroot comp render -p curl -p zlib +``` + +Each mock runner passes `--uniqueext` with an extension of at most 24 ASCII +characters: an abbreviated action, a component label of up to 12 characters, +and six random characters, for example `bld-curl-a2b3c4`. +An extension such as `rndr-abcdefghijkl-a2b3c4` uses the full 24-character limit. +Action codes are `bld` for builds (including advanced mock builds), `rndr` for +rendering, `qry` for queries, and `shl` for mock shells with or without packages. +These codes are never shortened further. Other actions use an abbreviated +command name. + +Batch roots label the first component and include the component count when it +fits; otherwise they use the abbreviated first component without the count. +Labels use letters, digits, `_`, and `-`, never spaces. +The extension stays the same for initialization, commands, and cleanup of that +root; separate roots receive separate random suffixes. Without the flag, +mock's existing root naming is unchanged. + +The flag also applies to queries, custom source generation, and +`azldev advanced mock` commands. A unique `mock shell` session does not reuse a +previous session's root. To inspect a preserved unique build root, take its +`--uniqueext` value from the verbose command log and run +`mock -r --uniqueext --shell` directly; a new azldev +invocation generates a new extension. + ## Related Resources - [Components Reference](../reference/config/components.md) — component definition format diff --git a/docs/user/reference/cli/azldev.md b/docs/user/reference/cli/azldev.md index c5de33703..a3ceb9dfc 100644 --- a/docs/user/reference/cli/azldev.md +++ b/docs/user/reference/cli/azldev.md @@ -29,6 +29,7 @@ lives), or use -C to point to one. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced.md b/docs/user/reference/cli/azldev_advanced.md index f76116d52..ef8efb670 100644 --- a/docs/user/reference/cli/azldev_advanced.md +++ b/docs/user/reference/cli/azldev_advanced.md @@ -32,6 +32,7 @@ output but fully supported. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_download-sources.md b/docs/user/reference/cli/azldev_advanced_download-sources.md index 7758ecd08..aa14ee1db 100644 --- a/docs/user/reference/cli/azldev_advanced_download-sources.md +++ b/docs/user/reference/cli/azldev_advanced_download-sources.md @@ -70,6 +70,7 @@ azldev advanced download-sources [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_mcp.md b/docs/user/reference/cli/azldev_advanced_mcp.md index 1f62c5e0c..3d4c384ac 100644 --- a/docs/user/reference/cli/azldev_advanced_mcp.md +++ b/docs/user/reference/cli/azldev_advanced_mcp.md @@ -43,6 +43,7 @@ azldev advanced mcp [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_mock.md b/docs/user/reference/cli/azldev_advanced_mock.md index 984278eea..2a1005d70 100644 --- a/docs/user/reference/cli/azldev_advanced_mock.md +++ b/docs/user/reference/cli/azldev_advanced_mock.md @@ -31,6 +31,7 @@ starting interactive shell sessions in mock chroot environments. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_mock_build-rpms.md b/docs/user/reference/cli/azldev_advanced_mock_build-rpms.md index 18e1be1a3..533f22ac6 100644 --- a/docs/user/reference/cli/azldev_advanced_mock_build-rpms.md +++ b/docs/user/reference/cli/azldev_advanced_mock_build-rpms.md @@ -50,6 +50,7 @@ azldev advanced mock build-rpms [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_mock_shell.md b/docs/user/reference/cli/azldev_advanced_mock_shell.md index 54d6ebc76..f63dd2c4a 100644 --- a/docs/user/reference/cli/azldev_advanced_mock_shell.md +++ b/docs/user/reference/cli/azldev_advanced_mock_shell.md @@ -55,6 +55,7 @@ azldev advanced mock shell [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_wget.md b/docs/user/reference/cli/azldev_advanced_wget.md index aa23ba04a..eaa056ba5 100644 --- a/docs/user/reference/cli/azldev_advanced_wget.md +++ b/docs/user/reference/cli/azldev_advanced_wget.md @@ -44,6 +44,7 @@ azldev advanced wget URI [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_completion.md b/docs/user/reference/cli/azldev_completion.md index 109d7858e..8abc5a6d0 100644 --- a/docs/user/reference/cli/azldev_completion.md +++ b/docs/user/reference/cli/azldev_completion.md @@ -30,6 +30,7 @@ See each sub-command's help for details on how to use the generated script. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_completion_bash.md b/docs/user/reference/cli/azldev_completion_bash.md index f39580feb..b5f95ac1d 100644 --- a/docs/user/reference/cli/azldev_completion_bash.md +++ b/docs/user/reference/cli/azldev_completion_bash.md @@ -53,6 +53,7 @@ azldev completion bash --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_completion_fish.md b/docs/user/reference/cli/azldev_completion_fish.md index 42eaf1dd5..2a137634d 100644 --- a/docs/user/reference/cli/azldev_completion_fish.md +++ b/docs/user/reference/cli/azldev_completion_fish.md @@ -44,6 +44,7 @@ azldev completion fish [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_completion_powershell.md b/docs/user/reference/cli/azldev_completion_powershell.md index 6565209e0..998cab5d1 100644 --- a/docs/user/reference/cli/azldev_completion_powershell.md +++ b/docs/user/reference/cli/azldev_completion_powershell.md @@ -41,6 +41,7 @@ azldev completion powershell [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_completion_zsh.md b/docs/user/reference/cli/azldev_completion_zsh.md index aa7d5d7a4..ad71d5fc1 100644 --- a/docs/user/reference/cli/azldev_completion_zsh.md +++ b/docs/user/reference/cli/azldev_completion_zsh.md @@ -55,6 +55,7 @@ azldev completion zsh [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component.md b/docs/user/reference/cli/azldev_component.md index df0e9622b..0e6f08f2a 100644 --- a/docs/user/reference/cli/azldev_component.md +++ b/docs/user/reference/cli/azldev_component.md @@ -34,6 +34,7 @@ components defined in the project configuration. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_add.md b/docs/user/reference/cli/azldev_component_add.md index 3b0b66fd0..d951425e3 100644 --- a/docs/user/reference/cli/azldev_component_add.md +++ b/docs/user/reference/cli/azldev_component_add.md @@ -47,6 +47,7 @@ azldev component add [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_build.md b/docs/user/reference/cli/azldev_component_build.md index 278ab3f6c..ee33a04d0 100644 --- a/docs/user/reference/cli/azldev_component_build.md +++ b/docs/user/reference/cli/azldev_component_build.md @@ -79,6 +79,7 @@ azldev component build [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_changed.md b/docs/user/reference/cli/azldev_component_changed.md index 2752c4ea2..717859431 100644 --- a/docs/user/reference/cli/azldev_component_changed.md +++ b/docs/user/reference/cli/azldev_component_changed.md @@ -69,6 +69,7 @@ azldev component changed [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_diff-sources.md b/docs/user/reference/cli/azldev_component_diff-sources.md index 4bcb11e90..ff52d20d1 100644 --- a/docs/user/reference/cli/azldev_component_diff-sources.md +++ b/docs/user/reference/cli/azldev_component_diff-sources.md @@ -41,6 +41,7 @@ azldev component diff-sources [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_history.md b/docs/user/reference/cli/azldev_component_history.md index b269a82d5..c5b33a3fd 100644 --- a/docs/user/reference/cli/azldev_component_history.md +++ b/docs/user/reference/cli/azldev_component_history.md @@ -67,6 +67,7 @@ azldev component history [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_list.md b/docs/user/reference/cli/azldev_component_list.md index f0cdcfd7c..4282bdc06 100644 --- a/docs/user/reference/cli/azldev_component_list.md +++ b/docs/user/reference/cli/azldev_component_list.md @@ -56,6 +56,7 @@ azldev component list [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_metadata.md b/docs/user/reference/cli/azldev_component_metadata.md index 35b0dc208..febaed932 100644 --- a/docs/user/reference/cli/azldev_component_metadata.md +++ b/docs/user/reference/cli/azldev_component_metadata.md @@ -82,6 +82,7 @@ azldev component metadata [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_prepare-sources.md b/docs/user/reference/cli/azldev_component_prepare-sources.md index 45f9f8cb7..337dfcfce 100644 --- a/docs/user/reference/cli/azldev_component_prepare-sources.md +++ b/docs/user/reference/cli/azldev_component_prepare-sources.md @@ -62,6 +62,7 @@ azldev component prepare-sources [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_query.md b/docs/user/reference/cli/azldev_component_query.md index f840ca4cd..516e68e9d 100644 --- a/docs/user/reference/cli/azldev_component_query.md +++ b/docs/user/reference/cli/azldev_component_query.md @@ -59,6 +59,7 @@ azldev component query [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_render.md b/docs/user/reference/cli/azldev_component_render.md index 88a9d5157..de7aded11 100644 --- a/docs/user/reference/cli/azldev_component_render.md +++ b/docs/user/reference/cli/azldev_component_render.md @@ -82,6 +82,7 @@ azldev component render [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_test.md b/docs/user/reference/cli/azldev_component_test.md index e316666e3..5ae0631fa 100644 --- a/docs/user/reference/cli/azldev_component_test.md +++ b/docs/user/reference/cli/azldev_component_test.md @@ -108,6 +108,7 @@ azldev component test COMPONENT [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_update.md b/docs/user/reference/cli/azldev_component_update.md index 024d3a153..8fedc7450 100644 --- a/docs/user/reference/cli/azldev_component_update.md +++ b/docs/user/reference/cli/azldev_component_update.md @@ -83,6 +83,7 @@ azldev component update [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_config.md b/docs/user/reference/cli/azldev_config.md index 6eed54b63..d785322cf 100644 --- a/docs/user/reference/cli/azldev_config.md +++ b/docs/user/reference/cli/azldev_config.md @@ -31,6 +31,7 @@ JSON schema used for validating TOML config files. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_config_dump.md b/docs/user/reference/cli/azldev_config_dump.md index 7136efc12..9520c1fe7 100644 --- a/docs/user/reference/cli/azldev_config_dump.md +++ b/docs/user/reference/cli/azldev_config_dump.md @@ -51,6 +51,7 @@ azldev config dump [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_config_generate-schema.md b/docs/user/reference/cli/azldev_config_generate-schema.md index 2f4eece5a..839ba3991 100644 --- a/docs/user/reference/cli/azldev_config_generate-schema.md +++ b/docs/user/reference/cli/azldev_config_generate-schema.md @@ -45,6 +45,7 @@ azldev config generate-schema [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_docs.md b/docs/user/reference/cli/azldev_docs.md index 787033cbb..2023bffa1 100644 --- a/docs/user/reference/cli/azldev_docs.md +++ b/docs/user/reference/cli/azldev_docs.md @@ -31,6 +31,7 @@ command tree, suitable for inclusion in the user guide. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_docs_agent.md b/docs/user/reference/cli/azldev_docs_agent.md index fd1c785b0..3e96e200e 100644 --- a/docs/user/reference/cli/azldev_docs_agent.md +++ b/docs/user/reference/cli/azldev_docs_agent.md @@ -33,6 +33,7 @@ reference so that agents always load the guidance that ships with the binary. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_docs_agent_install.md b/docs/user/reference/cli/azldev_docs_agent_install.md index c8c8853a5..fa56e5407 100644 --- a/docs/user/reference/cli/azldev_docs_agent_install.md +++ b/docs/user/reference/cli/azldev_docs_agent_install.md @@ -73,6 +73,7 @@ azldev docs agent install [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_docs_agent_show.md b/docs/user/reference/cli/azldev_docs_agent_show.md index 11d32383c..db7739a3c 100644 --- a/docs/user/reference/cli/azldev_docs_agent_show.md +++ b/docs/user/reference/cli/azldev_docs_agent_show.md @@ -50,6 +50,7 @@ azldev docs agent show [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_docs_markdown.md b/docs/user/reference/cli/azldev_docs_markdown.md index a86b59b4d..6fe0bbafc 100644 --- a/docs/user/reference/cli/azldev_docs_markdown.md +++ b/docs/user/reference/cli/azldev_docs_markdown.md @@ -52,6 +52,7 @@ azldev docs markdown [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image.md b/docs/user/reference/cli/azldev_image.md index ea678cf94..892ad319c 100644 --- a/docs/user/reference/cli/azldev_image.md +++ b/docs/user/reference/cli/azldev_image.md @@ -32,6 +32,7 @@ can be customized using Azure Linux Image Customizer. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_boot.md b/docs/user/reference/cli/azldev_image_boot.md index 143536805..66898d187 100644 --- a/docs/user/reference/cli/azldev_image_boot.md +++ b/docs/user/reference/cli/azldev_image_boot.md @@ -96,6 +96,7 @@ azldev image boot [IMAGE_NAME] [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_build.md b/docs/user/reference/cli/azldev_image_build.md index 3c89f6b7a..c563e340d 100644 --- a/docs/user/reference/cli/azldev_image_build.md +++ b/docs/user/reference/cli/azldev_image_build.md @@ -57,6 +57,7 @@ azldev image build [image-name] [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_customize.md b/docs/user/reference/cli/azldev_image_customize.md index 929c4f10b..593e6b410 100644 --- a/docs/user/reference/cli/azldev_image_customize.md +++ b/docs/user/reference/cli/azldev_image_customize.md @@ -55,6 +55,7 @@ azldev image customize [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_inject-files.md b/docs/user/reference/cli/azldev_image_inject-files.md index 748bde7f4..d4eeb7b6c 100644 --- a/docs/user/reference/cli/azldev_image_inject-files.md +++ b/docs/user/reference/cli/azldev_image_inject-files.md @@ -46,6 +46,7 @@ azldev image inject-files [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_list.md b/docs/user/reference/cli/azldev_image_list.md index a1270bbd3..edfb25fef 100644 --- a/docs/user/reference/cli/azldev_image_list.md +++ b/docs/user/reference/cli/azldev_image_list.md @@ -48,6 +48,7 @@ azldev image list [image-name-pattern...] [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_test.md b/docs/user/reference/cli/azldev_image_test.md index e2c1ca54e..d0be33dc8 100644 --- a/docs/user/reference/cli/azldev_image_test.md +++ b/docs/user/reference/cli/azldev_image_test.md @@ -81,6 +81,7 @@ azldev image test IMAGE_NAME [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_package.md b/docs/user/reference/cli/azldev_package.md index 678421bcc..b86f27d6c 100644 --- a/docs/user/reference/cli/azldev_package.md +++ b/docs/user/reference/cli/azldev_package.md @@ -32,6 +32,7 @@ publish channel assignments derived from package groups and component overrides. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_package_list.md b/docs/user/reference/cli/azldev_package_list.md index e6165273e..4f7f49d06 100644 --- a/docs/user/reference/cli/azldev_package_list.md +++ b/docs/user/reference/cli/azldev_package_list.md @@ -81,6 +81,7 @@ azldev package list [package-name...] [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_project.md b/docs/user/reference/cli/azldev_project.md index fef53ace7..3481a66be 100644 --- a/docs/user/reference/cli/azldev_project.md +++ b/docs/user/reference/cli/azldev_project.md @@ -31,6 +31,7 @@ as an Azure Linux project with a basic configuration. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_project_init.md b/docs/user/reference/cli/azldev_project_init.md index 13be79456..ecb50394f 100644 --- a/docs/user/reference/cli/azldev_project_init.md +++ b/docs/user/reference/cli/azldev_project_init.md @@ -42,6 +42,7 @@ azldev project init [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_project_new.md b/docs/user/reference/cli/azldev_project_new.md index b494e46ee..6c8677cfa 100644 --- a/docs/user/reference/cli/azldev_project_new.md +++ b/docs/user/reference/cli/azldev_project_new.md @@ -45,6 +45,7 @@ azldev project new PATH [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_repo.md b/docs/user/reference/cli/azldev_repo.md index ccbc3f5ee..018ed58f3 100644 --- a/docs/user/reference/cli/azldev_repo.md +++ b/docs/user/reference/cli/azldev_repo.md @@ -32,6 +32,7 @@ under one or more URL prefixes. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_repo_compare.md b/docs/user/reference/cli/azldev_repo_compare.md index 7053a3f19..8249d2c64 100644 --- a/docs/user/reference/cli/azldev_repo_compare.md +++ b/docs/user/reference/cli/azldev_repo_compare.md @@ -50,6 +50,7 @@ azldev repo compare [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_repo_query.md b/docs/user/reference/cli/azldev_repo_query.md index 9086aa1c9..7a12a5bc5 100644 --- a/docs/user/reference/cli/azldev_repo_query.md +++ b/docs/user/reference/cli/azldev_repo_query.md @@ -73,6 +73,7 @@ azldev repo query [flags] -- --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_version.md b/docs/user/reference/cli/azldev_version.md index 5ebddbcdd..21666d793 100644 --- a/docs/user/reference/cli/azldev_version.md +++ b/docs/user/reference/cli/azldev_version.md @@ -36,6 +36,7 @@ azldev version -O json --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/internal/app/azldev/agentskill/agentskill_test.go b/internal/app/azldev/agentskill/agentskill_test.go index a263a100f..212bb6dca 100644 --- a/internal/app/azldev/agentskill/agentskill_test.go +++ b/internal/app/azldev/agentskill/agentskill_test.go @@ -153,6 +153,18 @@ func TestBuildComponentSkillDocumentsRPMDevBumpspecPreview(t *testing.T) { assert.NotContains(t, doc, "rpmdev-bumpspec` or RPM macros") } +func TestSkillsDocumentUniqueMockRoots(t *testing.T) { + for _, name := range []string{"azldev-build-component", "azldev-mock"} { + t.Run(name, func(t *testing.T) { + doc, err := agentskill.SkillDocument(name, testParams()) + require.NoError(t, err) + assert.Contains(t, doc, "--unique-mockroot") + assert.Contains(t, doc, "at most 24 characters") + assert.Contains(t, doc, "--uniqueext --shell") + }) + } +} + func TestComponentTomlSkillDocumentsRPMDevBumpspecPreview(t *testing.T) { doc, err := agentskill.SkillDocument("azldev-comp-toml", testParams()) require.NoError(t, err) diff --git a/internal/app/azldev/agentskill/content/build-component.md.tmpl b/internal/app/azldev/agentskill/content/build-component.md.tmpl index 9375d5e22..46edb5bbe 100644 --- a/internal/app/azldev/agentskill/content/build-component.md.tmpl +++ b/internal/app/azldev/agentskill/content/build-component.md.tmpl @@ -21,6 +21,14 @@ Build foundational packages before their dependents. RPMs land in the project's configured output directory (`out` by default). `-q` quiets output but hides build progress — use it only for inner-loop builds you expect to succeed. +Use the global `--unique-mockroot` flag to isolate mock roots from other azldev +operations. Extensions contain abbreviated action/component labels and a random +suffix, use at most 24 characters total (up to 12 for the component label), and +remain stable through each root's cleanup. +To inspect a preserved unique root, use +`mock -r --uniqueext --shell` with the extension from +the verbose command log; a new azldev shell invocation creates a different root. + ## The inner loop investigate → modify → render → build → test → inspect diff --git a/internal/app/azldev/agentskill/content/mock.md.tmpl b/internal/app/azldev/agentskill/content/mock.md.tmpl index e42d63615..f50ba4a95 100644 --- a/internal/app/azldev/agentskill/content/mock.md.tmpl +++ b/internal/app/azldev/agentskill/content/mock.md.tmpl @@ -73,6 +73,7 @@ react to output between commands. | --- | --- | | `-p`, `--add-package ` | Install a package into the chroot before entering. Accepts an RPM file path or a package name. May be repeated. | | `--enable-network` | Allow network access (dependency resolution, downloads). | +| `--unique-mockroot` | Use a distinct root for this session, passing mock an action/package label (up to 12 characters for the package label) and random suffix via `--uniqueext` (at most 24 characters total). | > **`-p` means `--add-package`, not a component name.** Unlike `azldev comp build -p `, > `mock shell` has no component selector. `-p ` installs a package *by name* from the @@ -82,10 +83,13 @@ react to output between commands. - **Don't mix `-p ` with `--add-package /path/to/.rpm` for the same package** — that installs both the repo build and your local build, which conflict. Use one or the other. -- **The mock chroot is persistent** across `azldev adv mock shell` sessions — installed packages and +- **The mock chroot is persistent by default** across `azldev adv mock shell` sessions — installed packages and created files survive. Handy (install once, re-enter later), but stale state can confuse. azldev has no built-in reset; clear it with `mock` directly (`--scrub=chroot`, or `--scrub=all` to also drop the bootstrap), pointing at the project's distro mock config. +- **`--unique-mockroot` starts a separate root each time.** To re-enter a preserved unique root, + use `mock -r --uniqueext --shell` with the extension from the + verbose command log, not another azldev invocation. - **One mock session per terminal.** Running `azldev adv mock shell` while a terminal is already inside a mock shell fails — run `exit` first. diff --git a/internal/app/azldev/app.go b/internal/app/azldev/app.go index f9cfda1ae..3fa90076b 100644 --- a/internal/app/azldev/app.go +++ b/internal/app/azldev/app.go @@ -55,6 +55,7 @@ type App struct { configFiles []string colorMode ColorMode withoutLockfile bool + uniqueMockRoot bool // Root command for the CLI. cmd cobra.Command @@ -141,6 +142,7 @@ lives), or use -C to point to one.`, env.SetConcurrency(app.concurrency) env.SetNetworkRetries(app.networkRetries) env.SetPermissiveConfigParsing(app.permissiveConfigEnabled()) + env.SetUniqueMockRoot(app.uniqueMockRoot, command.Name()) return nil }, @@ -193,6 +195,8 @@ func (app *App) registerGlobalFlags() { false, "do not fail on unknown fields in TOML config files") app.cmd.PersistentFlags().BoolVar(&app.withoutLockfile, "without-lockfile", false, "preview: track resolved upstream commits in generated config instead of lock files") + app.cmd.PersistentFlags().BoolVar(&app.uniqueMockRoot, "unique-mockroot", false, + "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)") } // addAdvancedCommandHint embeds a hint about the hidden "advanced" command group diff --git a/internal/app/azldev/app_test.go b/internal/app/azldev/app_test.go index 64ac1397b..ab7421b19 100644 --- a/internal/app/azldev/app_test.go +++ b/internal/app/azldev/app_test.go @@ -9,6 +9,7 @@ import ( "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev" "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev/core/testutils" + "github.com/microsoft/azure-linux-dev-tools/internal/rpm/mock" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -67,6 +68,41 @@ func TestApp_Execute(t *testing.T) { assert.True(t, ran) } +func TestApp_UniqueMockRoot(t *testing.T) { + for name, enabled := range map[string]bool{"default": false, "enabled": true} { + t.Run(name, func(t *testing.T) { + app := createTestApp(t) + ran := false + cmd := &cobra.Command{ + Use: "build", + RunE: func(cmd *cobra.Command, _ []string) error { + ran = true + env, err := azldev.GetEnvFromCommand(cmd) + require.NoError(t, err) + + runner := mock.NewRunner(env.WithMockRootComponents("curl"), "/mock.cfg") + if enabled { + assert.Regexp(t, `^bld-curl-[a-z2-7]{6}$`, runner.UniqueExtension()) + } else { + assert.Empty(t, runner.UniqueExtension()) + } + + return nil + }, + } + app.AddTopLevelCommand(cmd) + + args := []string{"build"} + if enabled { + args = append(args, "--unique-mockroot") + } + + assert.Zero(t, app.Execute(args)) + assert.True(t, ran) + }) + } +} + func TestApp_RegisterPostInitCallback(t *testing.T) { app := createTestApp(t) diff --git a/internal/app/azldev/cmds/advanced/mock.go b/internal/app/azldev/cmds/advanced/mock.go index 18e4f8060..660582a60 100644 --- a/internal/app/azldev/cmds/advanced/mock.go +++ b/internal/app/azldev/cmds/advanced/mock.go @@ -6,6 +6,7 @@ package advanced import ( "fmt" "os" + "path/filepath" "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev" "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev/core/buildenvfactory" @@ -142,6 +143,8 @@ running smoke tests. Packages can be pre-installed into the chroot using // Builds RPMs from sources, using options. func BuildRPMS(env *azldev.Env, options *BuildRPMOptions) (results interface{}, err error) { + env = env.WithMockRootComponents(filepath.Base(options.SRPMPath)) + runner, err := makeMockRunner(env, &options.MockCmdOptions) if err != nil { return results, err @@ -167,6 +170,13 @@ func BuildRPMS(env *azldev.Env, options *BuildRPMOptions) (results interface{}, // Executes an interactive shell within a mock root. Uses the provided [ShellOptions] to configure the shell. func RunShell(env *azldev.Env, options *ShellOptions, extraArgs []string) error { + packages := make([]string, len(options.PackagesToAdd)) + for idx, pkg := range options.PackagesToAdd { + packages[idx] = filepath.Base(pkg) + } + + env = env.WithMockRootComponents(packages...) + runner, err := makeMockRunner(env, &options.MockCmdOptions) if err != nil { return err diff --git a/internal/app/azldev/cmds/advanced/mock_test.go b/internal/app/azldev/cmds/advanced/mock_test.go index 61a295f19..79e295210 100644 --- a/internal/app/azldev/cmds/advanced/mock_test.go +++ b/internal/app/azldev/cmds/advanced/mock_test.go @@ -35,6 +35,58 @@ func TestNewShellCmd(t *testing.T) { assert.Equal(t, "shell", cmd.Use) } +func TestAdvancedUniqueMockRoots(t *testing.T) { + tests := []struct { + name string + action string + configPath string + prefix string + }{ + {name: "shell explicit config", action: "shell", configPath: "/mock.cfg", prefix: "shl-curl-1-0-rpm-"}, + {name: "shell project config", action: "shell", prefix: "shl-curl-1-0-rpm-"}, + {name: "build explicit config", action: "build-rpms", configPath: "/mock.cfg", prefix: "bld-curl-1-0-src-"}, + {name: "build project config", action: "build-rpms", prefix: "bld-curl-1-0-src-"}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + env := testutils.NewTestEnv(t) + env.Env.SetUniqueMockRoot(true, test.action) + env.CmdFactory.RegisterCommandInSearchPath("mock") + + var extensions []string + + env.CmdFactory.RunHandler = func(cmd *exec.Cmd) error { + idx := slices.Index(cmd.Args, "--uniqueext") + require.Positive(t, idx) + require.Less(t, idx+1, len(cmd.Args)) + extensions = append(extensions, cmd.Args[idx+1]) + + return nil + } + + common := advanced.MockCmdOptions{MockConfigPath: test.configPath} + if test.action == "shell" { + require.NoError(t, advanced.RunShell(env.Env, &advanced.ShellOptions{ + MockCmdOptions: common, + PackagesToAdd: []string{"/rpms/curl-1.0.rpm"}, + }, []string{"true"})) + require.Len(t, extensions, 2) + assert.Equal(t, extensions[0], extensions[1]) + } else { + _, err := advanced.BuildRPMS(env.Env, &advanced.BuildRPMOptions{ + MockCmdOptions: common, + SRPMPath: "/srpms/curl-1.0.src.rpm", + OutputDirPath: "/rpms", + }) + require.NoError(t, err) + require.Len(t, extensions, 1) + } + + assert.Regexp(t, "^"+test.prefix+`[a-z2-7]{6}$`, extensions[0]) + }) + } +} + func TestBuildRPMS(t *testing.T) { const ( testMockConfigPath = "/mock/mock.cfg" diff --git a/internal/app/azldev/cmds/component/build.go b/internal/app/azldev/cmds/component/build.go index 2c9f99171..f7139e60c 100644 --- a/internal/app/azldev/cmds/component/build.go +++ b/internal/app/azldev/cmds/component/build.go @@ -201,6 +201,8 @@ func BuildComponents( return nil, fmt.Errorf("failed to create work dir factory:\n%w", err) } + env = env.WithMockRootComponents(components.Names()...) + mockProcessor := createBuildMockProcessor(env) defer destroyMockProcessor(env, mockProcessor) @@ -229,6 +231,8 @@ func BuildComponent( workDirFactory *workdir.Factory, options *ComponentBuildOptions, ) (ComponentBuildResults, error) { + env = env.WithMockRootComponents(component.GetName()) + mockProcessor := createBuildMockProcessor(env) defer destroyMockProcessor(env, mockProcessor) @@ -242,6 +246,7 @@ func buildComponent( mockProcessor *sources.MockProcessor, options *ComponentBuildOptions, ) (results ComponentBuildResults, err error) { + env = env.WithMockRootComponents(component.GetName()) // Resolve the effective distro for this component before creating the source manager. distro, err := sourceproviders.ResolveDistro(env, component) if err != nil { diff --git a/internal/app/azldev/cmds/component/diffsources.go b/internal/app/azldev/cmds/component/diffsources.go index 7fd728050..e021e01f5 100644 --- a/internal/app/azldev/cmds/component/diffsources.go +++ b/internal/app/azldev/cmds/component/diffsources.go @@ -96,7 +96,7 @@ func DiffComponentSources(env *azldev.Env, options *DiffSourcesOptions) (interfa return nil, fmt.Errorf("failed to resolve distro for component %q:\n%w", component.GetName(), err) } - sourceManager, err := sourceproviders.NewSourceManager(env, distro) + sourceManager, err := sourceproviders.NewSourceManager(env.WithMockRootComponents(component.GetName()), distro) if err != nil { return nil, fmt.Errorf("failed to create source manager:\n%w", err) } diff --git a/internal/app/azldev/cmds/component/preparesources.go b/internal/app/azldev/cmds/component/preparesources.go index 317b7fb38..4be62ae43 100644 --- a/internal/app/azldev/cmds/component/preparesources.go +++ b/internal/app/azldev/cmds/component/preparesources.go @@ -126,7 +126,7 @@ func PrepareComponentSources(env *azldev.Env, options *PrepareSourcesOptions) er } // Create source manager to handle all source fetching, both local and upstream. - sourceManager, err = sourceproviders.NewSourceManager(env, distro) + sourceManager, err = sourceproviders.NewSourceManager(env.WithMockRootComponents(component.GetName()), distro) if err != nil { return fmt.Errorf("failed to create source manager:\n%w", err) } diff --git a/internal/app/azldev/cmds/component/query.go b/internal/app/azldev/cmds/component/query.go index 83014b12c..8c09e6563 100644 --- a/internal/app/azldev/cmds/component/query.go +++ b/internal/app/azldev/cmds/component/query.go @@ -154,6 +154,8 @@ func QueryComponents( comps.Len()) } + env = env.WithMockRootComponents(comps.Names()...) + mockProcessor := createQueryMockProcessor(env) if mockProcessor == nil { return nil, errors.New( diff --git a/internal/app/azldev/cmds/component/refreshupstreamcommit.go b/internal/app/azldev/cmds/component/refreshupstreamcommit.go index 02da3bddf..a5c7dc30b 100644 --- a/internal/app/azldev/cmds/component/refreshupstreamcommit.go +++ b/internal/app/azldev/cmds/component/refreshupstreamcommit.go @@ -15,6 +15,7 @@ import ( "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev/core/components" "github.com/microsoft/azure-linux-dev-tools/internal/projectconfig" "github.com/microsoft/azure-linux-dev-tools/internal/providers/sourceproviders" + "github.com/microsoft/azure-linux-dev-tools/internal/rpm/mock" "github.com/microsoft/azure-linux-dev-tools/internal/upstreamcommit" "github.com/microsoft/azure-linux-dev-tools/internal/utils/parmap" "github.com/spf13/cobra" @@ -619,7 +620,9 @@ func resolveUpstreamCommit( return "", fmt.Errorf("resolving distro for %#q:\n%w", componentName, err) } - sourceManager, err := sourceproviders.NewSourceManager(env, distro) + //nolint:contextcheck // The cloned operational Env carries ctx and component-specific root labels. + sourceManager, err := sourceproviders.NewSourceManager( + env.WithContext(mock.WithRootComponents(ctx, componentName)), distro) if err != nil { return "", fmt.Errorf("creating source manager for %#q:\n%w", componentName, err) } diff --git a/internal/app/azldev/cmds/component/render.go b/internal/app/azldev/cmds/component/render.go index ff99942bd..afe1e95cc 100644 --- a/internal/app/azldev/cmds/component/render.go +++ b/internal/app/azldev/cmds/component/render.go @@ -177,6 +177,8 @@ func RenderComponents(env *azldev.Env, options *RenderOptions) ([]*RenderResult, } // Create mock processor for rpmautospec/spectool. + env = env.WithMockRootComponents(comps.Names()...) + mockProcessor := createMockProcessor(env) if mockProcessor == nil { return nil, errors.New( @@ -516,7 +518,7 @@ func prepareComponentSources( } // Create source manager. - sourceManager, err := sourceproviders.NewSourceManager(env, distro) + sourceManager, err := sourceproviders.NewSourceManager(env.WithMockRootComponents(componentName), distro) if err != nil { return nil, fmt.Errorf("creating source manager for %#q:\n%w", componentName, err) } diff --git a/internal/app/azldev/cmds/component/update.go b/internal/app/azldev/cmds/component/update.go index 9da1b4f75..32a027477 100644 --- a/internal/app/azldev/cmds/component/update.go +++ b/internal/app/azldev/cmds/component/update.go @@ -17,6 +17,7 @@ import ( "github.com/microsoft/azure-linux-dev-tools/internal/lockfile" "github.com/microsoft/azure-linux-dev-tools/internal/projectconfig" "github.com/microsoft/azure-linux-dev-tools/internal/providers/sourceproviders" + "github.com/microsoft/azure-linux-dev-tools/internal/rpm/mock" "github.com/microsoft/azure-linux-dev-tools/internal/utils/parmap" "github.com/spf13/cobra" ) @@ -886,7 +887,9 @@ func resolveOneSourceIdentity( return "", fmt.Errorf("resolving distro for %#q:\n%w", componentName, err) } - sourceManager, err := sourceproviders.NewSourceManager(env, distro) + //nolint:contextcheck // The cloned operational Env carries ctx and component-specific root labels. + sourceManager, err := sourceproviders.NewSourceManager( + env.WithContext(mock.WithRootComponents(ctx, componentName)), distro) if err != nil { return "", fmt.Errorf("creating source manager for %#q:\n%w", componentName, err) } diff --git a/internal/app/azldev/core/workdir/workdir.go b/internal/app/azldev/core/workdir/workdir.go index f611485e5..8af71c2fc 100644 --- a/internal/app/azldev/core/workdir/workdir.go +++ b/internal/app/azldev/core/workdir/workdir.go @@ -92,7 +92,7 @@ func MkComponentBuildEnvironment( // We'll nest the build environment in a subdirectory under the work directory. buildEnvDir := filepath.Join(workDir, "buildenv") - buildEnvFactory, err := buildenvfactory.NewMockRootFactoryForEnv(env) + buildEnvFactory, err := buildenvfactory.NewMockRootFactoryForEnv(env.WithMockRootComponents(component.Name)) if err != nil { return nil, fmt.Errorf("failed to create mock root factory:\n%w", err) } diff --git a/internal/app/azldev/core/workdir/workdir_test.go b/internal/app/azldev/core/workdir/workdir_test.go index fdc6d53b5..f61df3f59 100644 --- a/internal/app/azldev/core/workdir/workdir_test.go +++ b/internal/app/azldev/core/workdir/workdir_test.go @@ -9,6 +9,7 @@ import ( "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev/core/testutils" "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev/core/workdir" + "github.com/microsoft/azure-linux-dev-tools/internal/buildenv" "github.com/microsoft/azure-linux-dev-tools/internal/projectconfig" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -59,3 +60,28 @@ func Test_Create(t *testing.T) { require.NoError(t, statErr) assert.True(t, stat.IsDir()) } + +func TestMkComponentBuildEnvironmentUniqueRoots(t *testing.T) { + env := testutils.NewTestEnv(t) + env.Env.SetUniqueMockRoot(true, "build") + factory, err := workdir.NewFactory(env.FS(), env.Env.WorkDir(), env.Env.ConstructionTime()) + require.NoError(t, err) + + names := []string{"curl", "zlib", "curl"} + + extensions := make([]string, 0, len(names)) + for _, name := range names { + root, createErr := workdir.MkComponentBuildEnvironment(env.Env, factory, + &projectconfig.ComponentConfig{Name: name}, "build", nil) + require.NoError(t, createErr) + + mockRoot, ok := root.(*buildenv.MockRoot) + require.True(t, ok) + + extension := mockRoot.GetRunner().UniqueExtension() + assert.Regexp(t, `^bld-`+name+`-[a-z2-7]{6}$`, extension) + assert.Equal(t, extension, mockRoot.GetRunner().UniqueExtension()) + assert.NotContains(t, extensions, extension) + extensions = append(extensions, extension) + } +} diff --git a/internal/app/azldev/env.go b/internal/app/azldev/env.go index 9b426033f..0c2729b0f 100644 --- a/internal/app/azldev/env.go +++ b/internal/app/azldev/env.go @@ -23,6 +23,7 @@ import ( "github.com/microsoft/azure-linux-dev-tools/internal/global/opctx" "github.com/microsoft/azure-linux-dev-tools/internal/lockfile" "github.com/microsoft/azure-linux-dev-tools/internal/projectconfig" + "github.com/microsoft/azure-linux-dev-tools/internal/rpm/mock" ) // Parameters used to construct an [Env]. @@ -227,6 +228,24 @@ func (env *Env) SetVerbose(verbose bool) { env.verbose = verbose } +// SetUniqueMockRoot configures unique mock roots for the current CLI action. +func (env *Env) SetUniqueMockRoot(enabled bool, action string) { + env.ctx = mock.WithUniqueRoots(env.ctx, enabled, action) +} + +// WithMockRootComponents returns a shallow copy with component-specific mock root labels. +func (env *Env) WithMockRootComponents(names ...string) *Env { + return env.WithContext(mock.WithRootComponents(env.ctx, names...)) +} + +// WithContext returns a shallow copy using the supplied context for cancellation and values. +func (env *Env) WithContext(ctx context.Context) *Env { + childEnv := *env + childEnv.ctx = ctx + + return &childEnv +} + // NetworkRetries returns the maximum number of attempts for network operations. func (env *Env) NetworkRetries() int { return env.networkRetries diff --git a/internal/app/azldev/env_test.go b/internal/app/azldev/env_test.go index 7aa094960..423ffbe28 100644 --- a/internal/app/azldev/env_test.go +++ b/internal/app/azldev/env_test.go @@ -17,6 +17,7 @@ import ( "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev" "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev/core/testutils" "github.com/microsoft/azure-linux-dev-tools/internal/projectconfig" + "github.com/microsoft/azure-linux-dev-tools/internal/rpm/mock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -34,6 +35,38 @@ func setupTestLogger(logBuffer *bytes.Buffer) func() { } } +func TestEnvMockRootContext(t *testing.T) { + env := testutils.NewTestEnv(t).Env + env.SetUniqueMockRoot(true, "render") + + child := env.WithMockRootComponents("curl", "zlib") + + worker, cancel := child.WithCancel() + defer cancel() + + assert.Regexp(t, `^rndr-c_2-[a-z2-7]{6}$`, mock.NewRunner(worker, "/mock.cfg").UniqueExtension()) + assert.Regexp(t, `^rndr-[a-z2-7]{6}$`, mock.NewRunner(env, "/mock.cfg").UniqueExtension()) + + env.SetUniqueMockRoot(false, "render") + assert.Empty(t, mock.NewRunner(env, "/mock.cfg").UniqueExtension()) + assert.NotEmpty(t, mock.NewRunner(child, "/mock.cfg").UniqueExtension()) +} + +func TestEnvWithContext(t *testing.T) { + env := testutils.NewTestEnv(t).Env + + ctx, cancel := context.WithCancel(t.Context()) + defer cancel() + + child := env.WithContext(ctx) + assert.Equal(t, env.FS(), child.FS()) + assert.Equal(t, env.Config(), child.Config()) + cancel() + + require.ErrorIs(t, child.Err(), context.Canceled) + require.NoError(t, env.Err()) +} + func TestNewEnv(t *testing.T) { const ( testProjectRoot = "/non/existent/dir" diff --git a/internal/rpm/mock/mock.go b/internal/rpm/mock/mock.go index 566aa4973..a38a2f979 100644 --- a/internal/rpm/mock/mock.go +++ b/internal/rpm/mock/mock.go @@ -46,9 +46,10 @@ type Runner struct { // Verbosity verbose bool - mockConfigPath string - bindMounts []bindMountRequest - enableNetwork bool + mockConfigPath string + uniqueExtension string + bindMounts []bindMountRequest + enableNetwork bool // noPreClean requests that the root *not* be cleaned on command execution, even if mock deems // it ought to be. @@ -90,31 +91,33 @@ type bindMountRequest struct { // Constructs a new [Runner] that can be used to invoke mock. func NewRunner(ctx opctx.Ctx, mockConfigPath string) *Runner { return &Runner{ - fs: ctx.FS(), - osEnv: ctx.OSEnv(), - cmdFactory: ctx, - eventListener: ctx, - verbose: ctx.Verbose(), - mockConfigPath: mockConfigPath, + fs: ctx.FS(), + osEnv: ctx.OSEnv(), + cmdFactory: ctx, + eventListener: ctx, + verbose: ctx.Verbose(), + mockConfigPath: mockConfigPath, + uniqueExtension: newUniqueExtension(ctx), } } // Clone creates a deep copy of the provided [Runner] instance. func (r *Runner) Clone() *Runner { return &Runner{ - fs: r.fs, - osEnv: r.osEnv, - cmdFactory: r.cmdFactory, - eventListener: r.eventListener, - verbose: r.verbose, - mockConfigPath: r.mockConfigPath, - bindMounts: deep.MustCopy(r.bindMounts), - enableNetwork: r.enableNetwork, - noPreClean: r.noPreClean, - unprivileged: r.unprivileged, - baseDir: r.baseDir, - rootDir: r.rootDir, - configOpts: deep.MustCopy(r.configOpts), + fs: r.fs, + osEnv: r.osEnv, + cmdFactory: r.cmdFactory, + eventListener: r.eventListener, + verbose: r.verbose, + mockConfigPath: r.mockConfigPath, + uniqueExtension: r.uniqueExtension, + bindMounts: deep.MustCopy(r.bindMounts), + enableNetwork: r.enableNetwork, + noPreClean: r.noPreClean, + unprivileged: r.unprivileged, + baseDir: r.baseDir, + rootDir: r.rootDir, + configOpts: deep.MustCopy(r.configOpts), } } @@ -221,6 +224,11 @@ func (r *Runner) ConfigPath() string { return r.mockConfigPath } +// UniqueExtension returns the mock root extension, or empty when unique roots are disabled. +func (r *Runner) UniqueExtension() string { + return r.uniqueExtension +} + // InitRoot initializes a mock root. func (r *Runner) InitRoot(ctx context.Context) (err error) { slog.Debug("Initializing mock root", "dir", r.rootDir) @@ -665,7 +673,11 @@ func (r *Runner) getBaseArgs() (args []string) { } args = append(args, "-r", r.mockConfigPath) + args = append(args, "--configdir", filepath.Dir(r.mockConfigPath)) + if r.uniqueExtension != "" { + args = append(args, "--uniqueext", r.uniqueExtension) + } if r.baseDir != "" { args = append(args, "--config-opts", "basedir="+r.baseDir) diff --git a/internal/rpm/mock/uniqueroot.go b/internal/rpm/mock/uniqueroot.go new file mode 100644 index 000000000..5b8ce59dd --- /dev/null +++ b/internal/rpm/mock/uniqueroot.go @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package mock + +import ( + "context" + "crypto/rand" + "strconv" + "strings" +) + +type uniqueRootKey struct{} + +const ( + maxUniqueExtensionLength = 24 + uniqueRandomLength = 6 + maxRootActionLength = 4 + maxRootActionWithoutComponents = 8 + maxRootComponentLength = maxUniqueExtensionLength - maxRootActionLength - uniqueRandomLength - 2 +) + +type uniqueRootOptions struct { + enabled bool + action string + components []string +} + +// WithUniqueRoots configures newly created runners to use distinct mock roots. +func WithUniqueRoots(ctx context.Context, enabled bool, action string) context.Context { + return context.WithValue(ctx, uniqueRootKey{}, uniqueRootOptions{ + enabled: enabled, + action: action, + }) +} + +// WithRootComponents specializes the component label for newly created runners, +// without changing whether unique roots are enabled. +func WithRootComponents(ctx context.Context, components ...string) context.Context { + options, _ := ctx.Value(uniqueRootKey{}).(uniqueRootOptions) + + options.components = append([]string(nil), components...) + + return context.WithValue(ctx, uniqueRootKey{}, options) +} + +func newUniqueExtension(ctx context.Context) string { + options, _ := ctx.Value(uniqueRootKey{}).(uniqueRootOptions) + if !options.enabled { + return "" + } + + action := rootAction(options.action) + + label := action[:min(len(action), maxRootActionWithoutComponents)] + if len(options.components) > 0 { + action = action[:min(len(action), maxRootActionLength)] + component := rootLabel(options.components[0]) + + componentLabel := component[:min(len(component), maxRootComponentLength)] + if len(options.components) > 1 { + count := strconv.Itoa(len(options.components)) + + batchLabel := component[:min(len(component), 1)] + "_" + count + if len(batchLabel) <= maxRootComponentLength { + componentLabel = batchLabel + } + } + + label = action + "-" + componentLabel + } + + // Reserve six random base32 characters and a separator within the 24-byte limit. + return label + "-" + strings.ToLower(rand.Text()[:uniqueRandomLength]) +} + +func rootAction(action string) string { + action = rootLabel(action) + switch action { + case "build", "build-rpms": + return "bld" + case "render": + return "rndr" + case "query": + return "qry" + case "shell": + return "shl" + case "": + return "mock" + default: + return action + } +} + +func rootLabel(value string) string { + value = strings.ToLower(value) + value = strings.Map(func(char rune) rune { + if char >= 'a' && char <= 'z' || char >= '0' && char <= '9' || char == '_' || char == '-' { + return char + } + + return '-' + }, value) + + return strings.Trim(value, "-_") +} diff --git a/internal/rpm/mock/uniqueroot_test.go b/internal/rpm/mock/uniqueroot_test.go new file mode 100644 index 000000000..b57a1dc95 --- /dev/null +++ b/internal/rpm/mock/uniqueroot_test.go @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package mock_test + +import ( + "os/exec" + "slices" + "strings" + "testing" + + "github.com/microsoft/azure-linux-dev-tools/internal/rpm/mock" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestUniqueExtensionLabels(t *testing.T) { + tests := []struct { + name string + action string + components []string + prefix string + }{ + {name: "shell without packages", action: "shell", prefix: "shl-"}, + {name: "shell with packages", action: "shell", components: []string{"curl"}, prefix: "shl-curl-"}, + {name: "build without components", action: "build", prefix: "bld-"}, + {name: "build with one component", action: "build", components: []string{"curl"}, prefix: "bld-curl-"}, + {name: "advanced build", action: "build-rpms", components: []string{"curl"}, prefix: "bld-curl-"}, + {name: "render without components", action: "render", prefix: "rndr-"}, + {name: "render with one component", action: "render", components: []string{"curl"}, prefix: "rndr-curl-"}, + {name: "query without components", action: "query", prefix: "qry-"}, + {name: "query with one component", action: "query", components: []string{"curl"}, prefix: "qry-curl-"}, + { + name: "exact middle field and total limits", action: "render", + components: []string{"abcdefghijkl"}, prefix: "rndr-abcdefghijkl-", + }, + { + name: "middle field over limit", action: "render", + components: []string{"abcdefghijklm"}, prefix: "rndr-abcdefghijkl-", + }, + { + name: "middle field capped with shorter action", action: "build", + components: []string{"abcdefghijklm"}, prefix: "bld-abcdefghijkl-", + }, + { + name: "multiple components", action: "render", + components: []string{"curl", "zlib"}, prefix: "rndr-c_2-", + }, + { + name: "large batch", action: "render", + components: append([]string{"curl"}, make([]string, 999)...), prefix: "rndr-c_1000-", + }, + { + name: "large shell package list", action: "shell", + components: append([]string{"curl"}, make([]string, 999)...), prefix: "shl-c_1000-", + }, + { + name: "two digit batch count", action: "build", + components: append([]string{"curl"}, make([]string, 9)...), prefix: "bld-c_10-", + }, + { + name: "three digit batch count", action: "build", + components: append([]string{"curl"}, make([]string, 99)...), prefix: "bld-c_100-", + }, + { + name: "long component label", action: "query", + components: []string{strings.Repeat("rust-component", 10)}, prefix: "qry-rust-compone-", + }, + {name: "long action without components", action: "build-source-rpms", prefix: "build-so-"}, + {name: "allowed character boundaries", action: "AZ_az-09", prefix: "az_az-09-"}, + { + name: "unsafe characters", action: "BUILD", components: []string{"a/b \t\u00e9"}, + prefix: "bld-a-b-", + }, + {name: "empty action", prefix: "mock-"}, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ctx := newTestCtxWithMockPrereqsPresent() + ctx.Ctx = mock.WithUniqueRoots(ctx.Ctx, true, test.action) + ctx.Ctx = mock.WithRootComponents(ctx.Ctx, test.components...) + + runner := mock.NewRunner(ctx, testMockConfigPath) + extension := runner.UniqueExtension() + + assert.LessOrEqual(t, len(extension), 24) + assert.Regexp(t, `^[a-z0-9_-]+$`, extension) + assert.True(t, strings.HasPrefix(extension, test.prefix), extension) + assert.Regexp(t, `^[a-z2-7]{6}$`, strings.TrimPrefix(extension, test.prefix)) + }) + } +} + +func TestUniqueExtensionLifecycle(t *testing.T) { + ctx := newTestCtxWithMockPrereqsPresent() + ctx.Ctx = mock.WithUniqueRoots(ctx.Ctx, true, "build") + ctx.Ctx = mock.WithRootComponents(ctx.Ctx, "curl") + + var extensions []string + + capture := func(cmd *exec.Cmd) { + t.Helper() + + index := slices.Index(cmd.Args, "--uniqueext") + require.Positive(t, index) + require.Less(t, index+1, len(cmd.Args)) + extensions = append(extensions, cmd.Args[index+1]) + } + ctx.CmdFactory.RunHandler = func(cmd *exec.Cmd) error { + capture(cmd) + + return nil + } + ctx.CmdFactory.RunAndGetOutputHandler = func(cmd *exec.Cmd) (string, error) { + capture(cmd) + + return testMockRootPath, nil + } + + runner := mock.NewRunner(ctx, testMockConfigPath) + require.NoError(t, runner.InitRoot(ctx)) + require.NoError(t, runner.InstallPackages(ctx, []string{"rpm-build"})) + require.NoError(t, runner.BuildSRPM(ctx, testSpecPath, testSourceDirPath, testOutputDirPath, mock.SRPMBuildOptions{})) + require.NoError(t, runner.BuildRPM(ctx, testSRPMPath, testOutputDirPath, mock.RPMBuildOptions{})) + _, err := runner.GetRootPath(ctx) + require.NoError(t, err) + + cmd, err := runner.Clone().CmdInChroot(ctx, []string{"true"}, false) + require.NoError(t, err) + require.NoError(t, cmd.Run(ctx)) + require.NoError(t, runner.Clone().ScrubRoot(ctx)) + + require.Len(t, extensions, 7) + + for _, extension := range extensions { + assert.Equal(t, runner.UniqueExtension(), extension) + } + + assert.NotEqual(t, runner.UniqueExtension(), mock.NewRunner(ctx, testMockConfigPath).UniqueExtension()) +} + +func TestUniqueExtensionDisabled(t *testing.T) { + for name, explicitlyDisabled := range map[string]bool{"default": false, "explicit": true} { + t.Run(name, func(t *testing.T) { + ctx := newTestCtxWithMockPrereqsPresent() + if explicitlyDisabled { + ctx.Ctx = mock.WithUniqueRoots(ctx.Ctx, false, "build") + } + + ctx.Ctx = mock.WithRootComponents(ctx.Ctx, "curl") + ctx.CmdFactory.RunHandler = func(cmd *exec.Cmd) error { + assert.NotContains(t, cmd.Args, "--uniqueext") + + return nil + } + + runner := mock.NewRunner(ctx, testMockConfigPath) + assert.Empty(t, runner.UniqueExtension()) + require.NoError(t, runner.InitRoot(ctx)) + }) + } +} diff --git a/scenario/__snapshots__/TestSnapshotsContainer_--bogus-flag_stderr_1.snap b/scenario/__snapshots__/TestSnapshotsContainer_--bogus-flag_stderr_1.snap index 6832b09a4..79a84ba98 100755 --- a/scenario/__snapshots__/TestSnapshotsContainer_--bogus-flag_stderr_1.snap +++ b/scenario/__snapshots__/TestSnapshotsContainer_--bogus-flag_stderr_1.snap @@ -29,6 +29,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshotsContainer_--help_stdout_1.snap b/scenario/__snapshots__/TestSnapshotsContainer_--help_stdout_1.snap index e15aef19c..5f985e03e 100755 --- a/scenario/__snapshots__/TestSnapshotsContainer_--help_stdout_1.snap +++ b/scenario/__snapshots__/TestSnapshotsContainer_--help_stdout_1.snap @@ -36,6 +36,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshotsContainer_help_stdout_1.snap b/scenario/__snapshots__/TestSnapshotsContainer_help_stdout_1.snap index e15aef19c..5f985e03e 100755 --- a/scenario/__snapshots__/TestSnapshotsContainer_help_stdout_1.snap +++ b/scenario/__snapshots__/TestSnapshotsContainer_help_stdout_1.snap @@ -36,6 +36,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshots_--bogus-flag_stderr_1.snap b/scenario/__snapshots__/TestSnapshots_--bogus-flag_stderr_1.snap index 6832b09a4..79a84ba98 100755 --- a/scenario/__snapshots__/TestSnapshots_--bogus-flag_stderr_1.snap +++ b/scenario/__snapshots__/TestSnapshots_--bogus-flag_stderr_1.snap @@ -29,6 +29,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshots_--help_stdout_1.snap b/scenario/__snapshots__/TestSnapshots_--help_stdout_1.snap index e15aef19c..5f985e03e 100755 --- a/scenario/__snapshots__/TestSnapshots_--help_stdout_1.snap +++ b/scenario/__snapshots__/TestSnapshots_--help_stdout_1.snap @@ -36,6 +36,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshots_--help_with_color_stdout_1.snap b/scenario/__snapshots__/TestSnapshots_--help_with_color_stdout_1.snap index 4a47c31e2..3501c447d 100755 --- a/scenario/__snapshots__/TestSnapshots_--help_with_color_stdout_1.snap +++ b/scenario/__snapshots__/TestSnapshots_--help_with_color_stdout_1.snap @@ -36,6 +36,7 @@ Meta commands: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshots_help_stdout_1.snap b/scenario/__snapshots__/TestSnapshots_help_stdout_1.snap index e15aef19c..5f985e03e 100755 --- a/scenario/__snapshots__/TestSnapshots_help_stdout_1.snap +++ b/scenario/__snapshots__/TestSnapshots_help_stdout_1.snap @@ -36,6 +36,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files From 907ab915efc44cc74a2444db583785aafc1e34a8 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Tue, 10 Nov 2026 15:50:05 +0000 Subject: [PATCH 2/8] fix(mock): clean up unique bootstrap roots and init unique shells Address review feedback on unique mock roots: - Scrub the bootstrap root along with the main chroot when a unique extension is in use, since mock gives the bootstrap root a unique name too and nothing would reuse or remove it later. - Initialize the fresh unique root before entering `mock --shell` when no packages are being installed, as mock requires an initialized chroot for shell mode. - Add the unique-mockroot flag to the MCP tools/list snapshot. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6a5e36c4-2d25-42f4-8047-ba75293d4a6c --- internal/app/azldev/cmds/advanced/mock.go | 6 ++ internal/rpm/mock/mock.go | 6 ++ .../TestMCPServerMode_1.snap.json | 55 +++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/internal/app/azldev/cmds/advanced/mock.go b/internal/app/azldev/cmds/advanced/mock.go index 660582a60..fad7da562 100644 --- a/internal/app/azldev/cmds/advanced/mock.go +++ b/internal/app/azldev/cmds/advanced/mock.go @@ -191,6 +191,12 @@ func RunShell(env *azldev.Env, options *ShellOptions, extraArgs []string) error if err != nil { return fmt.Errorf("failed to install packages in mock root (%v): %w", options.PackagesToAdd, err) } + } else if runner.UniqueExtension() != "" { + // A unique root is brand new, and mock requires an initialized root for shell mode. + err = runner.InitRoot(env) + if err != nil { + return fmt.Errorf("failed to initialize mock root: %w", err) + } } cmd, err := runner.CmdInChroot(env, extraArgs, true /*interactive*/) diff --git a/internal/rpm/mock/mock.go b/internal/rpm/mock/mock.go index a38a2f979..4f79cb2fa 100644 --- a/internal/rpm/mock/mock.go +++ b/internal/rpm/mock/mock.go @@ -637,6 +637,12 @@ func (r *Runner) ScrubRoot(ctx context.Context) error { mockArgs = append(mockArgs, "--scrub", "chroot") } + // A unique extension gives the bootstrap root a unique name too, so it would never be reused + // or cleaned up by a later invocation. + if r.uniqueExtension != "" && r.baseDir == "" { + mockArgs = append(mockArgs, "--scrub", "bootstrap") + } + cmd := exec.CommandContext(ctx, MockBinary, mockArgs...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr diff --git a/scenario/__snapshots__/TestMCPServerMode_1.snap.json b/scenario/__snapshots__/TestMCPServerMode_1.snap.json index 663b83ff7..70bd5fc4e 100755 --- a/scenario/__snapshots__/TestMCPServerMode_1.snap.json +++ b/scenario/__snapshots__/TestMCPServerMode_1.snap.json @@ -101,6 +101,11 @@ "description": "Git ref to compare to", "type": "string" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", @@ -212,6 +217,11 @@ "description": "Spec path", "type": "string" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", @@ -321,6 +331,11 @@ "description": "Spec path", "type": "string" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", @@ -420,6 +435,11 @@ "description": "Spec path", "type": "string" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", @@ -539,6 +559,11 @@ "description": "only include entries whose metadata declares this upstream status ('upstreamed', 'upstreamable', 'needs-upstream-hook', 'inapplicable', or 'unknown')", "type": "string" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", @@ -621,6 +646,11 @@ "description": "only enable minimal output", "type": "boolean" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", @@ -699,6 +729,11 @@ "description": "only enable minimal output", "type": "boolean" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", @@ -782,6 +817,11 @@ "description": "skill to print", "type": "string" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", @@ -875,6 +915,11 @@ "description": "only enable minimal output", "type": "boolean" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", @@ -955,6 +1000,11 @@ "description": "only enable minimal output", "type": "boolean" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", @@ -1052,6 +1102,11 @@ "description": "Also synthesize '-debuginfo' packages (per reported package) and '-debugsource' packages (per component)", "type": "boolean" }, + "unique-mockroot": { + "default": false, + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "type": "boolean" + }, "verbose": { "default": false, "description": "enable verbose output", From 4f6141a854d15e9c422ff560cc97656ff040e88e Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Tue, 10 Nov 2026 16:07:34 +0000 Subject: [PATCH 3/8] test(scenario): fix MCP snapshot flag ordering Regenerate TestMCPServerMode_1.snap.json so the unique-mockroot property is in the order emitted by the MCP tool schema. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 077c559f-4c80-4bff-86f8-1841925e81b3 --- scenario/__snapshots__/TestMCPServerMode_1.snap.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scenario/__snapshots__/TestMCPServerMode_1.snap.json b/scenario/__snapshots__/TestMCPServerMode_1.snap.json index 70bd5fc4e..5a8773a94 100755 --- a/scenario/__snapshots__/TestMCPServerMode_1.snap.json +++ b/scenario/__snapshots__/TestMCPServerMode_1.snap.json @@ -554,16 +554,16 @@ "description": "Spec path", "type": "string" }, - "upstream-status": { - "default": "", - "description": "only include entries whose metadata declares this upstream status ('upstreamed', 'upstreamable', 'needs-upstream-hook', 'inapplicable', or 'unknown')", - "type": "string" - }, "unique-mockroot": { "default": false, "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", "type": "boolean" }, + "upstream-status": { + "default": "", + "description": "only include entries whose metadata declares this upstream status ('upstreamed', 'upstreamable', 'needs-upstream-hook', 'inapplicable', or 'unknown')", + "type": "string" + }, "verbose": { "default": false, "description": "enable verbose output", From 3d103988a99cc3bce06fe5e6aa364db0ec2506b8 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Tue, 10 Nov 2026 18:43:05 +0000 Subject: [PATCH 4/8] feat(build): build components concurrently with --unique-mockroot When --unique-mockroot is set, 'component build' now builds multiple components in parallel, each with its own mock processor and mock root, bounded by the CPU-bound concurrency limit. Builds stay sequential for a single component or when --local-repo-with-publish is used, since publishing requires ordered builds and mutates shared repo metadata. Add env.UniqueMockRootEnabled() and mock.UniqueRootsEnabled(), update the flag help text, and regenerate CLI docs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 36bd7f34-6b81-42da-b6a1-af2040d23322 --- docs/user/reference/cli/azldev.md | 2 +- docs/user/reference/cli/azldev_advanced.md | 2 +- .../cli/azldev_advanced_download-sources.md | 2 +- .../user/reference/cli/azldev_advanced_mcp.md | 2 +- .../reference/cli/azldev_advanced_mock.md | 2 +- .../cli/azldev_advanced_mock_build-rpms.md | 2 +- .../cli/azldev_advanced_mock_shell.md | 2 +- .../reference/cli/azldev_advanced_wget.md | 2 +- docs/user/reference/cli/azldev_completion.md | 2 +- .../reference/cli/azldev_completion_bash.md | 2 +- .../reference/cli/azldev_completion_fish.md | 2 +- .../cli/azldev_completion_powershell.md | 2 +- .../reference/cli/azldev_completion_zsh.md | 2 +- docs/user/reference/cli/azldev_component.md | 2 +- .../reference/cli/azldev_component_add.md | 2 +- .../reference/cli/azldev_component_build.md | 2 +- .../reference/cli/azldev_component_changed.md | 2 +- .../cli/azldev_component_diff-sources.md | 2 +- .../reference/cli/azldev_component_history.md | 2 +- .../reference/cli/azldev_component_list.md | 2 +- .../cli/azldev_component_metadata.md | 2 +- .../cli/azldev_component_prepare-sources.md | 2 +- .../reference/cli/azldev_component_query.md | 2 +- .../reference/cli/azldev_component_render.md | 2 +- .../reference/cli/azldev_component_test.md | 2 +- .../reference/cli/azldev_component_update.md | 2 +- docs/user/reference/cli/azldev_config.md | 2 +- docs/user/reference/cli/azldev_config_dump.md | 2 +- .../cli/azldev_config_generate-schema.md | 2 +- docs/user/reference/cli/azldev_docs.md | 2 +- docs/user/reference/cli/azldev_docs_agent.md | 2 +- .../cli/azldev_docs_agent_install.md | 2 +- .../reference/cli/azldev_docs_agent_show.md | 2 +- .../reference/cli/azldev_docs_markdown.md | 2 +- docs/user/reference/cli/azldev_image.md | 2 +- docs/user/reference/cli/azldev_image_boot.md | 2 +- docs/user/reference/cli/azldev_image_build.md | 2 +- .../reference/cli/azldev_image_customize.md | 2 +- .../cli/azldev_image_inject-files.md | 2 +- docs/user/reference/cli/azldev_image_list.md | 2 +- docs/user/reference/cli/azldev_image_test.md | 2 +- docs/user/reference/cli/azldev_package.md | 2 +- .../user/reference/cli/azldev_package_list.md | 2 +- docs/user/reference/cli/azldev_project.md | 2 +- .../user/reference/cli/azldev_project_init.md | 2 +- docs/user/reference/cli/azldev_project_new.md | 2 +- docs/user/reference/cli/azldev_repo.md | 2 +- .../user/reference/cli/azldev_repo_compare.md | 2 +- docs/user/reference/cli/azldev_repo_query.md | 2 +- docs/user/reference/cli/azldev_version.md | 2 +- internal/app/azldev/app.go | 3 +- internal/app/azldev/cmds/component/build.go | 69 +++++++++++++++++++ internal/app/azldev/env.go | 5 ++ internal/rpm/mock/uniqueroot.go | 7 ++ 54 files changed, 133 insertions(+), 51 deletions(-) diff --git a/docs/user/reference/cli/azldev.md b/docs/user/reference/cli/azldev.md index a3ceb9dfc..3c4f94887 100644 --- a/docs/user/reference/cli/azldev.md +++ b/docs/user/reference/cli/azldev.md @@ -29,7 +29,7 @@ lives), or use -C to point to one. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced.md b/docs/user/reference/cli/azldev_advanced.md index ef8efb670..2342a086a 100644 --- a/docs/user/reference/cli/azldev_advanced.md +++ b/docs/user/reference/cli/azldev_advanced.md @@ -32,7 +32,7 @@ output but fully supported. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_download-sources.md b/docs/user/reference/cli/azldev_advanced_download-sources.md index aa14ee1db..f055a4822 100644 --- a/docs/user/reference/cli/azldev_advanced_download-sources.md +++ b/docs/user/reference/cli/azldev_advanced_download-sources.md @@ -70,7 +70,7 @@ azldev advanced download-sources [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_mcp.md b/docs/user/reference/cli/azldev_advanced_mcp.md index 3d4c384ac..a38d2dc1a 100644 --- a/docs/user/reference/cli/azldev_advanced_mcp.md +++ b/docs/user/reference/cli/azldev_advanced_mcp.md @@ -43,7 +43,7 @@ azldev advanced mcp [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_mock.md b/docs/user/reference/cli/azldev_advanced_mock.md index 2a1005d70..919e6217f 100644 --- a/docs/user/reference/cli/azldev_advanced_mock.md +++ b/docs/user/reference/cli/azldev_advanced_mock.md @@ -31,7 +31,7 @@ starting interactive shell sessions in mock chroot environments. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_mock_build-rpms.md b/docs/user/reference/cli/azldev_advanced_mock_build-rpms.md index 533f22ac6..82fb0fa02 100644 --- a/docs/user/reference/cli/azldev_advanced_mock_build-rpms.md +++ b/docs/user/reference/cli/azldev_advanced_mock_build-rpms.md @@ -50,7 +50,7 @@ azldev advanced mock build-rpms [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_mock_shell.md b/docs/user/reference/cli/azldev_advanced_mock_shell.md index f63dd2c4a..92e54bbff 100644 --- a/docs/user/reference/cli/azldev_advanced_mock_shell.md +++ b/docs/user/reference/cli/azldev_advanced_mock_shell.md @@ -55,7 +55,7 @@ azldev advanced mock shell [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_advanced_wget.md b/docs/user/reference/cli/azldev_advanced_wget.md index eaa056ba5..520f01533 100644 --- a/docs/user/reference/cli/azldev_advanced_wget.md +++ b/docs/user/reference/cli/azldev_advanced_wget.md @@ -44,7 +44,7 @@ azldev advanced wget URI [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_completion.md b/docs/user/reference/cli/azldev_completion.md index 8abc5a6d0..dcfde1a97 100644 --- a/docs/user/reference/cli/azldev_completion.md +++ b/docs/user/reference/cli/azldev_completion.md @@ -30,7 +30,7 @@ See each sub-command's help for details on how to use the generated script. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_completion_bash.md b/docs/user/reference/cli/azldev_completion_bash.md index b5f95ac1d..179f83df4 100644 --- a/docs/user/reference/cli/azldev_completion_bash.md +++ b/docs/user/reference/cli/azldev_completion_bash.md @@ -53,7 +53,7 @@ azldev completion bash --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_completion_fish.md b/docs/user/reference/cli/azldev_completion_fish.md index 2a137634d..d493f8153 100644 --- a/docs/user/reference/cli/azldev_completion_fish.md +++ b/docs/user/reference/cli/azldev_completion_fish.md @@ -44,7 +44,7 @@ azldev completion fish [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_completion_powershell.md b/docs/user/reference/cli/azldev_completion_powershell.md index 998cab5d1..af5b066e2 100644 --- a/docs/user/reference/cli/azldev_completion_powershell.md +++ b/docs/user/reference/cli/azldev_completion_powershell.md @@ -41,7 +41,7 @@ azldev completion powershell [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_completion_zsh.md b/docs/user/reference/cli/azldev_completion_zsh.md index ad71d5fc1..3ec225a07 100644 --- a/docs/user/reference/cli/azldev_completion_zsh.md +++ b/docs/user/reference/cli/azldev_completion_zsh.md @@ -55,7 +55,7 @@ azldev completion zsh [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component.md b/docs/user/reference/cli/azldev_component.md index 0e6f08f2a..7126c74f2 100644 --- a/docs/user/reference/cli/azldev_component.md +++ b/docs/user/reference/cli/azldev_component.md @@ -34,7 +34,7 @@ components defined in the project configuration. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_add.md b/docs/user/reference/cli/azldev_component_add.md index d951425e3..8e3a82f7e 100644 --- a/docs/user/reference/cli/azldev_component_add.md +++ b/docs/user/reference/cli/azldev_component_add.md @@ -47,7 +47,7 @@ azldev component add [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_build.md b/docs/user/reference/cli/azldev_component_build.md index ee33a04d0..e51b73a20 100644 --- a/docs/user/reference/cli/azldev_component_build.md +++ b/docs/user/reference/cli/azldev_component_build.md @@ -79,7 +79,7 @@ azldev component build [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_changed.md b/docs/user/reference/cli/azldev_component_changed.md index 717859431..9371218f4 100644 --- a/docs/user/reference/cli/azldev_component_changed.md +++ b/docs/user/reference/cli/azldev_component_changed.md @@ -69,7 +69,7 @@ azldev component changed [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_diff-sources.md b/docs/user/reference/cli/azldev_component_diff-sources.md index ff52d20d1..83580b9e3 100644 --- a/docs/user/reference/cli/azldev_component_diff-sources.md +++ b/docs/user/reference/cli/azldev_component_diff-sources.md @@ -41,7 +41,7 @@ azldev component diff-sources [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_history.md b/docs/user/reference/cli/azldev_component_history.md index c5b33a3fd..48f70d71d 100644 --- a/docs/user/reference/cli/azldev_component_history.md +++ b/docs/user/reference/cli/azldev_component_history.md @@ -67,7 +67,7 @@ azldev component history [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_list.md b/docs/user/reference/cli/azldev_component_list.md index 4282bdc06..1d121f8a4 100644 --- a/docs/user/reference/cli/azldev_component_list.md +++ b/docs/user/reference/cli/azldev_component_list.md @@ -56,7 +56,7 @@ azldev component list [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_metadata.md b/docs/user/reference/cli/azldev_component_metadata.md index febaed932..6f9fd82e4 100644 --- a/docs/user/reference/cli/azldev_component_metadata.md +++ b/docs/user/reference/cli/azldev_component_metadata.md @@ -82,7 +82,7 @@ azldev component metadata [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_prepare-sources.md b/docs/user/reference/cli/azldev_component_prepare-sources.md index 337dfcfce..5426ca569 100644 --- a/docs/user/reference/cli/azldev_component_prepare-sources.md +++ b/docs/user/reference/cli/azldev_component_prepare-sources.md @@ -62,7 +62,7 @@ azldev component prepare-sources [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_query.md b/docs/user/reference/cli/azldev_component_query.md index 516e68e9d..194929f92 100644 --- a/docs/user/reference/cli/azldev_component_query.md +++ b/docs/user/reference/cli/azldev_component_query.md @@ -59,7 +59,7 @@ azldev component query [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_render.md b/docs/user/reference/cli/azldev_component_render.md index de7aded11..7c3c3acee 100644 --- a/docs/user/reference/cli/azldev_component_render.md +++ b/docs/user/reference/cli/azldev_component_render.md @@ -82,7 +82,7 @@ azldev component render [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_test.md b/docs/user/reference/cli/azldev_component_test.md index 5ae0631fa..a1c3d7406 100644 --- a/docs/user/reference/cli/azldev_component_test.md +++ b/docs/user/reference/cli/azldev_component_test.md @@ -108,7 +108,7 @@ azldev component test COMPONENT [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_component_update.md b/docs/user/reference/cli/azldev_component_update.md index 8fedc7450..5db10cdb7 100644 --- a/docs/user/reference/cli/azldev_component_update.md +++ b/docs/user/reference/cli/azldev_component_update.md @@ -83,7 +83,7 @@ azldev component update [flags] -C, --project string path to Azure Linux project -q, --quiet only enable minimal output --spec-editor editor Select the RPM spec editor (legacy or experimental) (default legacy) - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_config.md b/docs/user/reference/cli/azldev_config.md index d785322cf..a1f09a356 100644 --- a/docs/user/reference/cli/azldev_config.md +++ b/docs/user/reference/cli/azldev_config.md @@ -31,7 +31,7 @@ JSON schema used for validating TOML config files. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_config_dump.md b/docs/user/reference/cli/azldev_config_dump.md index 9520c1fe7..e4c74b1ef 100644 --- a/docs/user/reference/cli/azldev_config_dump.md +++ b/docs/user/reference/cli/azldev_config_dump.md @@ -51,7 +51,7 @@ azldev config dump [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_config_generate-schema.md b/docs/user/reference/cli/azldev_config_generate-schema.md index 839ba3991..d8ea8fe77 100644 --- a/docs/user/reference/cli/azldev_config_generate-schema.md +++ b/docs/user/reference/cli/azldev_config_generate-schema.md @@ -45,7 +45,7 @@ azldev config generate-schema [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_docs.md b/docs/user/reference/cli/azldev_docs.md index 2023bffa1..4a0d52176 100644 --- a/docs/user/reference/cli/azldev_docs.md +++ b/docs/user/reference/cli/azldev_docs.md @@ -31,7 +31,7 @@ command tree, suitable for inclusion in the user guide. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_docs_agent.md b/docs/user/reference/cli/azldev_docs_agent.md index 3e96e200e..0b7b0f2f3 100644 --- a/docs/user/reference/cli/azldev_docs_agent.md +++ b/docs/user/reference/cli/azldev_docs_agent.md @@ -33,7 +33,7 @@ reference so that agents always load the guidance that ships with the binary. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_docs_agent_install.md b/docs/user/reference/cli/azldev_docs_agent_install.md index fa56e5407..127f5ef6e 100644 --- a/docs/user/reference/cli/azldev_docs_agent_install.md +++ b/docs/user/reference/cli/azldev_docs_agent_install.md @@ -73,7 +73,7 @@ azldev docs agent install [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_docs_agent_show.md b/docs/user/reference/cli/azldev_docs_agent_show.md index db7739a3c..289100501 100644 --- a/docs/user/reference/cli/azldev_docs_agent_show.md +++ b/docs/user/reference/cli/azldev_docs_agent_show.md @@ -50,7 +50,7 @@ azldev docs agent show [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_docs_markdown.md b/docs/user/reference/cli/azldev_docs_markdown.md index 6fe0bbafc..38d5da719 100644 --- a/docs/user/reference/cli/azldev_docs_markdown.md +++ b/docs/user/reference/cli/azldev_docs_markdown.md @@ -52,7 +52,7 @@ azldev docs markdown [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image.md b/docs/user/reference/cli/azldev_image.md index 892ad319c..b09e8a497 100644 --- a/docs/user/reference/cli/azldev_image.md +++ b/docs/user/reference/cli/azldev_image.md @@ -32,7 +32,7 @@ can be customized using Azure Linux Image Customizer. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_boot.md b/docs/user/reference/cli/azldev_image_boot.md index 66898d187..4941a6ad8 100644 --- a/docs/user/reference/cli/azldev_image_boot.md +++ b/docs/user/reference/cli/azldev_image_boot.md @@ -96,7 +96,7 @@ azldev image boot [IMAGE_NAME] [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_build.md b/docs/user/reference/cli/azldev_image_build.md index c563e340d..3c9ca710d 100644 --- a/docs/user/reference/cli/azldev_image_build.md +++ b/docs/user/reference/cli/azldev_image_build.md @@ -57,7 +57,7 @@ azldev image build [image-name] [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_customize.md b/docs/user/reference/cli/azldev_image_customize.md index 593e6b410..6f97e43cb 100644 --- a/docs/user/reference/cli/azldev_image_customize.md +++ b/docs/user/reference/cli/azldev_image_customize.md @@ -55,7 +55,7 @@ azldev image customize [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_inject-files.md b/docs/user/reference/cli/azldev_image_inject-files.md index d4eeb7b6c..707f6adf2 100644 --- a/docs/user/reference/cli/azldev_image_inject-files.md +++ b/docs/user/reference/cli/azldev_image_inject-files.md @@ -46,7 +46,7 @@ azldev image inject-files [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_list.md b/docs/user/reference/cli/azldev_image_list.md index edfb25fef..db6053b18 100644 --- a/docs/user/reference/cli/azldev_image_list.md +++ b/docs/user/reference/cli/azldev_image_list.md @@ -48,7 +48,7 @@ azldev image list [image-name-pattern...] [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_image_test.md b/docs/user/reference/cli/azldev_image_test.md index d0be33dc8..fe3bacf48 100644 --- a/docs/user/reference/cli/azldev_image_test.md +++ b/docs/user/reference/cli/azldev_image_test.md @@ -81,7 +81,7 @@ azldev image test IMAGE_NAME [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_package.md b/docs/user/reference/cli/azldev_package.md index b86f27d6c..10534a12a 100644 --- a/docs/user/reference/cli/azldev_package.md +++ b/docs/user/reference/cli/azldev_package.md @@ -32,7 +32,7 @@ publish channel assignments derived from package groups and component overrides. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_package_list.md b/docs/user/reference/cli/azldev_package_list.md index 4f7f49d06..39574b56e 100644 --- a/docs/user/reference/cli/azldev_package_list.md +++ b/docs/user/reference/cli/azldev_package_list.md @@ -81,7 +81,7 @@ azldev package list [package-name...] [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_project.md b/docs/user/reference/cli/azldev_project.md index 3481a66be..41ed95190 100644 --- a/docs/user/reference/cli/azldev_project.md +++ b/docs/user/reference/cli/azldev_project.md @@ -31,7 +31,7 @@ as an Azure Linux project with a basic configuration. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_project_init.md b/docs/user/reference/cli/azldev_project_init.md index ecb50394f..c80d18b63 100644 --- a/docs/user/reference/cli/azldev_project_init.md +++ b/docs/user/reference/cli/azldev_project_init.md @@ -42,7 +42,7 @@ azldev project init [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_project_new.md b/docs/user/reference/cli/azldev_project_new.md index 6c8677cfa..e273ad314 100644 --- a/docs/user/reference/cli/azldev_project_new.md +++ b/docs/user/reference/cli/azldev_project_new.md @@ -45,7 +45,7 @@ azldev project new PATH [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_repo.md b/docs/user/reference/cli/azldev_repo.md index 018ed58f3..efc106ef1 100644 --- a/docs/user/reference/cli/azldev_repo.md +++ b/docs/user/reference/cli/azldev_repo.md @@ -32,7 +32,7 @@ under one or more URL prefixes. --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_repo_compare.md b/docs/user/reference/cli/azldev_repo_compare.md index 8249d2c64..9ceb3df5a 100644 --- a/docs/user/reference/cli/azldev_repo_compare.md +++ b/docs/user/reference/cli/azldev_repo_compare.md @@ -50,7 +50,7 @@ azldev repo compare [flags] --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_repo_query.md b/docs/user/reference/cli/azldev_repo_query.md index 7a12a5bc5..d6c1e0d4f 100644 --- a/docs/user/reference/cli/azldev_repo_query.md +++ b/docs/user/reference/cli/azldev_repo_query.md @@ -73,7 +73,7 @@ azldev repo query [flags] -- --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/docs/user/reference/cli/azldev_version.md b/docs/user/reference/cli/azldev_version.md index 21666d793..309d83172 100644 --- a/docs/user/reference/cli/azldev_version.md +++ b/docs/user/reference/cli/azldev_version.md @@ -36,7 +36,7 @@ azldev version -O json --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --without-lockfile preview: track resolved upstream commits in generated config instead of lock files ``` diff --git a/internal/app/azldev/app.go b/internal/app/azldev/app.go index 3fa90076b..ef442a60a 100644 --- a/internal/app/azldev/app.go +++ b/internal/app/azldev/app.go @@ -196,7 +196,8 @@ func (app *App) registerGlobalFlags() { app.cmd.PersistentFlags().BoolVar(&app.withoutLockfile, "without-lockfile", false, "preview: track resolved upstream commits in generated config instead of lock files") app.cmd.PersistentFlags().BoolVar(&app.uniqueMockRoot, "unique-mockroot", false, - "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)") + "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); "+ + "allows 'component build' to build multiple components concurrently") } // addAdvancedCommandHint embeds a hint about the hidden "advanced" command group diff --git a/internal/app/azldev/cmds/component/build.go b/internal/app/azldev/cmds/component/build.go index f7139e60c..69b70d2db 100644 --- a/internal/app/azldev/cmds/component/build.go +++ b/internal/app/azldev/cmds/component/build.go @@ -4,6 +4,7 @@ package component import ( + "context" "errors" "fmt" "path/filepath" @@ -21,6 +22,7 @@ import ( "github.com/microsoft/azure-linux-dev-tools/internal/utils/defers" "github.com/microsoft/azure-linux-dev-tools/internal/utils/fileutils" "github.com/microsoft/azure-linux-dev-tools/internal/utils/localrepo" + "github.com/microsoft/azure-linux-dev-tools/internal/utils/parmap" "github.com/spf13/cobra" ) @@ -201,6 +203,13 @@ func BuildComponents( return nil, fmt.Errorf("failed to create work dir factory:\n%w", err) } + // Unique mock roots make concurrent builds safe. Publishing to a local repo requires + // builds to complete in order (later components may depend on earlier ones, and + // publishing mutates shared repo metadata), so it stays sequential. + if env.UniqueMockRootEnabled() && options.LocalRepoWithPublishPath == "" && components.Len() > 1 { + return buildComponentsConcurrently(env, components, workDirFactory, options) + } + env = env.WithMockRootComponents(components.Names()...) mockProcessor := createBuildMockProcessor(env) @@ -225,6 +234,66 @@ func BuildComponents( return results, err } +// buildComponentsConcurrently builds the components in parallel, each with its own +// mock root and mock processor. Results are returned in input order. +func buildComponentsConcurrently( + env *azldev.Env, + comps *components.ComponentSet, + workDirFactory *workdir.Factory, + options *ComponentBuildOptions, +) ([]ComponentBuildResults, error) { + workerEnv, cancel := env.WithCancel() + defer cancel() + + progressEvent := env.StartEvent("Building components", "count", comps.Len()) + defer progressEvent.End() + + type buildOutcome struct { + results ComponentBuildResults + err error + } + + allComponents := comps.Components() + total := int64(len(allComponents)) + + outcomes := parmap.Map( + workerEnv, + env.CPUBoundConcurrency(), + allComponents, + func(done, _ int) { progressEvent.SetProgress(int64(done), total) }, + func(_ context.Context, component components.Component) buildOutcome { + // workerEnv (captured) carries the cancellation context. + //nolint:contextcheck // env carries the ctx + componentResults, buildErr := BuildComponent(workerEnv, component, workDirFactory, options) + if buildErr != nil { + buildErr = fmt.Errorf("failed to build %q:\n%w", component.GetName(), buildErr) + + if !options.ContinueOnError { + cancel() + } + } + + return buildOutcome{results: componentResults, err: buildErr} + }, + ) + + results := make([]ComponentBuildResults, 0, len(outcomes)) + + var err error + + for _, outcome := range outcomes { + if outcome.Cancelled { + continue + } + + err = errors.Join(err, outcome.Value.err) + + results = append(results, outcome.Value.results) + } + + return results, err +} + func BuildComponent( env *azldev.Env, component components.Component, diff --git a/internal/app/azldev/env.go b/internal/app/azldev/env.go index 0c2729b0f..44da6e63c 100644 --- a/internal/app/azldev/env.go +++ b/internal/app/azldev/env.go @@ -233,6 +233,11 @@ func (env *Env) SetUniqueMockRoot(enabled bool, action string) { env.ctx = mock.WithUniqueRoots(env.ctx, enabled, action) } +// UniqueMockRootEnabled reports whether unique mock roots were requested for the current CLI action. +func (env *Env) UniqueMockRootEnabled() bool { + return mock.UniqueRootsEnabled(env.ctx) +} + // WithMockRootComponents returns a shallow copy with component-specific mock root labels. func (env *Env) WithMockRootComponents(names ...string) *Env { return env.WithContext(mock.WithRootComponents(env.ctx, names...)) diff --git a/internal/rpm/mock/uniqueroot.go b/internal/rpm/mock/uniqueroot.go index 5b8ce59dd..1bb73e1f6 100644 --- a/internal/rpm/mock/uniqueroot.go +++ b/internal/rpm/mock/uniqueroot.go @@ -34,6 +34,13 @@ func WithUniqueRoots(ctx context.Context, enabled bool, action string) context.C }) } +// UniqueRootsEnabled reports whether ctx was configured with [WithUniqueRoots] enabled. +func UniqueRootsEnabled(ctx context.Context) bool { + options, _ := ctx.Value(uniqueRootKey{}).(uniqueRootOptions) + + return options.enabled +} + // WithRootComponents specializes the component label for newly created runners, // without changing whether unique roots are enabled. func WithRootComponents(ctx context.Context, components ...string) context.Context { From b0f8979379987e08f384d5605fd2191a6fdb4ad2 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Tue, 10 Nov 2026 19:48:43 +0000 Subject: [PATCH 5/8] fix(build): address parallel build review feedback Protect shared event nesting from concurrent workers, return cancellation when queued builds are skipped, and run chroot cleanup with bounded, cancellation-detached contexts. Refresh CLI and MCP snapshots for the updated --unique-mockroot description. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4b65bb80-fb20-4e66-aaac-2bf4ae60835c --- internal/app/azldev/cmds/component/build.go | 17 ++++++++- internal/app/azldev/event.go | 3 ++ internal/app/azldev/eventlistener.go | 5 +++ internal/app/azldev/eventlistener_test.go | 35 +++++++++++++++++++ .../sourceproviders/customsourceprovider.go | 8 ++++- .../TestMCPServerMode_1.snap.json | 22 ++++++------ ...pshotsContainer_--bogus-flag_stderr_1.snap | 2 +- ...estSnapshotsContainer_--help_stdout_1.snap | 2 +- .../TestSnapshotsContainer_help_stdout_1.snap | 2 +- .../TestSnapshots_--bogus-flag_stderr_1.snap | 2 +- .../TestSnapshots_--help_stdout_1.snap | 2 +- ...tSnapshots_--help_with_color_stdout_1.snap | 2 +- .../TestSnapshots_help_stdout_1.snap | 2 +- 13 files changed, 84 insertions(+), 20 deletions(-) create mode 100644 internal/app/azldev/eventlistener_test.go diff --git a/internal/app/azldev/cmds/component/build.go b/internal/app/azldev/cmds/component/build.go index 69b70d2db..26a3b308e 100644 --- a/internal/app/azldev/cmds/component/build.go +++ b/internal/app/azldev/cmds/component/build.go @@ -281,8 +281,12 @@ func buildComponentsConcurrently( var err error + cancelled := false + for _, outcome := range outcomes { if outcome.Cancelled { + cancelled = true + continue } @@ -291,6 +295,14 @@ func buildComponentsConcurrently( results = append(results, outcome.Value.results) } + if ctxErr := env.Err(); ctxErr != nil { + err = errors.Join(err, ctxErr) + } + + if cancelled && err == nil { + err = errors.New("component builds cancelled before completion") + } + return results, err } @@ -341,7 +353,10 @@ func buildComponent( // Clean up the build environment before we return (unless we were asked not to do so). defer defers.HandleDeferError(func() error { if !options.BuildEnvPolicy.ShouldPreserve(err == nil) { - return buildEnv.Destroy(env) + ctx, cancel := context.WithTimeout(context.WithoutCancel(env), mockProcessorCleanupTimeout) + defer cancel() + + return buildEnv.Destroy(env.WithContext(ctx)) } return nil diff --git a/internal/app/azldev/event.go b/internal/app/azldev/event.go index 329f1aa05..b27f90591 100644 --- a/internal/app/azldev/event.go +++ b/internal/app/azldev/event.go @@ -45,6 +45,9 @@ func (e *event) End() { } // Decrement our event nesting level. + e.parentEventListener.mu.Lock() + defer e.parentEventListener.mu.Unlock() + if e.parentEventListener.eventLevel > 0 { e.parentEventListener.eventLevel-- } diff --git a/internal/app/azldev/eventlistener.go b/internal/app/azldev/eventlistener.go index 7c509370d..dc4e76f83 100644 --- a/internal/app/azldev/eventlistener.go +++ b/internal/app/azldev/eventlistener.go @@ -9,11 +9,13 @@ import ( "log/slog" "os" "strings" + "sync" "github.com/microsoft/azure-linux-dev-tools/internal/global/opctx" ) type appEventListener struct { + mu sync.Mutex eventLevel int eventLogger *slog.Logger quiet bool @@ -41,6 +43,9 @@ func NewEventListener(eventLogger *slog.Logger, quiet, verbose bool) (*appEventL // //nolint:ireturn,nolintlint // We need to return an interface because of the interface definition. func (el *appEventListener) StartEvent(name string, args ...any) opctx.Event { + el.mu.Lock() + defer el.mu.Unlock() + if name != "" { const spacesPerLevel = 2 diff --git a/internal/app/azldev/eventlistener_test.go b/internal/app/azldev/eventlistener_test.go new file mode 100644 index 000000000..e64539d82 --- /dev/null +++ b/internal/app/azldev/eventlistener_test.go @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package azldev_test + +import ( + "log/slog" + "sync" + "testing" + + "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev" + "github.com/stretchr/testify/require" +) + +func TestAppEventListenerConcurrentEvents(t *testing.T) { + t.Parallel() + + listener, err := azldev.NewEventListener(slog.New(slog.DiscardHandler), true, false) + require.NoError(t, err) + + const eventCount = 100 + + var waitGroup sync.WaitGroup + waitGroup.Add(eventCount) + + for range eventCount { + go func() { + defer waitGroup.Done() + + listener.StartEvent("worker").End() + }() + } + + waitGroup.Wait() +} diff --git a/internal/providers/sourceproviders/customsourceprovider.go b/internal/providers/sourceproviders/customsourceprovider.go index f287c9277..8baf405b1 100644 --- a/internal/providers/sourceproviders/customsourceprovider.go +++ b/internal/providers/sourceproviders/customsourceprovider.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/microsoft/azure-linux-dev-tools/internal/app/azldev/core/components" "github.com/microsoft/azure-linux-dev-tools/internal/global/opctx" @@ -35,6 +36,8 @@ const customGenOutputDir = "/azldev-gen/output" // near the end of command output. const maxCustomScriptOutputBytes = 64 * 1024 +const customSourceCleanupTimeout = 5 * time.Minute + // customFileSourceProvider implements [FileSourceProvider] for source files with // [projectconfig.OriginTypeCustom]. It executes a user-supplied script inside a // fresh mock chroot and packages the output directory as a deterministic archive. @@ -276,7 +279,10 @@ func execScriptInChroot( defer func() { // Best-effort cleanup. Log on failure rather than overwriting the primary error. - if scrubErr := runner.ScrubRoot(ctx); scrubErr != nil { + cleanupCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), customSourceCleanupTimeout) + defer cancel() + + if scrubErr := runner.ScrubRoot(cleanupCtx); scrubErr != nil { slog.Warn("Failed to scrub mock root after custom source generation", "filename", ref.Filename, "error", scrubErr) diff --git a/scenario/__snapshots__/TestMCPServerMode_1.snap.json b/scenario/__snapshots__/TestMCPServerMode_1.snap.json index 5a8773a94..895ecf4a4 100755 --- a/scenario/__snapshots__/TestMCPServerMode_1.snap.json +++ b/scenario/__snapshots__/TestMCPServerMode_1.snap.json @@ -103,7 +103,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "verbose": { @@ -219,7 +219,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "verbose": { @@ -333,7 +333,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "verbose": { @@ -437,7 +437,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "verbose": { @@ -556,7 +556,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "upstream-status": { @@ -648,7 +648,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "verbose": { @@ -731,7 +731,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "verbose": { @@ -819,7 +819,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "verbose": { @@ -917,7 +917,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "verbose": { @@ -1002,7 +1002,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "verbose": { @@ -1104,7 +1104,7 @@ }, "unique-mockroot": { "default": false, - "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)", + "description": "use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently", "type": "boolean" }, "verbose": { diff --git a/scenario/__snapshots__/TestSnapshotsContainer_--bogus-flag_stderr_1.snap b/scenario/__snapshots__/TestSnapshotsContainer_--bogus-flag_stderr_1.snap index 79a84ba98..5d1cbf8a8 100755 --- a/scenario/__snapshots__/TestSnapshotsContainer_--bogus-flag_stderr_1.snap +++ b/scenario/__snapshots__/TestSnapshotsContainer_--bogus-flag_stderr_1.snap @@ -29,7 +29,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshotsContainer_--help_stdout_1.snap b/scenario/__snapshots__/TestSnapshotsContainer_--help_stdout_1.snap index 5f985e03e..c1adbdc90 100755 --- a/scenario/__snapshots__/TestSnapshotsContainer_--help_stdout_1.snap +++ b/scenario/__snapshots__/TestSnapshotsContainer_--help_stdout_1.snap @@ -36,7 +36,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshotsContainer_help_stdout_1.snap b/scenario/__snapshots__/TestSnapshotsContainer_help_stdout_1.snap index 5f985e03e..c1adbdc90 100755 --- a/scenario/__snapshots__/TestSnapshotsContainer_help_stdout_1.snap +++ b/scenario/__snapshots__/TestSnapshotsContainer_help_stdout_1.snap @@ -36,7 +36,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshots_--bogus-flag_stderr_1.snap b/scenario/__snapshots__/TestSnapshots_--bogus-flag_stderr_1.snap index 79a84ba98..5d1cbf8a8 100755 --- a/scenario/__snapshots__/TestSnapshots_--bogus-flag_stderr_1.snap +++ b/scenario/__snapshots__/TestSnapshots_--bogus-flag_stderr_1.snap @@ -29,7 +29,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshots_--help_stdout_1.snap b/scenario/__snapshots__/TestSnapshots_--help_stdout_1.snap index 5f985e03e..c1adbdc90 100755 --- a/scenario/__snapshots__/TestSnapshots_--help_stdout_1.snap +++ b/scenario/__snapshots__/TestSnapshots_--help_stdout_1.snap @@ -36,7 +36,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshots_--help_with_color_stdout_1.snap b/scenario/__snapshots__/TestSnapshots_--help_with_color_stdout_1.snap index 3501c447d..82d31d4fe 100755 --- a/scenario/__snapshots__/TestSnapshots_--help_with_color_stdout_1.snap +++ b/scenario/__snapshots__/TestSnapshots_--help_with_color_stdout_1.snap @@ -36,7 +36,7 @@ Meta commands: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files diff --git a/scenario/__snapshots__/TestSnapshots_help_stdout_1.snap b/scenario/__snapshots__/TestSnapshots_help_stdout_1.snap index 5f985e03e..c1adbdc90 100755 --- a/scenario/__snapshots__/TestSnapshots_help_stdout_1.snap +++ b/scenario/__snapshots__/TestSnapshots_help_stdout_1.snap @@ -36,7 +36,7 @@ Flags: --permissive-config do not fail on unknown fields in TOML config files -C, --project string path to Azure Linux project -q, --quiet only enable minimal output - --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters) + --unique-mockroot use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters); allows 'component build' to build multiple components concurrently -v, --verbose enable verbose output --version version for azldev --without-lockfile preview: track resolved upstream commits in generated config instead of lock files From afde10a2c8afad2c1a6b85665d7323d302cbfc98 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Tue, 10 Nov 2026 23:01:07 +0000 Subject: [PATCH 6/8] fix(mock): preserve shared bootstrap caches during unique root cleanup Probe mock help for bootstrap-cache support before scrubbing unique roots. On older versions, scrub only the main root and remove the validated unique bootstrap directory with sudo after mock exits, preserving shared caches. Cover capability detection, custom root paths, cleanup failures, and cache preservation with regression tests, and update user and agent guidance. Validation: mage all passed with refreshed Docker group membership; mage mutationDiff HEAD killed all 24 mutants with none surviving or uncovered. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1dd8217a-74b0-49ad-9004-917ec834302f --- docs/user/how-to/build-component.md | 6 + .../app/azldev/agentskill/agentskill_test.go | 8 + .../azldev/agentskill/content/mock.md.tmpl | 2 + internal/rpm/mock/mock.go | 96 +++++++- internal/rpm/mock/mock_test.go | 225 ++++++++++++++++++ internal/rpm/mock/uniqueroot_test.go | 4 + 6 files changed, 339 insertions(+), 2 deletions(-) diff --git a/docs/user/how-to/build-component.md b/docs/user/how-to/build-component.md index 1907b2704..89fac6522 100644 --- a/docs/user/how-to/build-component.md +++ b/docs/user/how-to/build-component.md @@ -76,6 +76,12 @@ The extension stays the same for initialization, commands, and cleanup of that root; separate roots receive separate random suffixes. Without the flag, mock's existing root naming is unchanged. +Cleanup removes both the unique build root and its bootstrap root while preserving +shared caches. azldev checks `mock --help` for `bootstrap-cache` support before +cleanup: newer Mock versions can safely use `--scrub=bootstrap`; older versions +require `sudo` to remove only the bootstrap directory with the matching extension +after Mock finishes scrubbing the build root. + The flag also applies to queries, custom source generation, and `azldev advanced mock` commands. A unique `mock shell` session does not reuse a previous session's root. To inspect a preserved unique build root, take its diff --git a/internal/app/azldev/agentskill/agentskill_test.go b/internal/app/azldev/agentskill/agentskill_test.go index 212bb6dca..1ef85de4a 100644 --- a/internal/app/azldev/agentskill/agentskill_test.go +++ b/internal/app/azldev/agentskill/agentskill_test.go @@ -165,6 +165,14 @@ func TestSkillsDocumentUniqueMockRoots(t *testing.T) { } } +func TestMockSkillDocumentsBootstrapCleanup(t *testing.T) { + doc, err := agentskill.SkillDocument("azldev-mock", testParams()) + require.NoError(t, err) + assert.Contains(t, doc, "Cleanup preserves shared caches.") + assert.Contains(t, doc, "`mock --help` does not list `bootstrap-cache`") + assert.Contains(t, doc, "matching unique bootstrap directory") +} + func TestComponentTomlSkillDocumentsRPMDevBumpspecPreview(t *testing.T) { doc, err := agentskill.SkillDocument("azldev-comp-toml", testParams()) require.NoError(t, err) diff --git a/internal/app/azldev/agentskill/content/mock.md.tmpl b/internal/app/azldev/agentskill/content/mock.md.tmpl index f50ba4a95..b0ac28ddb 100644 --- a/internal/app/azldev/agentskill/content/mock.md.tmpl +++ b/internal/app/azldev/agentskill/content/mock.md.tmpl @@ -90,6 +90,8 @@ react to output between commands. - **`--unique-mockroot` starts a separate root each time.** To re-enter a preserved unique root, use `mock -r --uniqueext --shell` with the extension from the verbose command log, not another azldev invocation. + Cleanup preserves shared caches. If `mock --help` does not list `bootstrap-cache`, + azldev uses `sudo` to remove only the matching unique bootstrap directory after Mock exits. - **One mock session per terminal.** Running `azldev adv mock shell` while a terminal is already inside a mock shell fails — run `exit` first. diff --git a/internal/rpm/mock/mock.go b/internal/rpm/mock/mock.go index 4f79cb2fa..7cffdd4e4 100644 --- a/internal/rpm/mock/mock.go +++ b/internal/rpm/mock/mock.go @@ -629,7 +629,16 @@ func (r *Runner) ScrubRoot(ctx context.Context) error { mockArgs := r.getBaseArgs() - if r.baseDir != "" { + var bootstrapPath string + + if r.uniqueExtension != "" { + bootstrapPath, err = r.bootstrapCleanupPath(ctx) + if err != nil { + return err + } + } + + if r.baseDir != "" && r.uniqueExtension == "" { // Lie about the cache topdir so that mock doesn't delete our *actual* shared cache. mockArgs = append(mockArgs, "--config-opts", "cache_topdir="+r.baseDir) mockArgs = append(mockArgs, "--scrub", "all") @@ -639,7 +648,7 @@ func (r *Runner) ScrubRoot(ctx context.Context) error { // A unique extension gives the bootstrap root a unique name too, so it would never be reused // or cleaned up by a later invocation. - if r.uniqueExtension != "" && r.baseDir == "" { + if r.uniqueExtension != "" && bootstrapPath == "" { mockArgs = append(mockArgs, "--scrub", "bootstrap") } @@ -659,6 +668,89 @@ func (r *Runner) ScrubRoot(ctx context.Context) error { return fmt.Errorf("mock failed to scrub root:\n%w", err) } + if bootstrapPath != "" { + return r.removeBootstrapRoot(ctx, bootstrapPath) + } + + return nil +} + +// bootstrapCleanupPath returns the unique bootstrap directory to remove manually, or an empty +// string when mock supports scrubbing the bootstrap without deleting its shared cache. +func (r *Runner) bootstrapCleanupPath(ctx context.Context) (string, error) { + cmd, err := r.cmdFactory.Command(exec.CommandContext(ctx, MockBinary, "--help")) + if err != nil { + return "", fmt.Errorf("failed to create command to query mock capabilities:\n%w", err) + } + + help, err := cmd.RunAndGetOutput(ctx) + if err != nil { + return "", fmt.Errorf("failed to query mock capabilities:\n%w", err) + } + + if strings.Contains(help, "bootstrap-cache") { + return "", nil + } + + // Query the canonical root directory, ignoring custom '--rootdir' settings: mock always + // places the bootstrap beside this directory, even when the main root is elsewhere. + probe := r.Clone() + + probe.rootDir = "" + if probe.configOpts == nil { + probe.configOpts = make(map[string]string) + } + + probe.configOpts["rootdir"] = "{{basedir}}/{{root}}" + + rootPath, err := probe.GetRootPath(ctx) + if err != nil { + return "", fmt.Errorf("failed to locate unique mock bootstrap root:\n%w", err) + } + + rootPath = filepath.Clean(rootPath) + rootName := filepath.Base(rootPath) + suffix := "-" + r.uniqueExtension + + if !filepath.IsAbs(rootPath) || strings.ContainsAny(rootPath, "\r\n") || + !strings.HasSuffix(rootName, suffix) || len(rootName) <= len(suffix) { + return "", fmt.Errorf("refusing to derive bootstrap root from unexpected mock root path %#q", rootPath) + } + + bootstrapName := strings.TrimSuffix(rootName, suffix) + "-bootstrap" + suffix + + return filepath.Join(filepath.Dir(rootPath), bootstrapName), nil +} + +func (r *Runner) removeBootstrapRoot(ctx context.Context, bootstrapPath string) error { + exists, err := fileutils.Exists(r.fs, bootstrapPath) + if err != nil { + return fmt.Errorf("failed to check mock bootstrap root %#q:\n%w", bootstrapPath, err) + } + + if !exists { + return nil + } + + // Mock has exited and finalized both roots, unmounting their filesystems. The bootstrap + // contains root-owned files, so remove only its validated unique directory with sudo. + if !r.cmdFactory.CommandInSearchPath("sudo") { + return fmt.Errorf("sudo required to remove unique mock bootstrap root %#q", bootstrapPath) + } + + rawCmd := exec.CommandContext(ctx, "sudo", "rm", "--recursive", "--force", "--one-file-system", "--", bootstrapPath) + rawCmd.Stdout = os.Stdout + rawCmd.Stderr = os.Stderr + + cmd, err := r.cmdFactory.Command(rawCmd) + if err != nil { + return fmt.Errorf("failed to create command to remove mock bootstrap root:\n%w", err) + } + + if err := cmd.Run(ctx); err != nil { + return fmt.Errorf("failed to remove mock bootstrap root %#q:\n%w", bootstrapPath, err) + } + return nil } diff --git a/internal/rpm/mock/mock_test.go b/internal/rpm/mock/mock_test.go index 3d402c9ce..dfbd30bfa 100644 --- a/internal/rpm/mock/mock_test.go +++ b/internal/rpm/mock/mock_test.go @@ -8,6 +8,7 @@ import ( "fmt" "os/exec" "path/filepath" + "slices" "strings" "testing" @@ -27,6 +28,7 @@ const ( testOutputDirPath = "/output" testSRPMPath = "/output/component-1.0.0.src.rpm" testRPMPath = "/output/component-1.0.0.rpm" + testSudoBinary = "sudo" ) func newTestCtxWithMockPrereqsPresent() *testctx.TestCtx { @@ -119,6 +121,229 @@ func TestGetRootPath(t *testing.T) { assert.Equal(t, testMockRootPath, rootPath) } +func TestScrubRoot(t *testing.T) { + tests := []struct { + name string + unique bool + bootstrapCache bool + baseDir string + missingBootstrap bool + }{ + {name: "shared root"}, + {name: "shared private base", baseDir: "/private/mock"}, + {name: "unique modern mock", unique: true, bootstrapCache: true}, + {name: "unique legacy mock", unique: true}, + {name: "unique modern private base", unique: true, bootstrapCache: true, baseDir: "/private/mock"}, + {name: "unique legacy private base", unique: true, baseDir: "/private/mock"}, + {name: "unique missing bootstrap", unique: true, missingBootstrap: true}, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ctx := newTestCtxWithMockPrereqsPresent() + ctx.Ctx = mock.WithUniqueRoots(ctx.Ctx, test.unique, "build") + ctx.CmdFactory.RegisterCommandInSearchPath(testSudoBinary) + runner := mock.NewRunner(ctx, testMockConfigPath).WithBaseDir(test.baseDir) + runner.WithRootDir("/custom/root") + runner.WithConfigOpts(map[string]string{"rootdir": "/configured/root"}) + + baseDir := test.baseDir + if baseDir == "" { + baseDir = "/configured/mock" + } + + rootName := "test" + bootstrapName := "test-bootstrap" + + if test.unique { + rootName += "-" + runner.UniqueExtension() + bootstrapName += "-" + runner.UniqueExtension() + } + + rootPath := filepath.Join(baseDir, rootName) + bootstrapPath := filepath.Join(baseDir, bootstrapName) + cachePath := "/var/cache/mock/test-bootstrap/root_cache/cache" + otherRoot := filepath.Join(baseDir, "test-bootstrap-other") + + sharedRoot := filepath.Join(baseDir, "test-bootstrap") + for _, path := range []string{rootPath, otherRoot, sharedRoot, filepath.Dir(cachePath)} { + require.NoError(t, fileutils.MkdirAll(ctx.FS(), path)) + } + + if !test.missingBootstrap { + require.NoError(t, fileutils.MkdirAll(ctx.FS(), bootstrapPath)) + } + + require.NoError(t, fileutils.WriteFile(ctx.FS(), cachePath, []byte("shared cache"), fileperms.PrivateFile)) + + var actions []string + + ctx.CmdFactory.RunAndGetOutputHandler = func(cmd *exec.Cmd) (string, error) { + if slices.Contains(cmd.Args, "--help") { + actions = append(actions, "help") + + assert.Equal(t, []string{"mock", "--help"}, cmd.Args) + + if test.bootstrapCache { + return "--scrub=[all|bootstrap|chroot|cache|bootstrap-cache]", nil + } + + return "--scrub=[all|bootstrap|chroot|cache]", nil + } + + actions = append(actions, "path") + + assert.Contains(t, cmd.Args, "--print-root-path") + assert.Contains(t, cmd.Args, "rootdir={{basedir}}/{{root}}") + assert.NotContains(t, cmd.Args, "--rootdir") + assert.NotContains(t, cmd.Args, "rootdir=/configured/root") + + return rootPath + "\n", nil + } + ctx.CmdFactory.RunHandler = func(cmd *exec.Cmd) error { + if cmd.Args[0] == testSudoBinary { + actions = append(actions, "remove") + + assert.Equal(t, []string{ + testSudoBinary, "rm", "--recursive", "--force", "--one-file-system", "--", bootstrapPath, + }, cmd.Args) + + return ctx.FS().RemoveAll(bootstrapPath) + } + + actions = append(actions, "scrub") + + assert.Contains(t, cmd.Args, "--scrub") + assert.NotContains(t, cmd.Args, "bootstrap-cache") + assert.Equal(t, test.unique && test.bootstrapCache, slices.Contains(cmd.Args, "bootstrap")) + assert.Equal(t, !test.unique && test.baseDir != "", slices.Contains(cmd.Args, "all")) + require.NoError(t, ctx.FS().RemoveAll(rootPath)) + + if test.unique && test.bootstrapCache { + require.NoError(t, ctx.FS().RemoveAll(bootstrapPath)) + } + + return nil + } + + require.NoError(t, runner.ScrubRoot(ctx)) + + expectedActions := []string{"scrub"} + if test.unique { + expectedActions = []string{"help", "scrub"} + if !test.bootstrapCache { + expectedActions = []string{"help", "path", "scrub"} + if !test.missingBootstrap { + expectedActions = append(expectedActions, "remove") + } + } + } + + assert.Equal(t, expectedActions, actions) + + if test.unique { + exists, err := fileutils.Exists(ctx.FS(), bootstrapPath) + require.NoError(t, err) + assert.False(t, exists) + } + + for _, path := range []string{otherRoot, sharedRoot, cachePath} { + exists, err := fileutils.Exists(ctx.FS(), path) + require.NoError(t, err) + assert.True(t, exists, path) + } + }) + } +} + +func TestScrubRootRejectsUnexpectedPaths(t *testing.T) { + for _, path := range []string{ + "", "/", "/var/lib/mock/test", "relative-EXTENSION", + "/var/lib/mock/-EXTENSION", "/var/lib/mock/unsafe\nroot-EXTENSION", + } { + t.Run(path, func(t *testing.T) { + ctx := newTestCtxWithMockPrereqsPresent() + ctx.Ctx = mock.WithUniqueRoots(ctx.Ctx, true, "build") + runner := mock.NewRunner(ctx, testMockConfigPath) + ctx.CmdFactory.RunAndGetOutputHandler = func(cmd *exec.Cmd) (string, error) { + if slices.Contains(cmd.Args, "--help") { + return "--scrub=[bootstrap|chroot]", nil + } + + return strings.ReplaceAll(path, "EXTENSION", runner.UniqueExtension()), nil + } + ctx.CmdFactory.RunHandler = func(cmd *exec.Cmd) error { + t.Fatalf("unexpected destructive command: %v", cmd.Args) + + return nil + } + + err := runner.ScrubRoot(ctx) + require.ErrorContains(t, err, "refusing to derive bootstrap root") + }) + } +} + +func TestScrubRootFailures(t *testing.T) { + for _, stage := range []string{"help", "path", "scrub", "remove", "missing sudo"} { + t.Run(stage, func(t *testing.T) { + ctx := newTestCtxWithMockPrereqsPresent() + + ctx.Ctx = mock.WithUniqueRoots(ctx.Ctx, true, "build") + if stage != "missing sudo" { + ctx.CmdFactory.RegisterCommandInSearchPath(testSudoBinary) + } + + runner := mock.NewRunner(ctx, testMockConfigPath) + rootPath := "/var/lib/mock/test-" + runner.UniqueExtension() + bootstrapPath := "/var/lib/mock/test-bootstrap-" + runner.UniqueExtension() + require.NoError(t, fileutils.MkdirAll(ctx.FS(), bootstrapPath)) + + testError := errors.New("injected cleanup failure") + ctx.CmdFactory.RunAndGetOutputHandler = func(cmd *exec.Cmd) (string, error) { + if slices.Contains(cmd.Args, "--help") { + if stage == "help" { + return "", testError + } + + return "--scrub=[bootstrap|chroot]", nil + } + + if stage == "path" { + return "", testError + } + + return rootPath, nil + } + ctx.CmdFactory.RunHandler = func(cmd *exec.Cmd) error { + if cmd.Args[0] == testSudoBinary { + assert.Equal(t, "remove", stage) + } else { + assert.Contains(t, []string{"scrub", "remove", "missing sudo"}, stage) + assert.NotContains(t, cmd.Args, "bootstrap") + } + + if stage == "scrub" || stage == "remove" && cmd.Args[0] == testSudoBinary { + return testError + } + + return nil + } + + err := runner.ScrubRoot(ctx) + if stage == "missing sudo" { + require.ErrorContains(t, err, "sudo required") + } else { + require.ErrorIs(t, err, testError) + } + + exists, err := fileutils.Exists(ctx.FS(), bootstrapPath) + require.NoError(t, err) + assert.True(t, exists) + }) + } +} + func TestBuildSRPM(t *testing.T) { ctx := newTestCtxWithMockPrereqsPresent() executedCmds := []string{} diff --git a/internal/rpm/mock/uniqueroot_test.go b/internal/rpm/mock/uniqueroot_test.go index b57a1dc95..b4c1e75cc 100644 --- a/internal/rpm/mock/uniqueroot_test.go +++ b/internal/rpm/mock/uniqueroot_test.go @@ -113,6 +113,10 @@ func TestUniqueExtensionLifecycle(t *testing.T) { return nil } ctx.CmdFactory.RunAndGetOutputHandler = func(cmd *exec.Cmd) (string, error) { + if slices.Contains(cmd.Args, "--help") { + return "--scrub=[chroot|bootstrap|bootstrap-cache]", nil + } + capture(cmd) return testMockRootPath, nil From 1823badb5039a40506e9f085bd4381c12457d185 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Tue, 10 Nov 2026 23:17:07 +0000 Subject: [PATCH 7/8] fix(mock): skip unique root discovery during dry runs Skip mock capability and root-path discovery when previewing unique-root cleanup. Keep the wrapped scrub command so dry runs log cleanup without requiring output from commands that are not executed. Preserve dry-run behavior across runner clones, add regression coverage for default and private base directories, and document the cleanup preview. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fc0e0213-1257-4970-b4a6-e865ac20b402 --- docs/user/how-to/build-component.md | 2 ++ internal/rpm/mock/mock.go | 8 ++++++ internal/rpm/mock/mock_test.go | 40 +++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/docs/user/how-to/build-component.md b/docs/user/how-to/build-component.md index 89fac6522..a7a1943d0 100644 --- a/docs/user/how-to/build-component.md +++ b/docs/user/how-to/build-component.md @@ -81,6 +81,8 @@ shared caches. azldev checks `mock --help` for `bootstrap-cache` support before cleanup: newer Mock versions can safely use `--scrub=bootstrap`; older versions require `sudo` to remove only the bootstrap directory with the matching extension after Mock finishes scrubbing the build root. +With `--dry-run`, cleanup skips capability and path discovery and previews the +scrub command without executing it. The flag also applies to queries, custom source generation, and `azldev advanced mock` commands. A unique `mock shell` session does not reuse a diff --git a/internal/rpm/mock/mock.go b/internal/rpm/mock/mock.go index 7cffdd4e4..032d27e20 100644 --- a/internal/rpm/mock/mock.go +++ b/internal/rpm/mock/mock.go @@ -42,6 +42,7 @@ type Runner struct { osEnv opctx.OSEnv cmdFactory opctx.CmdFactory eventListener opctx.EventListener + dryRunInfo opctx.DryRunnable // Verbosity verbose bool @@ -95,6 +96,7 @@ func NewRunner(ctx opctx.Ctx, mockConfigPath string) *Runner { osEnv: ctx.OSEnv(), cmdFactory: ctx, eventListener: ctx, + dryRunInfo: ctx, verbose: ctx.Verbose(), mockConfigPath: mockConfigPath, uniqueExtension: newUniqueExtension(ctx), @@ -108,6 +110,7 @@ func (r *Runner) Clone() *Runner { osEnv: r.osEnv, cmdFactory: r.cmdFactory, eventListener: r.eventListener, + dryRunInfo: r.dryRunInfo, verbose: r.verbose, mockConfigPath: r.mockConfigPath, uniqueExtension: r.uniqueExtension, @@ -678,6 +681,11 @@ func (r *Runner) ScrubRoot(ctx context.Context) error { // bootstrapCleanupPath returns the unique bootstrap directory to remove manually, or an empty // string when mock supports scrubbing the bootstrap without deleting its shared cache. func (r *Runner) bootstrapCleanupPath(ctx context.Context) (string, error) { + // Dry runs cannot discover capabilities or paths; only preview the wrapped scrub command. + if r.dryRunInfo.DryRun() { + return "", nil + } + cmd, err := r.cmdFactory.Command(exec.CommandContext(ctx, MockBinary, "--help")) if err != nil { return "", fmt.Errorf("failed to create command to query mock capabilities:\n%w", err) diff --git a/internal/rpm/mock/mock_test.go b/internal/rpm/mock/mock_test.go index dfbd30bfa..60a5e5198 100644 --- a/internal/rpm/mock/mock_test.go +++ b/internal/rpm/mock/mock_test.go @@ -256,6 +256,46 @@ func TestScrubRoot(t *testing.T) { } } +func TestScrubRootDryRun(t *testing.T) { + for _, baseDir := range []string{"", "/private/mock"} { + t.Run("base="+baseDir, func(t *testing.T) { + ctx := newTestCtxWithMockPrereqsPresent() + ctx.DryRunValue = true + ctx.Ctx = mock.WithUniqueRoots(ctx.Ctx, true, "build") + runner := mock.NewRunner(ctx, testMockConfigPath).WithBaseDir(baseDir) + + ctx.CmdFactory.RunAndGetOutputHandler = func(cmd *exec.Cmd) (string, error) { + t.Errorf("unexpected discovery command during dry run: %v", cmd.Args) + + return "", nil + } + + var commands [][]string + + ctx.CmdFactory.RunHandler = func(cmd *exec.Cmd) error { + commands = append(commands, cmd.Args) + + return nil + } + + for _, candidate := range []*mock.Runner{runner, runner.Clone()} { + require.NoError(t, candidate.ScrubRoot(ctx)) + } + + require.Len(t, commands, 2) + + for _, args := range commands { + assert.Equal(t, "mock", args[0]) + assert.Contains(t, args, "--uniqueext") + assert.Contains(t, args, runner.UniqueExtension()) + assert.Equal(t, []string{"--scrub", "chroot", "--scrub", "bootstrap"}, args[len(args)-4:]) + assert.NotContains(t, args, "all") + assert.NotContains(t, args, "bootstrap-cache") + } + }) + } +} + func TestScrubRootRejectsUnexpectedPaths(t *testing.T) { for _, path := range []string{ "", "/", "/var/lib/mock/test", "relative-EXTENSION", From a167dd048db6284a922fd8da4abf8798de66396e Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Wed, 11 Nov 2026 03:57:15 +0000 Subject: [PATCH 8/8] fix(mock): disable yum cache for unique roots Pass --disable-plugin yum_cache whenever mock uses --uniqueext, leaving non-unique commands unchanged. Cover the unique-root lifecycle and update user and agent documentation in both lockfile modes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e25b5788-5449-4db1-ae9d-5c235e69dbc5 --- docs/user/how-to/build-component.md | 4 ++++ internal/app/azldev/agentskill/agentskill_test.go | 5 +++++ .../app/azldev/agentskill/content/build-component.md.tmpl | 1 + internal/app/azldev/agentskill/content/mock.md.tmpl | 1 + .../content/withoutlockfile/build-component.md.tmpl | 3 +++ internal/rpm/mock/mock.go | 2 +- internal/rpm/mock/uniqueroot_test.go | 6 ++++++ 7 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/user/how-to/build-component.md b/docs/user/how-to/build-component.md index a7a1943d0..881780e4a 100644 --- a/docs/user/how-to/build-component.md +++ b/docs/user/how-to/build-component.md @@ -76,6 +76,10 @@ The extension stays the same for initialization, commands, and cleanup of that root; separate roots receive separate random suffixes. Without the flag, mock's existing root naming is unchanged. +Unique-root commands also pass `--disable-plugin yum_cache` to disable mock's +shared yum cache. Commands without `--unique-mockroot` retain the configured cache +behavior. + Cleanup removes both the unique build root and its bootstrap root while preserving shared caches. azldev checks `mock --help` for `bootstrap-cache` support before cleanup: newer Mock versions can safely use `--scrub=bootstrap`; older versions diff --git a/internal/app/azldev/agentskill/agentskill_test.go b/internal/app/azldev/agentskill/agentskill_test.go index 1ef85de4a..e53c985a8 100644 --- a/internal/app/azldev/agentskill/agentskill_test.go +++ b/internal/app/azldev/agentskill/agentskill_test.go @@ -161,6 +161,11 @@ func TestSkillsDocumentUniqueMockRoots(t *testing.T) { assert.Contains(t, doc, "--unique-mockroot") assert.Contains(t, doc, "at most 24 characters") assert.Contains(t, doc, "--uniqueext --shell") + assert.Contains(t, doc, "--disable-plugin yum_cache") + + withoutLockfileDoc, err := agentskill.NewCatalog(true).SkillDocument(name, testParams()) + require.NoError(t, err) + assert.Contains(t, withoutLockfileDoc, "--disable-plugin yum_cache") }) } } diff --git a/internal/app/azldev/agentskill/content/build-component.md.tmpl b/internal/app/azldev/agentskill/content/build-component.md.tmpl index 46edb5bbe..4930e1ff3 100644 --- a/internal/app/azldev/agentskill/content/build-component.md.tmpl +++ b/internal/app/azldev/agentskill/content/build-component.md.tmpl @@ -25,6 +25,7 @@ Use the global `--unique-mockroot` flag to isolate mock roots from other azldev operations. Extensions contain abbreviated action/component labels and a random suffix, use at most 24 characters total (up to 12 for the component label), and remain stable through each root's cleanup. +azldev also passes `--disable-plugin yum_cache` for unique-root commands. To inspect a preserved unique root, use `mock -r --uniqueext --shell` with the extension from the verbose command log; a new azldev shell invocation creates a different root. diff --git a/internal/app/azldev/agentskill/content/mock.md.tmpl b/internal/app/azldev/agentskill/content/mock.md.tmpl index b0ac28ddb..8bf8a36ba 100644 --- a/internal/app/azldev/agentskill/content/mock.md.tmpl +++ b/internal/app/azldev/agentskill/content/mock.md.tmpl @@ -90,6 +90,7 @@ react to output between commands. - **`--unique-mockroot` starts a separate root each time.** To re-enter a preserved unique root, use `mock -r --uniqueext --shell` with the extension from the verbose command log, not another azldev invocation. + azldev also passes `--disable-plugin yum_cache` for unique-root commands. Cleanup preserves shared caches. If `mock --help` does not list `bootstrap-cache`, azldev uses `sudo` to remove only the matching unique bootstrap directory after Mock exits. - **One mock session per terminal.** Running `azldev adv mock shell` while a terminal is already diff --git a/internal/app/azldev/agentskill/content/withoutlockfile/build-component.md.tmpl b/internal/app/azldev/agentskill/content/withoutlockfile/build-component.md.tmpl index cac327d99..e476ef94c 100644 --- a/internal/app/azldev/agentskill/content/withoutlockfile/build-component.md.tmpl +++ b/internal/app/azldev/agentskill/content/withoutlockfile/build-component.md.tmpl @@ -21,6 +21,9 @@ Build foundational packages before their dependents. RPMs land in the project's configured output directory (`out` by default). `-q` quiets output but hides build progress — use it only for inner-loop builds you expect to succeed. +Use `--unique-mockroot` to isolate mock roots. azldev also passes +`--disable-plugin yum_cache` for unique-root commands. + ## The inner loop investigate → modify → render → build → test → inspect diff --git a/internal/rpm/mock/mock.go b/internal/rpm/mock/mock.go index 032d27e20..feefbe440 100644 --- a/internal/rpm/mock/mock.go +++ b/internal/rpm/mock/mock.go @@ -782,7 +782,7 @@ func (r *Runner) getBaseArgs() (args []string) { args = append(args, "--configdir", filepath.Dir(r.mockConfigPath)) if r.uniqueExtension != "" { - args = append(args, "--uniqueext", r.uniqueExtension) + args = append(args, "--uniqueext", r.uniqueExtension, "--disable-plugin", "yum_cache") } if r.baseDir != "" { diff --git a/internal/rpm/mock/uniqueroot_test.go b/internal/rpm/mock/uniqueroot_test.go index b4c1e75cc..79613cde5 100644 --- a/internal/rpm/mock/uniqueroot_test.go +++ b/internal/rpm/mock/uniqueroot_test.go @@ -106,6 +106,11 @@ func TestUniqueExtensionLifecycle(t *testing.T) { require.Positive(t, index) require.Less(t, index+1, len(cmd.Args)) extensions = append(extensions, cmd.Args[index+1]) + + pluginIndex := slices.Index(cmd.Args, "--disable-plugin") + require.Positive(t, pluginIndex) + require.Less(t, pluginIndex+1, len(cmd.Args)) + assert.Equal(t, "yum_cache", cmd.Args[pluginIndex+1]) } ctx.CmdFactory.RunHandler = func(cmd *exec.Cmd) error { capture(cmd) @@ -155,6 +160,7 @@ func TestUniqueExtensionDisabled(t *testing.T) { ctx.Ctx = mock.WithRootComponents(ctx.Ctx, "curl") ctx.CmdFactory.RunHandler = func(cmd *exec.Cmd) error { assert.NotContains(t, cmd.Args, "--uniqueext") + assert.NotContains(t, cmd.Args, "--disable-plugin") return nil }