Skip to content

CI/CD - Pin Ansible dependencies and reuse build layers - #900

Draft
gusui-msft wants to merge 1 commit into
mainfrom
gusui-msft/ansible-dependency-reliability-20261116
Draft

gusui-msft wants to merge 1 commit into
mainfrom
gusui-msft/ansible-dependency-reliability-20261116

Conversation

@gusui-msft

@gusui-msft gusui-msft commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Make Ansible dependency installation predictable and cache-friendly while reusing the existing Makefile, Dockerfiles, and CI workflows.

  • Two-profile Python and collection pins: requirements/ansible.txt pins one legacy profile for Python <3.11 (ansible-base==2.10.17, ansible-runner==2.3.1) and one modern profile for Python >=3.11 (ansible-core==2.19.15, ansible-runner==2.4.3), with Jinja2==3.1.6 across all supported runtimes, aligned with setup.py (ansible-core>=2.19,<2.23 on Python >=3.11). Both profiles are exercised directly by the existing CI matrix (Python 3.7/3.10 and Python 3.12). Shared transitive dependencies (cryptography, PyYAML, packaging, resolvelib) remain pip-managed so constraints do not conflict with preinstalled packages in NGC PyTorch and ROCm base images.
  • Bounded collection acquisition (make postinstall): derives the legacy (ansible.posix:1.5.4, ansible.utils:2.12.0, community.crypto:2.16.0) or modern (ansible.posix:2.2.2, ansible.utils:6.1.1, community.crypto:3.5.1) collection set directly from ansible-galaxy --version (preventing mixed-PATH interpreter mismatches) and bounds ansible-galaxy collection install to at most three attempts (timeout -k 30 300, 10s/20s backoff), without introducing a custom installer or post-install checker script.
  • Source-independent Docker layer across all seven active Dockerfiles (nine image variants): cuda11.1.1, cuda12.9, cuda13.0, cuda13.4, cuda13.5, rocm6.3.x, and rocm6.4.x install requirements/ansible.txt and make postinstall immediately before ADD . . and pass -c requirements/ansible.txt to subsequent pip install commands. Source-only edits reuse standard BuildKit layer caching in .github/workflows/build-image.yml without invalidating earlier toolchain/library layers or adding extra cold-build CI jobs.
  • CI, devcontainer, and local collection tests: apply -c requirements/ansible.txt and make postinstall across CPU, CUDA, Ansible CI pipelines, and .devcontainer/post-create-command.sh, and cover bounded retries/timeouts, mixed-PATH ansible-galaxy profile selection, runner failure propagation, community.crypto.openssh_keypair key generation and idempotency, ansible.utils.index_of, and the production fetch_results.yaml playbook in tests/runner/test_ansible.py.

Validation

Validated at a21dba79 on Linux x86_64 across isolated legacy and modern Python environments:

  • Legacy profile — Python 3.8.20 and 3.10.22 (ansible-base==2.10.17, ansible-runner==2.3.1, Jinja2==3.1.6) and Modern profile — Python 3.11.18, 3.12.3, and 3.13.18 (ansible-core==2.19.15, ansible-runner==2.4.3, Jinja2==3.1.6): clean constrained install, pip check, fresh make postinstall, and python3 -m pytest -q tests/runner/test_ansible.py (9 passed, 6 subtests passed, including mixed-PATH Galaxy runtime selection, unactivated-venv symlink PATH handling, system rsync, and the fallback rsync path for minimal containers).
  • Negative controls & static checks: verified test failure when removing timeout, dropping -k 30, changing the 300s deadline, or reducing retries to two attempts; full-repo yapf==0.31.0 --diff (Python 3.10), flake8, mypy, bash -n, workflow YAML parsing, and git diff --check passed.

Scope and limits

  • Python 3.7-3.10 retain ansible-base 2.10.17 as an end-of-life compatibility bridge; GPU Python and base-image versions are unchanged.
  • Cold builds still require PyPI and Ansible Galaxy. Multi-arch image builds and multi-node SSH/Docker deployment remain gated by the PR image and integration checks when marked ready for review.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 03:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Legacy Ansible collections become hidden after deployment, and the frozen cryptography versions cannot install on Python 3.9.0–3.9.1 despite those interpreters remaining supported.

3 open issues
What changed in this PR

This PR separates SuperBench’s Ansible dependencies from application builds, freezing supported profiles and enabling GPU images to reuse dependency layers after source-only changes.

Changes:

  • Adds pinned Python and collection profiles, with shared installation, bounded Galaxy retries, and dependency validation.
  • Introduces reusable dependency stages across six GPU Dockerfiles and constrains subsequent Python installations.
  • Adds profile, collection, runner, and build-cache checks, and documents the installation workflow.
File Description
tests/​runner/​test_ansible.py Tests real local execution and failure propagation.
tests/​ansible/​test_dependencies.yaml Exercises collection operations and production result fetching.
tests/​ansible/​test_dependencies.py Tests retries, validation, collections, and cache-probe behavior.
tests/​ansible/​check_build_cache.sh Checks cold builds, cache reuse, and dependency invalidation.
setup.py Selects engine and runner ranges by Python version.
scripts/​install_ansible.py Installs and validates frozen dependency profiles.
requirements/​ansible.txt Freezes Python dependencies with version markers.
requirements/​ansible.in Defines inputs for generating the Python freeze.
requirements/​ansible-modern.yml Pins modern Ansible collections.
requirements/​ansible-legacy.yml Pins legacy-compatible Ansible collections.
Makefile Routes postinstall through the shared installer.
docs/​developer-guides/​development.md Documents profiles, validation, and dependency caching.
dockerfile/​rocm6.4.x.dockerfile Adds a dependency stage and post-install checks.
dockerfile/​rocm6.3.x.dockerfile Adds a dependency stage and constrained installation.
dockerfile/​cuda13.4.dockerfile Shares the dependency stage across both build branches.
dockerfile/​cuda13.0.dockerfile Adds cached dependencies and application validation.
dockerfile/​cuda12.9.dockerfile Adds cached dependencies and application validation.
dockerfile/​cuda11.1.1.dockerfile Adds legacy-profile caching, validation, and rsync.
.github/​workflows/​build-image.yml Runs cache checks for relevant pull-request changes.
.github/​workflows/​ansible-dependencies.yml Adds a Python-version matrix for profile validation.
.azure-pipelines/​cuda-unit-test.yml Constrains installation and adds collection-test tools.
.azure-pipelines/​cpu-unit-test.yml Constrains installation and stops on setup failures.
.azure-pipelines/​ansible-integration-test.yml Constrains integration dependencies and stops on setup failures.

Review effort: Balanced

Comment thread dockerfile/cuda11.1.1.dockerfile Resolved
Comment thread requirements/ansible.txt Resolved
Copilot AI balanced review requested due to automatic review settings November 17, 2026 03:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Both affected Dockerfiles use a collection-path variable ignored by Ansible 2.10, causing plugins to install under /root where the workspace mount hides them from control-node use.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread dockerfile/rocm6.3.x.dockerfile Resolved
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.36%. Comparing base (c548e79) to head (5e05ae3).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #900   +/-   ##
=======================================
  Coverage   86.36%   86.36%           
=======================================
  Files         107      107           
  Lines        8258     8258           
=======================================
  Hits         7132     7132           
  Misses       1126     1126           
Flag Coverage Δ
cpu-python3.12-unit-test 71.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI balanced review requested due to automatic review settings November 25, 2026 00:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The legacy Ansible engine lacks a Jinja2 upper bound in package metadata, allowing ordinary installs on Python 3.8–3.10 to resolve incompatible Jinja2 versions and fail.

No open issues 🎉

5 previously missed issues

In code that hasn't changed since last review

High severity Add the legacy Jinja2 bound to package metadata

setup.py:171

The legacy engine is selected for ordinary pip install ., but its Jinja2 compatibility bound exists only in the optional constraints file. The documented control-node install (docs/getting-started/installation.mdx:71) does not use that file, so Python 3.8–3.10 can still resolve Jinja2 3.1+, whose removed filter imports break Ansible 2.10. Add the legacy Jinja2 upper bound to package metadata so every supported installation path gets a compatible pair.

Medium severity Validate conflicts, dependencies, paths, and plugin support

Makefile:25

The PR promises conflict, dependency-drift, collection-shadowing and plugin-support checks, but this recipe only selects collection versions and trusts Galaxy's exit code. In an existing environment, make postinstall can therefore succeed without establishing that Ansible loads the selected profile. Add the promised distribution-conflict check before installation and validate installed Python dependencies, effective collection paths and plugin engine support before reporting success.

Medium severity Add a hard-kill deadline for timed-out acquisitions

Makefile:32

timeout 300 sends SIGTERM but has no hard kill deadline, so an acquisition that ignores the signal can block indefinitely and prevent retries or exhaustion failure. Add a finite --kill-after grace period and update the timeout stub and command assertion in tests/runner/test_ansible.py:33,67 to handle the extra option.

Medium severity Add the promised BuildKit cache checks or revise merge gates

docs/​developer-guides/​development.md:46

The PR description claims real cold-build, cache-reuse and invalidation checks, but .github/workflows/build-image.yml:168–185 still performs only one cache-importing build. Add the promised BuildKit checks, with forced cold builds gated on dependency or Dockerfile changes, or revise the stated merge gates to reflect the checks that actually exist.

Medium severity Test Python 3.11 and 3.13+ engine profiles in CI

requirements/​ansible.txt:7

The CPU matrix still runs only Python 3.7, 3.10 and 3.12, leaving the distinct 3.11 and 3.13+ engine profiles untested there. The new tests mock Galaxy or run only the built-in shell module, so they do not verify the pinned collections' production behavior. Add clean-install profile CI for 3.11 and 3.13 with real key-generation, rank-lookup and result-fetch checks.

2 resolved since last review

Review effort: Balanced

@gusui-msft
gusui-msft force-pushed the gusui-msft/ansible-dependency-reliability-20261116 branch from 5e05ae3 to 9748b96 Compare November 30, 2026 19:35
Copilot AI balanced review requested due to automatic review settings November 30, 2026 19:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Installation reproducibility and profile compatibility remain unverified due to incomplete dependency pinning, missing install validation, an unupdated CUDA 13.5 variant, and insufficient cache and collection tests.

5 open issues

Review effort: Balanced

Comment thread Makefile Resolved
Comment thread Makefile Resolved
Comment thread docs/developer-guides/development.md Resolved
Comment thread docs/developer-guides/development.md Resolved
Comment thread requirements/ansible.txt Resolved
@gusui-msft
gusui-msft force-pushed the gusui-msft/ansible-dependency-reliability-20261116 branch from 9748b96 to 6a0e811 Compare December 2, 2026 22:56
Copilot AI balanced review requested due to automatic review settings December 2, 2026 22:56
@gusui-msft gusui-msft changed the title CI/CD - Freeze Ansible dependencies and reuse build layers CI/CD - Pin Ansible dependencies and reuse build layers Dec 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread .azure-pipelines/cpu-unit-test.yml Resolved
Comment thread Makefile Resolved
Comment thread dockerfile/cuda13.4.dockerfile Resolved
@gusui-msft
gusui-msft force-pushed the gusui-msft/ansible-dependency-reliability-20261116 branch from 6a0e811 to d0b6240 Compare December 2, 2026 23:18
Copilot AI balanced review requested due to automatic review settings December 2, 2026 23:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The devcontainer bootstrap omits required Ansible collections, and collection profile selection can choose versions incompatible with the Galaxy runtime in mixed-PATH environments.

5 open issues

Review effort: Balanced

Comment thread Makefile Resolved
Comment thread setup.py Resolved
Pin two direct Ansible profiles (legacy Python <3.11 on ansible-base 2.10.17 / ansible-runner 2.3.1, modern Python >=3.11 on ansible-core 2.19.15 / ansible-runner 2.4.3, with Jinja2 3.1.6 across all runtimes) in requirements/ansible.txt, and select matching legacy/modern collection pins from ansible-galaxy --version with bounded 3x 300s retries in Makefile.

Install the Ansible layer immediately before copying repository source across all seven active Dockerfiles (nine image variants, including CUDA 13.5), constrain subsequent pip installs, and align CI and devcontainer setup scripts.

Add offline retry/timeout/mixed-PATH tests and real local collection smoke tests (SSH key generation idempotency, ansible.utils.index_of, and fetch_results.yaml) in tests/runner/test_ansible.py.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gusui-msft
gusui-msft force-pushed the gusui-msft/ansible-dependency-reliability-20261116 branch from d0b6240 to a21dba7 Compare December 2, 2026 23:34
Copilot AI balanced review requested due to automatic review settings December 2, 2026 23:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The Ansible installation and dependency-profile changes have no active review issues.

1 open issue
4 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants