Run and operate the Artefact Validations#
Task-oriented guides for deploying, configuring, and operating the SKA CI/CD Artefact Validations service (Marvin). For the full configuration reference see Endpoints, toggles, configuration, and metrics; for concepts and design rationale see How the Artefact Validations service works.
Prerequisites#
To run the service you need:
A Redis broker for Celery, and a MongoDB instance for audit records (the Helm chart can deploy both as subcharts).
Credentials for Harbor (
HARBOR_URL/HARBOR_USERNAME/HARBOR_PASSWORD/HARBOR_TOKEN) and Nexus (NEXUS_URL/NEXUS_API_USERNAME/NEXUS_API_PASSWORD/NEXUS_HMAC_SIGNATURE_SECRET).A GitLab token for Marvin (
GITLAB_API_REQUESTER=marvin-42-service,GITLAB_API_PRIVATE_TOKEN) so it can open merge requests.An Unleash feature-flag backend, reached through the Unleash Proxy (
UNLEASH_PROXY_URL/UNLEASH_PROXY_SDK_TOKEN/UNLEASH_ENVIRONMENT).For SBOM signing: a HashiCorp Vault with an AppRole and the
oci-pkiPKI mount (VAULT_URL,VAULT_AUTH_APPROLE_ROLE_ID,VAULT_AUTH_APPROLE_SECRET_ID,VAULT_OCI_PKI_URI), and thenotationbinary on the worker image.An
OPENID_SECRETfor the FastAPI session middleware.
Deploy with the Helm chart#
The chart lives in charts/ska-cicd-artefact-validations. It installs the
FastAPI webhook receiver (a Deployment running fastapi run), a Celery
worker Deployment, and bundled MongoDB and Redis
subcharts, an Ingress exposing /harbor, /nexus, and /metrics,
and the Secrets that carry configuration and credentials.
Configuration is supplied through global.env values (rendered into
Kubernetes Secrets) plus a file-based config block. The simplest install
sets the mandatory global.env values and accepts the defaults:
helm install marvin charts/ska-cicd-artefact-validations \
--set global.env.harbor_url=https://harbor.skao.int/api/v2.0 \
--set global.env.harbor_username=<harbor username> \
--set global.env.harbor_password=<harbor password> \
--set global.env.harbor_token=<webhook-token> \
--set global.env.nexus_url=https://artefact.skao.int \
--set global.env.nexus_api_username=<nexus username> \
--set global.env.nexus_api_password=<nexus password> \
--set global.env.nexus_hmac_signature_secret=<secret> \
--set global.env.gitlab_api_requester=marvin-42-service \
--set global.env.gitlab_api_private_token=<gitlab token> \
--set global.env.mongo_url=<mongo-uri> \
--set global.env.mongo_db=Artifact_Metadata \
--set global.env.mongo_col=Artefact_Validation \
--set redis.auth.password=<password> \
--set global.env.openid_secret=<secret> \
--set global.env.unleash_proxy_url=<proxy-url> \
--set global.env.unleash_proxy_sdk_token=<token> \
--set global.env.unleash_environment=production-celery \
--set global.env.vault_url=<vault-url> \
--set global.env.vault_auth_approle_role_id=<role-id> \
--set global.env.vault_auth_approle_secret_id=<secret-id> \
--set global.env.vault_oci_pki_uri=<pki-common-name>
Note
Most keys under global.env are marked mandatory in values.yaml.
In practice these are populated from Vault at deploy time rather than typed
on the command line. The full list of environment variables and their
consumers is in Endpoints, toggles, configuration, and metrics.
The Celery broker password is the exception: it comes from the bundled
redis subchart (redis.auth.password), not from
global.env.redis_password, which the chart declares but never consumes.
Optionally, you can deploy the service with the cicd_validations Ansible role
(ska_collections.k8s.cicd_validations, from the
ska-ser-ansible-collections collection) instead of running helm by
hand. The role renders the chart’s values from role variables and applies the
release with kubernetes.core.helm, so a playbook only supplies the
deployment’s configuration and secrets:
k8s_cicd_validations_config(extended throughk8s_cicd_validations_extra_config) — the non-secret settings for Harbor, Nexus, GitLab, Vault, MongoDB, Redis, and Unleash.k8s_cicd_validations_secrets— the mandatory credentials: the Harbor password and token, the Nexus password and HMAC secret, the GitLab token, the Vault AppRole role and secret IDs, the OpenID secret, and the Unleash Proxy keys and token.k8s_cicd_validations_app_config— the behaviouralconfigblock described in Configure the service behaviour.k8s_cicd_validations_helm_chart_version— the published chart version to deploy, pulled from thehelm-internalrepository.
The role can also stand up an Unleash Proxy alongside the service (its
deploy_unleash_proxy tasks) and tear both down again (its destroy
tasks).
Configure the service behaviour#
The behavioural settings (as opposed to credentials) live under config
in values.yaml and are mounted into both processes as config.yml:
config:
harbor:
promotion_repository: "production" # target project for promotion
query_retries: 5 # vulnerability-report poll attempts
query_retry_delay_s: 30 # delay between those attempts
signature_check_retries: 5 # signature poll attempts
signature_check_retry_delay_s: 30 # delay between signature checks
verify_sbom_signature: false # also require the SBOM to be signed
vulnerability_severity: "Critical" # min severity that blocks promotion
promote: true
delete: false # delete the staging source on promote
nexus:
quarantine: true
delete: true # delete the source on quarantine
metrics:
prometheus_multiproc_dir: "/metrics-registry"
Warning
The Helm chart ships promotion_repository: "test-promotion" in its
default values.yaml. Set it to production for a real deployment, or
promotions will land in the wrong project.
Register the webhooks#
The service only does work when Harbor and Nexus point their webhooks at it.
Expose the service (through the Ingress in a cluster, or a tunnel such as
Ngrok for local testing) and configure:
Harbor — add two HTTP webhooks, on two projects, each under the project’s
Webhooks. Both use an Auth Header matching HARBOR_TOKEN:
On the staging project, event Artifact pushed:
<base-url>/harbor(drives validation and promotion).On the production project, event Scanning finished:
<base-url>/harbor/sbom_sign(drives SBOM signing of the promoted image).
Nexus — create a Webhook: Repository capability on the repository, select
the component event type, point the URL at <base-url>/nexus, and set the
Secret Key to NEXUS_HMAC_SIGNATURE_SECRET (Nexus signs the payload with
HMAC-SHA1, sent in X-Nexus-Webhook-Signature).
Add a compliance check#
Checks are discovered automatically: at import time import_check_classes()
scans src/ska_cicd_artefact_validations/checks and registers every class
whose name starts with Check. There is no central registry to edit, adding
a file is enough. See How the Artefact Validations service works for how the
framework runs checks and Endpoints, toggles, configuration, and metrics for the checks
that ship today.
Create a file named
check_<something>.pyin thechecksdirectory, subclassingCheck(the class name must start withCheck):from ska_cicd_artefact_validations.core.artefact import Artefact from ska_cicd_artefact_validations.core.check import Check from ska_cicd_artefact_validations.core.message_generator import ( MessageType, ) class CheckThisIsANewCheck(Check): # The toggle must also be created in the GitLab feature flags. feature_toggle = "new_check_toggle" def __init__(self): # Add any APIs you need here, with type hints. pass async def check(self, artefact: Artefact) -> bool: # True = passed; False fails validation. return True async def type(self) -> MessageType: # FAILURE blocks the MR; WARNING and INFO do not. return MessageType.FAILURE async def description(self) -> str: return "Description that appears in the Marvin comment." async def mitigation_strategy(self) -> str: return "How the developer should fix the problem."
Add the
new_check_togglefeature flag in the GitLab project under Deploy > Feature flags so the check can be enabled and disabled at runtime.Add unit tests under
tests/unit(the check is picked up by the existing test framework) and run them as shown in Run the tests locally.
Enable and disable feature toggles#
Checks and behaviours are governed by Unleash feature flags, managed in the GitLab project under Deploy > Feature flags. Toggling a flag takes effect without a redeploy (the client refreshes every 60 seconds). The available toggles and their effects are listed in Endpoints, toggles, configuration, and metrics.
To skip one check for a single artefact, enable the corresponding
<toggle>-excluded strategy scoped to that artefact’s name (the check
framework passes the artefact name as the Unleash userId).
Investigate an image that never gets promoted#
If require-signatures is on and an image is never promoted, its
main_task is retrying (or has exhausted its retries and failed) because the
signatures have not appeared. To diagnose, inspect the worker logs and the
artefact’s accessories in Harbor:
Confirm it is the signature gate. The worker logs that the artefact is “not fully signed yet” while it polls in-handler (
signature_check_retries×signature_check_retry_delay_s), then anArtefactNotSignedError(Artefact <ref> is not signed.); the task is then retried every 10 minutes for up to an hour before failing.Check the image signature. Inspect the artefact’s accessories in Harbor for a
signature.notationentry. For a multi-platform image, the index and every child manifest must each be signed, so check the index and every platform. If one is missing, the external image signer did not run for it — this service cannot produce it.Check the SBOM. Confirm each manifest has an
sbom.harboraccessory (for a multi-platform image, check every child manifest except theunknown/unknownBuildKit attestation manifests whose layers are allapplication/vnd.in-toto+json, which only need a signature) and — unlessverify_sbom_signatureis disabled — that the SBOM itself has a nestedsignature.notationaccessory. If an SBOM is missing or unsigned, check the/harbor/sbom_signflow: was theSCANNING_COMPLETEDwebhook delivered, issign-sbomenabled, and did Vault/Notation succeed in the worker logs? Harbor sends that event type twice per artefact and only the SBOM scan’s copy is acted on, so anIgnoring Harbor SBOM sign requestline for the vulnerability scan is expected, not a fault.Recover. Re-push the image (or fix the signing chain) to restart the flow, or — without re-pushing — re-trigger the validation as described in Re-trigger a Harbor validation. Once all signatures are present the next cycle promotes the image.
Re-trigger a Harbor validation#
When a legitimate artefact fails to promote — a transient error during
validation, or signatures that only appeared after the retry budget was
exhausted — you do not need to re-push the image. Marvin validates whatever a
Harbor PUSH_ARTIFACT webhook describes, so replaying that webhook re-runs
the whole flow (checks, vulnerability gate, signature gate, promotion) against
the artefact as it exists now.
Send a minimal PUSH_ARTIFACT event to the /harbor endpoint with the
authorization header set to the value of HARBOR_TOKEN (the same secret
the real Harbor webhook uses):
curl -X POST "<base-url>/harbor" \
-H "authorization: $HARBOR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "PUSH_ARTIFACT",
"occur_at": <timestamp>,
"operator": "admin",
"event_data": {
"resources": [
{
"digest": "<digest of oci index or oci image>",
"tag": "<tag>",
"resource_url": "harbor.skao.int/<staging project>/<image>:<tag>"
}
],
"repository": {
"name": "<image>",
"namespace": "<staging project>",
"repo_full_name": "<staging project>/<image>",
"repo_type": "public"
}
}
}'
Building the payload — read the values off the artefact’s page in Harbor (or its API); everything else is fixed or free-form:
Field |
Value |
|---|---|
|
Must be |
|
Event time in epoch seconds — any value works (e.g. |
|
Free-form string identifying who replayed it (e.g. |
|
The Harbor project (e.g. |
|
The repository name (e.g. |
|
|
|
The tag to validate (e.g. |
|
The artefact’s manifest digest, used to look up its SBOM and signature accessories. |
|
|
Note
Extra Harbor fields (date_created, repo_type, …) are accepted and
ignored, so you can paste a real webhook body verbatim. To re-run only
SBOM signing, post a SCANNING_COMPLETED body to /harbor/sbom_sign the
same way, remembering to include "scan": {"scan_type": "sbom"} — without
it the event is acknowledged but ignored.
Run the tests locally#
Run the tests through the make target, which sets the required environment
variables for you (OPENID_SECRET to import the FastAPI app and
UNLEASH_INACTIVE to skip contacting Unleash) and produces the coverage and
JUnit reports:
make python-test
The suite covers the handlers, the signature gate, the SBOM-signing sign-once path, the webhooks, the checks, and the Celery tasks.
Build the documentation#
Build the HTML docs through the make target:
make docs-build clean html
The rendered site is written to docs/build/html.
Run the dangling-signature cleanup#
scripts/delete_dangling_sbom_signature_artifacts.py removes signature
artefacts whose referenced SBOM no longer exists. It is wired into CI as the
scheduled clean-dangling-signature-artifacts job (it runs only on
schedule pipelines):
clean-dangling-signature-artifacts:
stage: schedule
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
script:
- uv sync
- uv run python scripts/delete_dangling_sbom_signature_artifacts.py
To run it by hand, set its environment and invoke it:
export HARBOR_URL=https://harbor.skao.int/api/v2.0
export DELETE_DANGLING_SIGNATURE_ARTIFACTS_PROJECT=production
export ROBOT_DELETE_DANGLING_SIGNATURE_ARTIFACTS_ACCOUNT_USERNAME=<robot>
export ROBOT_DELETE_DANGLING_SIGNATURE_ARTIFACTS_ACCOUNT_SECRET=<secret>
uv run python scripts/delete_dangling_sbom_signature_artifacts.py
Note
HARBOR_URL includes the /api/v2.0 suffix here, the same form the
service expects.