Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions docs/configuring/hpc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ while dependencies, artifact names and publishing work as for any other kind.
How it works
------------

The job itself runs on a small runner group, ``hpc-submit`` (see :doc:`../reference/runners`).
The job itself runs on the runner group ``hpc`` (see :doc:`../reference/runners`),
in the ``atos-citester`` image, whose ssh configuration connects as the ``citester`` user.
This runner downloads the dependencies from the artifact store, ships them together with the source to the HPC,
and submits the build script through `troika <https://github.com/ecmwf/troika>`__.
Once the job has finished, it copies the install tree back and uploads it to the artifact store.
Expand All @@ -28,16 +29,16 @@ The manifest
[matrix.build-hpc]
execution = "hpc-atos"
triggers = ["upstream-change", "rebuild-request"]
container-credentials = true
container-credentials = "ECCR_PULL_ATOS_CITESTER"

[matrix.build-hpc.defaults]
job-script = "./.ci/hpc/build.sh.j2"
platform = "hpc-atos-gnu"
cxx-compiler = "g++-8"
fortran-compiler = "gfortran-8"
build-type = "RelWithDebInfo"
runs-on = "hpc-submit"
container = "eccr.ecmwf.int/private-ci-images/ubuntu24.04-internal-tools:latest"
runs-on = "hpc"
container = "eccr.ecmwf.int/private-ci-images-atos-citester/ubuntu24.04-hpc-runner:latest"
site = "hpc-batch"
modules = ["load prgenv/gnu", "unload gcc", "load gcc/old", "load cmake", "load ninja"]
c-compiler-binary = "gcc"
Expand All @@ -51,6 +52,9 @@ The manifest
[[matrix.build-hpc.include]]
options = "eckit-geo"

``container-credentials`` names the pair of secrets the image is pulled with,
here ``ECCR_PULL_ATOS_CITESTER_NAME`` and ``ECCR_PULL_ATOS_CITESTER_TOKEN``;
``true`` stands for ``ECCR_PULL_ROBOT_NAME`` and ``ECCR_PULL_ROBOT_TOKEN``.
``job-script`` points to the build script, and every field of a leg is passed to it.
It is a leg field, so a leg may bring its own build script.
A build on the HPC usually needs control over the exact modules, the job's resources and the like,
Expand Down Expand Up @@ -84,15 +88,15 @@ The above manifest would then require two hand-written shell scripts and look li
[matrix.build-hpc]
execution = "hpc-atos"
triggers = ["upstream-change", "rebuild-request"]
container-credentials = true
container-credentials = "ECCR_PULL_ATOS_CITESTER"

[matrix.build-hpc.defaults]
platform = "hpc-atos-gnu"
cxx-compiler = "g++-8"
fortran-compiler = "gfortran-8"
build-type = "RelWithDebInfo"
runs-on = "hpc-submit"
container = "eccr.ecmwf.int/private-ci-images/ubuntu24.04-internal-tools:latest"
runs-on = "hpc"
container = "eccr.ecmwf.int/private-ci-images-atos-citester/ubuntu24.04-hpc-runner:latest"
site = "hpc-batch"

[[matrix.build-hpc.include]]
Expand Down
5 changes: 3 additions & 2 deletions docs/configuring/job-scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,12 @@ and a new Python is added upstream first.
[matrix.test-hpc]
execution = "hpc-atos"
publishes = false
container-credentials = "ECCR_PULL_ATOS_CITESTER"

[[matrix.test-hpc.include]]
job-script = "./.ci/test.sh.j2"
runs-on = "hpc-submit"
container = "eccr.ecmwf.int/private-ci-images/ubuntu24.04-internal-tools"
runs-on = "hpc"
container = "eccr.ecmwf.int/private-ci-images-atos-citester/ubuntu24.04-hpc-runner:latest"
site = "hpc-batch"
platform = "hpc-atos"
modules = ["load uv"]
Expand Down
5 changes: 3 additions & 2 deletions docs/reference/hpc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The flow of a job

::

hpc-submit runner
hpc runner
resolve -> fetch deps (S3) -> submit -> ship source, deps, marker -> wait -> fetch install -> publish
| ^
v troika | Finished: SUCCESS/FAILURE
Expand Down Expand Up @@ -225,7 +225,8 @@ Cluster configuration
- ``vars.HPC_CI_REMOTE_WORK_DIR`` is the base directory on the cluster, recommended ``$SCRATCH/github-ci``.
It is expanded on the cluster, in a login shell, and must yield an absolute path.
- ``vars.HPC_CI_WORK_DIR`` is a scratch directory on the runner, by default ``$RUNNER_TEMP``.
- ``secrets.HPC_CI_SSH_USER`` optionally sets the user on the cluster.
- ``secrets.HPC_CI_SSH_USER`` optionally sets the user on the cluster for the HPC actions;
the generated HPC jobs leave it to the image's ssh configuration.

On ECMWF's Atos, staging and install go to ``$SCRATCH``, shared Lustre with a 30-day purge,
and the build to ``$TMPDIR``, the node-local SSD, whose size ``ssdtmp`` requests.
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/runners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ The following runner groups for the CI exist on the self-hosted Kubernetes clust
- 4 / 16
- 8 / 32 GiB
- 50 GiB
* - ``hpc-submit``
* - ``hpc``
- —
- —
- 50 GiB

The HPC is reached through the runner group ``hpc-submit``.
These runners are small and cheap and are not meant for heavy lifting.
The HPC is reached through the runner group ``hpc``, virtual machines at ECMWF.
They are not meant for heavy lifting.
They ship sources and dependencies to the HPC and submit the job to the queue.
Afterwards they copy the artifacts back and store it in S3.
See :doc:`../configuring/hpc`.
Expand Down
6 changes: 2 additions & 4 deletions src/ci_infrastructure/ci_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
_reader_mint_step,
_rebuild_job,
_render_doc,
container_credentials,
upstream_repos,
)
from .manifest import FROM_DEPENDENCIES_RE, VISIBILITY_PUBLIC
Expand Down Expand Up @@ -183,10 +184,7 @@ def _kind_job(m: Manifest, kind: str, *, repos: Sequence[str], waits: Mapping[st

container: dict[str, Any] = {"image": "${{ matrix.container || '' }}"}
if mk.container_credentials:
container["credentials"] = {
"username": "${{ secrets.ECCR_PULL_ROBOT_NAME }}",
"password": "${{ secrets.ECCR_PULL_ROBOT_TOKEN }}",
}
container["credentials"] = container_credentials(mk.container_credentials)
# `build` runs the tests too, unless a `test` kind does.
title = "build+test" if kind == "build" and "test" not in ci_kinds(m) else kind
return {
Expand Down
14 changes: 8 additions & 6 deletions src/ci_infrastructure/generate_downstream_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class MatrixKind:
legs: Sequence[dict[str, Any]] # after reuse-matrix resolution
execution: Execution
publishes: bool
container_credentials: bool
container_credentials: bool | str
artifact_prefix: str | None = None
# The prefixes this kind publishes; empty when it publishes nothing.
packages: tuple[str, ...] = ()
Expand Down Expand Up @@ -985,6 +985,12 @@ def _job_script_step(m: Manifest, mk: MatrixKind) -> Step:
}


def container_credentials(value: bool | str) -> dict[str, str]:
"""The registry credentials of `container-credentials`: `true` or a secret-pair prefix."""
prefix = "ECCR_PULL_ROBOT" if value is True else value
return {"username": f"${{{{ secrets.{prefix}_NAME }}}}", "password": f"${{{{ secrets.{prefix}_TOKEN }}}}"}


def _hpc_build_step(mk: MatrixKind) -> Step:
"""Submit the leg's recipe to the cluster; the action also publishes."""
with_block: dict[str, str] = {
Expand All @@ -995,7 +1001,6 @@ def _hpc_build_step(mk: MatrixKind) -> Step:
"cmake-prefix-path": "${{ steps.deps.outputs.cmake-prefix-path }}",
"work-dir": "${{ vars.HPC_CI_WORK_DIR }}",
"remote-work-dir": "${{ vars.HPC_CI_REMOTE_WORK_DIR }}",
"troika-user": "${{ secrets.HPC_CI_SSH_USER }}",
}
if not mk.publishes:
with_block["publish"] = "false"
Expand Down Expand Up @@ -1192,10 +1197,7 @@ def _kind_job(m: Manifest, kind: str, cross: Sequence[JobRef], repos: Sequence[s
# An empty image runs on the host. HPC legs need it too: the ssh identity lives in the image.
container: dict[str, Any] = {"image": "${{ matrix.container || '' }}"}
if mk.container_credentials:
container["credentials"] = {
"username": "${{ secrets.ECCR_PULL_ROBOT_NAME }}",
"password": "${{ secrets.ECCR_PULL_ROBOT_TOKEN }}",
}
container["credentials"] = container_credentials(mk.container_credentials)
job["container"] = container
job["strategy"] = {
"fail-fast": False,
Expand Down
17 changes: 14 additions & 3 deletions src/ci_infrastructure/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
BaseModel,
ConfigDict,
Field,
StrictBool,
StrictInt,
ValidationError,
ValidationInfo,
Expand Down Expand Up @@ -518,11 +519,12 @@ class MatrixKindTable(_Table):
"`[package]`, or every `[packages]` entry when `[package]` is `meta`. With `publishes = false`, the "
"packages it builds and tests against their deps without publishing them.",
)
container_credentials: bool = Field(
strict=True,
container_credentials: StrictBool | str = Field(
default=False,
alias="container-credentials",
description="Pull the leg's `container` with registry credentials.",
description="Pull the leg's `container` with registry credentials: `true` for the "
'`ECCR_PULL_ROBOT_NAME`/`_TOKEN` secrets, or the prefix of another pair, e.g. `"ECCR_PULL_ATOS_CITESTER"` '
"for `ECCR_PULL_ATOS_CITESTER_NAME`/`_TOKEN`.",
)
ci: bool = Field(
strict=True,
Expand Down Expand Up @@ -566,6 +568,15 @@ def _artifact_prefix_shape(cls, v: str | None) -> str | None:
)
return stripped

@field_validator("container_credentials")
@classmethod
def _credentials_prefix(cls, v: bool | str) -> bool | str:
if isinstance(v, str) and not re.fullmatch(r"[A-Z][A-Z0-9_]*", v):
raise ValueError(
f"container-credentials must be true, false or a secret prefix like ECCR_PULL_ROBOT; got {v!r}"
)
return v


class GeneratedTable(_Table):
"""`[generated]`: how the generated workflows are written."""
Expand Down
17 changes: 16 additions & 1 deletion tests/test_generate_hpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def hpc_yaml(tmp_path: Path) -> str:
"site: ${{ matrix.site }}",
"actions/fetch-deps@main",
"cmake-prefix-path: ${{ steps.deps.outputs.cmake-prefix-path }}",
"troika-user: ${{ secrets.HPC_CI_SSH_USER }}",
"stage-only: 'true'",
"runs-on: ${{ matrix['runs-on'] }}",
"image: ${{ matrix.container || '' }}",
Expand Down Expand Up @@ -131,6 +130,22 @@ def test_container_credentials_are_opt_in(tmp_path: Path) -> None:
assert "password: ${{ secrets.ECCR_PULL_ROBOT_TOKEN }}" in yaml


def test_container_credentials_name_a_secret_pair(tmp_path: Path) -> None:
yaml = render_single(
tmp_path,
_HPC_MANIFEST.replace(
'execution = "hpc-atos"', 'execution = "hpc-atos"\ncontainer-credentials = "ECCR_PULL_ATOS_CITESTER"'
),
EXECUTION_HPC_ATOS,
)
assert "username: ${{ secrets.ECCR_PULL_ATOS_CITESTER_NAME }}" in yaml
assert "password: ${{ secrets.ECCR_PULL_ATOS_CITESTER_TOKEN }}" in yaml


def test_hpc_job_leaves_the_user_to_the_image(hpc_yaml: str) -> None:
assert "troika-user" not in hpc_yaml


def test_legs_differing_only_by_site_collide(tmp_path: Path) -> None:
"""`site` is scheduling, not artifact identity."""
write_repo(
Expand Down
Loading