From e22a44a68eef36142b32e937ff27273c05e0ce67 Mon Sep 17 00:00:00 2001 From: mtalvi Date: Tue, 1 Dec 2026 12:58:41 +0200 Subject: [PATCH 1/2] Add optional Trustee bootstrap and require installed OSC for Kata --- .github/workflows/deployment-validation.yml | 6 + Makefile-quickstart | 4 + README.md | 5 + charts/openshell-rhdh/files/portal.py | 3 + charts/openshell-rhdh/files/preflight.py | 44 ++++ .../templates/osc-preflight-rbac.yaml | 24 +++ charts/saw-portal-container/files/enroll.py | 3 + .../saw-portal-container/files/preflight.py | 44 ++++ .../templates/auto-enroll.yaml | 14 ++ charts/saw-trustee/Chart.yaml | 5 + charts/saw-trustee/templates/trustee.yaml | 35 ++++ charts/saw-trustee/values.schema.json | 27 +++ charts/saw-trustee/values.yaml | 10 + charts/saw-users/files/preflight.py | 44 ++++ charts/saw-users/files/projector.py | 5 + charts/saw-users/templates/projector.yaml | 14 ++ docs/README.md | 3 + docs/deployment-guide.md | 9 +- docs/deployment-validation-ci.md | 1 + docs/kata-workspaces.md | 15 +- docs/trustee-validation-2026-12-01.md | 75 +++++++ docs/trustee.md | 195 ++++++++++++++++++ overrides/values-confidential-disabled.yaml | 2 + overrides/values-confidential.yaml | 42 ++++ scripts/check-sandboxed-operator.py | 39 ++++ scripts/ci/check_confidential_pattern.py | 79 +++++++ scripts/ci/deployment_validation.py | 2 + .../trusteeconfig_v1alpha1.json | 134 ++++++++++++ scripts/ci/vendor_crd_schemas.py | 1 + scripts/saw-profile-catalog.py | 4 + tests/charts/test_openshell_rhdh_chart.py | 6 + tests/charts/test_portal_container.py | 23 +++ tests/charts/test_saw_trustee.py | 94 +++++++++ tests/portal/test_portal.py | 29 +++ tests/scripts/test_sandboxed_operator.py | 49 +++++ tests/scripts/test_saw_preflight.py | 5 + tests/scripts/test_standalone_projector.py | 10 + values-global.yaml | 4 + values-prod.yaml | 4 + 39 files changed, 1110 insertions(+), 2 deletions(-) create mode 100644 charts/openshell-rhdh/templates/osc-preflight-rbac.yaml create mode 100644 charts/saw-trustee/Chart.yaml create mode 100644 charts/saw-trustee/templates/trustee.yaml create mode 100644 charts/saw-trustee/values.schema.json create mode 100644 charts/saw-trustee/values.yaml create mode 100644 docs/trustee-validation-2026-12-01.md create mode 100644 docs/trustee.md create mode 100644 overrides/values-confidential-disabled.yaml create mode 100644 overrides/values-confidential.yaml create mode 100644 scripts/check-sandboxed-operator.py create mode 100644 scripts/ci/check_confidential_pattern.py create mode 100644 scripts/ci/schemas/confidentialcontainers.org/trusteeconfig_v1alpha1.json create mode 100644 tests/charts/test_saw_trustee.py create mode 100644 tests/scripts/test_sandboxed_operator.py diff --git a/.github/workflows/deployment-validation.yml b/.github/workflows/deployment-validation.yml index c40db22cf..b9f29464e 100644 --- a/.github/workflows/deployment-validation.yml +++ b/.github/workflows/deployment-validation.yml @@ -35,6 +35,12 @@ jobs: sudo install -m 0755 "$RUNNER_TEMP/kubeconform" /usr/local/bin/kubeconform - name: Validate deployment and dependencies run: make test-dependencies + - name: Validate optional Trustee pattern selection and propagation + run: | + helm pull clustergroup --repo https://charts.validatedpatterns.io \ + --version 0.9.61 --untar --untardir "$RUNNER_TEMP/saw-pattern-check" + uv run --locked scripts/ci/check_confidential_pattern.py \ + --chart "$RUNNER_TEMP/saw-pattern-check/clustergroup" - uses: actions/upload-artifact@v4 if: always() with: diff --git a/Makefile-quickstart b/Makefile-quickstart index 81003e375..adb052b57 100644 --- a/Makefile-quickstart +++ b/Makefile-quickstart @@ -594,6 +594,10 @@ e2e-workspace: .check-saw-name .check-deployment-mode ## Check one workspace end test-dependencies: ## Validate rendered charts and deployment dependencies @uv run --locked scripts/ci/deployment_validation.py --report deployment-validation.json +.PHONY: kata-operator-check +kata-operator-check: ## Check the installed OSC Subscription and CSV before adding Kata users + @python3 scripts/check-sandboxed-operator.py + test-pattern-e2e: ## Run E2E checks on a fresh cluster; cleanup is separate @uv run --locked scripts/ci/pattern_e2e.py diff --git a/README.md b/README.md index 68a0fa0ed..45d33307b 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,11 @@ More detail: [deployment guide](docs/deployment-guide.md), endpoint. - Kata workspaces also need OpenShift sandboxed containers ([Kata guide](docs/kata-workspaces.md)). + The pattern installs its operator; Kata registration requires its installed + CSV to be `Succeeded`, in addition to runtime and worker readiness. +- Optional Red Hat build of Trustee installation is controlled by + `global.confidential.enabled` ([Trustee setup](docs/trustee.md)). It defaults + to false and does not activate confidential workspaces by itself. ## Installation diff --git a/charts/openshell-rhdh/files/portal.py b/charts/openshell-rhdh/files/portal.py index 812966d72..63d217493 100644 --- a/charts/openshell-rhdh/files/portal.py +++ b/charts/openshell-rhdh/files/portal.py @@ -988,6 +988,9 @@ def check_workspace_preflight(k8s, user, site, mode, profile, catalog): configs = k8s.call("GET", "/apis/kataconfiguration.openshift.io/v1/kataconfigs").get("items", []) nodes = k8s.call("GET", "/api/v1/nodes").get("items", []) kata_crd = "kataconfigs.kataconfiguration.openshift.io" + api_readiness["sandboxedOperator"] = _preflight.sandboxed_operator_ready( + k8s.call("GET", _preflight.OSC_SUBSCRIPTIONS_PATH).get("items"), + k8s.call("GET", _preflight.OSC_CSVS_PATH).get("items")) api_readiness[kata_crd] = _preflight.crd_established(k8s.call( "GET", "/apis/apiextensions.k8s.io/v1/customresourcedefinitions/" + kata_crd, ok404=True)) diff --git a/charts/openshell-rhdh/files/preflight.py b/charts/openshell-rhdh/files/preflight.py index dc499183c..a213e21a1 100644 --- a/charts/openshell-rhdh/files/preflight.py +++ b/charts/openshell-rhdh/files/preflight.py @@ -40,6 +40,10 @@ def __init__(self, reason): "storage", "secrets", "registry", "providerEgress", "revisions", ) KATA_CHECKS = ("osc", "kataConfig", "workers", "runtimeClass") +OSC_NAMESPACE = "openshift-sandboxed-containers-operator" +OSC_API = "/apis/operators.coreos.com/v1alpha1/namespaces/" + OSC_NAMESPACE +OSC_SUBSCRIPTIONS_PATH = OSC_API + "/subscriptions" +OSC_CSVS_PATH = OSC_API + "/clusterserviceversions" # This pinned image has /sandbox mode 0770, owned by 1000:0. The OpenShift # namespace UID cannot traverse it. The reviewed notebook build adds o+x. @@ -368,6 +372,44 @@ def crd_established(obj): and condition.get("status") == "True" for condition in conditions) +def sandboxed_operator_ready(subscriptions, csvs): + """Require the OSC Subscription's installed CSV, not a leftover Kata CRD.""" + if not isinstance(subscriptions, list) or not isinstance(csvs, list): + return False + installed = set() + for csv in csvs: + if not isinstance(csv, dict): + continue + metadata, status = csv.get("metadata") or {}, csv.get("status") or {} + if (isinstance(metadata, dict) and isinstance(status, dict) + and metadata.get("namespace") == OSC_NAMESPACE + and not metadata.get("deletionTimestamp") + and status.get("phase") == "Succeeded"): + name = metadata.get("name") + if isinstance(name, str): + installed.add(name) + for subscription in subscriptions: + if not isinstance(subscription, dict): + continue + metadata = subscription.get("metadata") or {} + spec, status = subscription.get("spec") or {}, subscription.get("status") or {} + if not all(isinstance(value, dict) for value in (metadata, spec, status)): + continue + if (metadata.get("namespace") != OSC_NAMESPACE or metadata.get("deletionTimestamp") + or spec.get("name") != "sandboxed-containers-operator"): + continue + conditions = status.get("conditions") or [] + if not isinstance(conditions, list) or any( + isinstance(item, dict) and item.get("status") == "True" + and item.get("type") in {"ResolutionFailed", "InstallPlanFailed"} + for item in conditions): + continue + name = status.get("installedCSV") + if isinstance(name, str) and name in installed: + return True + return False + + def api_resources_available(discovery, group_version, resource_names): """Check served API resources from discovery, including built-in APIs.""" if not isinstance(discovery, dict) or discovery.get("groupVersion") != group_version: @@ -430,6 +472,8 @@ def verify_kata_platform(site, runtime_class, kata_configs, nodes, api_readiness raise PreflightError("AgentSandboxUnavailable") if api_readiness.get("kataconfigs.kataconfiguration.openshift.io") is not True: raise PreflightError("SandboxedContainersUnavailable") + if api_readiness.get("sandboxedOperator") is not True: + raise PreflightError("SandboxedContainersUnavailable") if not isinstance(kata_configs, list): raise PreflightError("KataConfigNotReady") ready_configs = [item for item in kata_configs diff --git a/charts/openshell-rhdh/templates/osc-preflight-rbac.yaml b/charts/openshell-rhdh/templates/osc-preflight-rbac.yaml new file mode 100644 index 000000000..2553ad29c --- /dev/null +++ b/charts/openshell-rhdh/templates/osc-preflight-rbac.yaml @@ -0,0 +1,24 @@ +{{- if has "kata" .Values.portal.deploymentModes }} +# OLM metadata only, scoped to the platform operator's namespace. +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: saw-portal-osc-preflight + namespace: openshift-sandboxed-containers-operator +rules: + - apiGroups: [operators.coreos.com] + resources: [subscriptions, clusterserviceversions] + verbs: [list] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: saw-portal-osc-preflight + namespace: openshift-sandboxed-containers-operator +roleRef: {apiGroup: rbac.authorization.k8s.io, kind: Role, name: saw-portal-osc-preflight} +subjects: + - {kind: ServiceAccount, name: {{ .Values.portal.provisionerServiceAccount }}, namespace: {{ .Values.portal.namespace }}} +{{- if ne .Values.portal.provisionerServiceAccount "saw-workspaces-generator" }} + - {kind: ServiceAccount, name: saw-workspaces-generator, namespace: {{ .Values.portal.namespace }}} +{{- end }} +{{- end }} diff --git a/charts/saw-portal-container/files/enroll.py b/charts/saw-portal-container/files/enroll.py index cf10cccf7..ac42b74df 100644 --- a/charts/saw-portal-container/files/enroll.py +++ b/charts/saw-portal-container/files/enroll.py @@ -11,6 +11,7 @@ from saw_kubernetes.compiler import compile_profile_files, digest from saw_kubernetes.intent import build_intent from preflight import PreflightError, api_resources_available, crd_established, verify_kata_platform +from preflight import OSC_SUBSCRIPTIONS_PATH, OSC_CSVS_PATH, sandboxed_operator_ready from portal_contract import verify_contract from receipt import receipt_key from gateway_ca import read_public_ca @@ -67,6 +68,8 @@ def obj(kind,name,namespace=ns): if exc.code == 404:raise PreflightError("ClusterVersionUnavailable") from None raise api_readiness={} + api_readiness["sandboxedOperator"]=sandboxed_operator_ready( + api(OSC_SUBSCRIPTIONS_PATH).get("items"), api(OSC_CSVS_PATH).get("items")) for name in ("kataconfigs.kataconfiguration.openshift.io", "sandboxes.agents.x-k8s.io", "externalsecrets.external-secrets.io", "adminnetworkpolicies.policy.networking.k8s.io"): try: diff --git a/charts/saw-portal-container/files/preflight.py b/charts/saw-portal-container/files/preflight.py index dc499183c..a213e21a1 100644 --- a/charts/saw-portal-container/files/preflight.py +++ b/charts/saw-portal-container/files/preflight.py @@ -40,6 +40,10 @@ def __init__(self, reason): "storage", "secrets", "registry", "providerEgress", "revisions", ) KATA_CHECKS = ("osc", "kataConfig", "workers", "runtimeClass") +OSC_NAMESPACE = "openshift-sandboxed-containers-operator" +OSC_API = "/apis/operators.coreos.com/v1alpha1/namespaces/" + OSC_NAMESPACE +OSC_SUBSCRIPTIONS_PATH = OSC_API + "/subscriptions" +OSC_CSVS_PATH = OSC_API + "/clusterserviceversions" # This pinned image has /sandbox mode 0770, owned by 1000:0. The OpenShift # namespace UID cannot traverse it. The reviewed notebook build adds o+x. @@ -368,6 +372,44 @@ def crd_established(obj): and condition.get("status") == "True" for condition in conditions) +def sandboxed_operator_ready(subscriptions, csvs): + """Require the OSC Subscription's installed CSV, not a leftover Kata CRD.""" + if not isinstance(subscriptions, list) or not isinstance(csvs, list): + return False + installed = set() + for csv in csvs: + if not isinstance(csv, dict): + continue + metadata, status = csv.get("metadata") or {}, csv.get("status") or {} + if (isinstance(metadata, dict) and isinstance(status, dict) + and metadata.get("namespace") == OSC_NAMESPACE + and not metadata.get("deletionTimestamp") + and status.get("phase") == "Succeeded"): + name = metadata.get("name") + if isinstance(name, str): + installed.add(name) + for subscription in subscriptions: + if not isinstance(subscription, dict): + continue + metadata = subscription.get("metadata") or {} + spec, status = subscription.get("spec") or {}, subscription.get("status") or {} + if not all(isinstance(value, dict) for value in (metadata, spec, status)): + continue + if (metadata.get("namespace") != OSC_NAMESPACE or metadata.get("deletionTimestamp") + or spec.get("name") != "sandboxed-containers-operator"): + continue + conditions = status.get("conditions") or [] + if not isinstance(conditions, list) or any( + isinstance(item, dict) and item.get("status") == "True" + and item.get("type") in {"ResolutionFailed", "InstallPlanFailed"} + for item in conditions): + continue + name = status.get("installedCSV") + if isinstance(name, str) and name in installed: + return True + return False + + def api_resources_available(discovery, group_version, resource_names): """Check served API resources from discovery, including built-in APIs.""" if not isinstance(discovery, dict) or discovery.get("groupVersion") != group_version: @@ -430,6 +472,8 @@ def verify_kata_platform(site, runtime_class, kata_configs, nodes, api_readiness raise PreflightError("AgentSandboxUnavailable") if api_readiness.get("kataconfigs.kataconfiguration.openshift.io") is not True: raise PreflightError("SandboxedContainersUnavailable") + if api_readiness.get("sandboxedOperator") is not True: + raise PreflightError("SandboxedContainersUnavailable") if not isinstance(kata_configs, list): raise PreflightError("KataConfigNotReady") ready_configs = [item for item in kata_configs diff --git a/charts/saw-portal-container/templates/auto-enroll.yaml b/charts/saw-portal-container/templates/auto-enroll.yaml index 90689dd32..3c222f1b2 100644 --- a/charts/saw-portal-container/templates/auto-enroll.yaml +++ b/charts/saw-portal-container/templates/auto-enroll.yaml @@ -41,6 +41,20 @@ kind: ClusterRoleBinding metadata: {name: {{ $t }}-{{ $name }}} roleRef: {apiGroup: rbac.authorization.k8s.io, kind: ClusterRole, name: {{ $t }}-{{ $name }}} subjects: [{kind: ServiceAccount, name: {{ $name }}, namespace: {{ $t }}}] +{{- if $s.kataRuntimeClass }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: {name: {{ $t }}-{{ $name }}-osc, namespace: openshift-sandboxed-containers-operator} +rules: + - {apiGroups: [operators.coreos.com], resources: [subscriptions, clusterserviceversions], verbs: [list]} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: {name: {{ $t }}-{{ $name }}-osc, namespace: openshift-sandboxed-containers-operator} +roleRef: {apiGroup: rbac.authorization.k8s.io, kind: Role, name: {{ $t }}-{{ $name }}-osc} +subjects: [{kind: ServiceAccount, name: {{ $name }}, namespace: {{ $t }}}] +{{- end }} {{- range $ns := list $n $t $gov }} --- apiVersion: rbac.authorization.k8s.io/v1 diff --git a/charts/saw-trustee/Chart.yaml b/charts/saw-trustee/Chart.yaml new file mode 100644 index 000000000..432a8e87a --- /dev/null +++ b/charts/saw-trustee/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: saw-trustee +description: Optional Red Hat build of Trustee with a Restricted profile and closed bootstrap ingress +type: application +version: 0.1.0 diff --git a/charts/saw-trustee/templates/trustee.yaml b/charts/saw-trustee/templates/trustee.yaml new file mode 100644 index 000000000..2ea601108 --- /dev/null +++ b/charts/saw-trustee/templates/trustee.yaml @@ -0,0 +1,35 @@ +{{- if .Values.global.confidential.enabled }} +{{- $t := .Values.trustee }} +# Keep bootstrap KBS inaccessible to workloads until measured, registration- +# specific authorization and ingress are implemented. The vendor operator owns +# its generated policies; do not race it by pre-creating those ConfigMaps. +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ $t.name }}-bootstrap-deny + namespace: {{ .Release.Namespace }} + annotations: + argocd.argoproj.io/sync-wave: '-1' + argocd.argoproj.io/sync-options: Prune=false,Delete=false +spec: + podSelector: + matchLabels: + app: kbs + policyTypes: [Ingress] + ingress: [] +--- +apiVersion: confidentialcontainers.org/v1alpha1 +kind: TrusteeConfig +metadata: + name: {{ $t.name }} + namespace: {{ .Release.Namespace }} + annotations: + argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true,Prune=false,Delete=false +spec: + profileType: Restricted + kbsServiceType: ClusterIP + httpsSpec: + tlsSecretName: {{ $t.httpsSecretName | quote }} + attestationTokenVerificationSpec: + tlsSecretName: {{ $t.attestationTokenSecretName | quote }} +{{- end }} diff --git a/charts/saw-trustee/values.schema.json b/charts/saw-trustee/values.schema.json new file mode 100644 index 000000000..d04fee771 --- /dev/null +++ b/charts/saw-trustee/values.schema.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://json-schema.org/draft-07/schema#", + "type": "object", + "required": ["global", "trustee"], + "properties": { + "global": { + "type": "object", + "required": ["confidential"], + "properties": { + "confidential": { + "type": "object", + "required": ["enabled"], + "properties": {"enabled": {"type": "boolean"}} + } + } + }, + "trustee": { + "type": "object", + "required": ["name", "httpsSecretName", "attestationTokenSecretName"], + "properties": { + "name": {"type": "string", "maxLength": 40, "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"}, + "httpsSecretName": {"type": "string", "minLength": 1, "maxLength": 253, "pattern": "^[a-z0-9]([-a-z0-9.]*[a-z0-9])?$"}, + "attestationTokenSecretName": {"type": "string", "minLength": 1, "maxLength": 253, "pattern": "^[a-z0-9]([-a-z0-9.]*[a-z0-9])?$"} + } + } + } +} diff --git a/charts/saw-trustee/values.yaml b/charts/saw-trustee/values.yaml new file mode 100644 index 000000000..6ac704e44 --- /dev/null +++ b/charts/saw-trustee/values.yaml @@ -0,0 +1,10 @@ +global: + confidential: + enabled: false + +# Existing kubernetes.io/tls Secrets in the release namespace. The operator +# reads these; Helm never reads or generates private key material. +trustee: + name: saw-trustee + httpsSecretName: saw-trustee-https + attestationTokenSecretName: saw-trustee-token diff --git a/charts/saw-users/files/preflight.py b/charts/saw-users/files/preflight.py index dc499183c..a213e21a1 100644 --- a/charts/saw-users/files/preflight.py +++ b/charts/saw-users/files/preflight.py @@ -40,6 +40,10 @@ def __init__(self, reason): "storage", "secrets", "registry", "providerEgress", "revisions", ) KATA_CHECKS = ("osc", "kataConfig", "workers", "runtimeClass") +OSC_NAMESPACE = "openshift-sandboxed-containers-operator" +OSC_API = "/apis/operators.coreos.com/v1alpha1/namespaces/" + OSC_NAMESPACE +OSC_SUBSCRIPTIONS_PATH = OSC_API + "/subscriptions" +OSC_CSVS_PATH = OSC_API + "/clusterserviceversions" # This pinned image has /sandbox mode 0770, owned by 1000:0. The OpenShift # namespace UID cannot traverse it. The reviewed notebook build adds o+x. @@ -368,6 +372,44 @@ def crd_established(obj): and condition.get("status") == "True" for condition in conditions) +def sandboxed_operator_ready(subscriptions, csvs): + """Require the OSC Subscription's installed CSV, not a leftover Kata CRD.""" + if not isinstance(subscriptions, list) or not isinstance(csvs, list): + return False + installed = set() + for csv in csvs: + if not isinstance(csv, dict): + continue + metadata, status = csv.get("metadata") or {}, csv.get("status") or {} + if (isinstance(metadata, dict) and isinstance(status, dict) + and metadata.get("namespace") == OSC_NAMESPACE + and not metadata.get("deletionTimestamp") + and status.get("phase") == "Succeeded"): + name = metadata.get("name") + if isinstance(name, str): + installed.add(name) + for subscription in subscriptions: + if not isinstance(subscription, dict): + continue + metadata = subscription.get("metadata") or {} + spec, status = subscription.get("spec") or {}, subscription.get("status") or {} + if not all(isinstance(value, dict) for value in (metadata, spec, status)): + continue + if (metadata.get("namespace") != OSC_NAMESPACE or metadata.get("deletionTimestamp") + or spec.get("name") != "sandboxed-containers-operator"): + continue + conditions = status.get("conditions") or [] + if not isinstance(conditions, list) or any( + isinstance(item, dict) and item.get("status") == "True" + and item.get("type") in {"ResolutionFailed", "InstallPlanFailed"} + for item in conditions): + continue + name = status.get("installedCSV") + if isinstance(name, str) and name in installed: + return True + return False + + def api_resources_available(discovery, group_version, resource_names): """Check served API resources from discovery, including built-in APIs.""" if not isinstance(discovery, dict) or discovery.get("groupVersion") != group_version: @@ -430,6 +472,8 @@ def verify_kata_platform(site, runtime_class, kata_configs, nodes, api_readiness raise PreflightError("AgentSandboxUnavailable") if api_readiness.get("kataconfigs.kataconfiguration.openshift.io") is not True: raise PreflightError("SandboxedContainersUnavailable") + if api_readiness.get("sandboxedOperator") is not True: + raise PreflightError("SandboxedContainersUnavailable") if not isinstance(kata_configs, list): raise PreflightError("KataConfigNotReady") ready_configs = [item for item in kata_configs diff --git a/charts/saw-users/files/projector.py b/charts/saw-users/files/projector.py index 91b181706..4fa927d5f 100644 --- a/charts/saw-users/files/projector.py +++ b/charts/saw-users/files/projector.py @@ -46,6 +46,8 @@ def preflight_resource(self, path): "/apis/kataconfiguration.openshift.io/v1/kataconfigs", "/api/v1/nodes", "/apis/admissionregistration.k8s.io/v1", + preflight.OSC_SUBSCRIPTIONS_PATH, + preflight.OSC_CSVS_PATH, } allowed = (path in fixed or re.fullmatch( r"/api/v1/namespaces/saw-[a-z0-9-]+", path) or re.fullmatch( @@ -126,6 +128,9 @@ def verify_gitops_preflight(owner, site, mode, read): configs = read("/apis/kataconfiguration.openshift.io/v1/kataconfigs") nodes = read("/api/v1/nodes") readiness = {} + readiness["sandboxedOperator"] = preflight.sandboxed_operator_ready( + (read(preflight.OSC_SUBSCRIPTIONS_PATH) or {}).get("items"), + (read(preflight.OSC_CSVS_PATH) or {}).get("items")) for name in ("kataconfigs.kataconfiguration.openshift.io", "sandboxes.agents.x-k8s.io", "externalsecrets.external-secrets.io", diff --git a/charts/saw-users/templates/projector.yaml b/charts/saw-users/templates/projector.yaml index 946a316b3..d90acc349 100644 --- a/charts/saw-users/templates/projector.yaml +++ b/charts/saw-users/templates/projector.yaml @@ -107,6 +107,20 @@ subjects: [{kind: ServiceAccount, name: {{ $name }}-identity, namespace: {{ .Rel {{- $classes = append $classes (dig "kataRuntimeClass" "name" "" (index $config.containerSites $user.name)) }} {{- end }} {{- end }} +{{- if $classes }} +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: {name: {{ $name }}-osc, namespace: openshift-sandboxed-containers-operator} +rules: +- {apiGroups: [operators.coreos.com], resources: [subscriptions, clusterserviceversions], verbs: [list]} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: {name: {{ $name }}-osc, namespace: openshift-sandboxed-containers-operator} +roleRef: {apiGroup: rbac.authorization.k8s.io, kind: Role, name: {{ $name }}-osc} +subjects: [{kind: ServiceAccount, name: {{ $name }}, namespace: {{ .Release.Namespace }}}] +--- +{{- end }} apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: {name: {{ $name }}-preflight} diff --git a/docs/README.md b/docs/README.md index 60f914adb..1d4c40d88 100644 --- a/docs/README.md +++ b/docs/README.md @@ -33,6 +33,9 @@ quickstart, and the supported-provider and secrets tables. ## Features & how-to +[Optional Trustee setup](trustee.md) explains the global switch, shared +overrides, certificate prerequisites, operator installation, and current scope. + | Doc | What it covers | |---|---| | [Harness bundles](harness-bundles.md) | Ship skills, MCP servers and tool plugins into a sandbox | diff --git a/docs/deployment-guide.md b/docs/deployment-guide.md index 31336aadc..ed8daf019 100644 --- a/docs/deployment-guide.md +++ b/docs/deployment-guide.md @@ -52,7 +52,14 @@ All applications are defined in `values-prod.yaml` and deployed by the Validated | `governance-policy` | `openshell-agents` | Policy ConfigMaps (profiles + sandbox policy) | | `governance-interceptor` | `openshell-agents` | gRPC interceptor deployment; with `global.governance.engine: apf`, the APF inputs and an Argo CD app for the APF chart ([apf.md](apf.md)) | -**Operator Subscriptions:** OpenShift Virtualization, RHBK (Keycloak), External Secrets Operator, RHDH, OpenShift AI. +**Operator Subscriptions:** OpenShift Virtualization, RHBK (Keycloak), External Secrets Operator, RHDH, OpenShift AI, OpenShift Pipelines, OpenShift sandboxed containers, and OpenTelemetry. The pattern installs the sandboxed containers Operator on user workload clusters; Kata enrollment also verifies its installed CSV is `Succeeded`. + +Red Hat build of Trustee is optional: `global.confidential.enabled: true` +selects the shared confidential overrides and adds its operator and restrictive +configuration. Prepare its certificate Secrets and review its manual InstallPlan +as described in [Trustee setup](trustee.md). This installs attestation services; +the runtime and per-workspace attestation/credential integration have separate +qualification requirements. ## Deployment Phases diff --git a/docs/deployment-validation-ci.md b/docs/deployment-validation-ci.md index aa856a09e..fd40fda58 100644 --- a/docs/deployment-validation-ci.md +++ b/docs/deployment-validation-ci.md @@ -164,5 +164,6 @@ served OpenAPI v3 schemas from their CRD files: - [RHDH Backstage CRD](https://github.com/redhat-developer/rhdh-operator/blob/82b4a840d12c06abb771bc6957b365c245477667/config/crd/bases/rhdh.redhat.com_backstages.yaml) - [HyperConverged CRD](https://github.com/kubevirt/hyperconverged-cluster-operator/blob/37b709d5d9400d47dc03f96fef5f6ac21dc70f8f/config/crd/bases/hco.kubevirt.io_hyperconvergeds.yaml) - [KataConfig CRD](https://github.com/openshift/sandboxed-containers-operator/blob/891eadc9fa270c38b1d7040d05675636990058b8/config/crd/bases/kataconfiguration.openshift.io_kataconfigs.yaml) +- [TrusteeConfig CRD](https://github.com/confidential-containers/trustee-operator/blob/0cde07204d23de9d64b7b214362126f41af23244/config/crd/bases/confidentialcontainers.org_trusteeconfigs.yaml) - [Tekton Pipeline CRD](https://github.com/tektoncd/pipeline/blob/592dfb840f02a0e9e2920f75b1737372ceb17c15/config/300-crds/300-pipeline.yaml) - [Tekton Task CRD](https://github.com/tektoncd/pipeline/blob/592dfb840f02a0e9e2920f75b1737372ceb17c15/config/300-crds/300-task.yaml) diff --git a/docs/kata-workspaces.md b/docs/kata-workspaces.md index a34e6194a..59e1f7883 100644 --- a/docs/kata-workspaces.md +++ b/docs/kata-workspaces.md @@ -59,7 +59,20 @@ The pattern installs the Red Hat OpenShift sandboxed containers Operator in `openshift-sandboxed-containers-operator` (`values-prod.yaml`: a Namespace, an OperatorGroup scoped to it, and a Subscription from `redhat-operators` on the `stable` channel). The operator alone changes no node. Check that the -Subscription has an installed CSV and that the CSV is `Succeeded`. +Subscription has an installed CSV and that the CSV is `Succeeded`: + +```bash +make kata-operator-check +``` + +The GitOps projector, enrollment Job, and RHDH registration preflight verify +the Subscription's package and installed CSV through read-only, namespace-scoped +permissions. A leftover Kata CRD or RuntimeClass does not qualify an absent or +failed operator. This check runs after the pattern installs its operators; +`make saw-init` can still prepare a fresh cluster before they exist. The +operator is installed regardless of the optional Trustee setting. Installing +the operator does not activate the worker runtime; the KataConfig remains +opt-in. For the separate Trustee installation, see [Trustee setup](trustee.md). The `saw-kata` application (`charts/saw-kata`) creates the KataConfig below when enabled, selecting plain workers only (never control-plane nodes, even diff --git a/docs/trustee-validation-2026-12-01.md b/docs/trustee-validation-2026-12-01.md new file mode 100644 index 000000000..ed8bab717 --- /dev/null +++ b/docs/trustee-validation-2026-12-01.md @@ -0,0 +1,75 @@ +# Trustee installation validation — 2026-12-01 + +Scope: the optional Trustee installation and OSC readiness gate. The test +cluster was `cluster-nx6jv`, OpenShift 4.22.22, platform `BareMetal`. +The implementation branch is `codex/optional-trustee-operators`, based on +upstream `main` at `2cd2ee86`. + +## Local validation + +- 519 affected chart, portal, preflight, deployment-validation, projector, + and Make-interface tests passed. The focused 64-test Trustee/operator/ + preflight set also passed during validation; the final bootstrap chart and + complete clustergroup variants were checked again after adopting the + operator-owned Restricted policy and network isolation. These + are separate runs, not an additive total. +- `CI=true PYTHON=python3 make lint-static` passed. +- Catalog generation/check passed, including identical shared preflight + sources in the three independently deployed charts. +- Deployment validation returned zero errors: 27 enabled chart variants, + 303 schema resources, and the existing BOM/dependency checks. The enabled + TrusteeConfig passed the vendored schema and the installed vendor CRD. +- Clustergroup 0.9.61 rendered both capability states in single-source and + multi-source mode. OSC remained present in both states. Trustee namespace, + OperatorGroup, Subscription, and Application appeared only when enabled. + The generated Trustee child Application preserved the selected boolean + and shared values-file path, and its chart rendered successfully. + +## Live component validation + +The cluster initially had no OSC or Trustee Subscription. Only the two +operators and the Trustee test configuration were installed from the +rendered manifests; this was not a full SAW or full GitOps installation. + +1. The new read-only OSC check failed with + `SandboxedContainersUnavailable` before installation. +2. OSC installed as `sandboxed-containers-operator.v1.13.1`, phase + `Succeeded`; the same check then passed. +3. The reviewed Trustee InstallPlan selected only + `trustee-operator.v1.2.1`. After approval, its CSV reached `Succeeded`. +4. Separate lab-only HTTPS and token-signing certificates were uploaded as + existing TLS Secrets. Temporary private-key files were removed. No real + provider credential or SAW registration was provisioned. +5. The rendered Restricted TrusteeConfig passed server-side dry run. Its + status became ready, and `trustee-deployment` became available. +6. Fresh-creation testing showed the vendor operator initializes its own + generated resource-policy ConfigMap, including when a same-named map is + pre-created. The final chart therefore uses the supported Restricted + profile and a chart-owned bootstrap NetworkPolicy, rather than competing + with generated policy ownership. The active policy's mounted filename is + `resource-policy.rego`; its Restricted rules are not an unconditional + denial of all attested clients. +7. The bootstrap NetworkPolicy selects the live KBS Pods (`app: kbs`) and + permits no ingress. A temporary ordinary Pod's TCP/HTTPS connection to the + KBS service timed out as expected. Repeat apply and restart checks preserve + the bootstrap configuration. +8. An administrator request over certificate-verified HTTPS through a temporary localhost + port-forward returned HTTP 401 for the demonstration resource and released + no resource payload. No public Route was created. +9. No KataConfig or confidential workspace was created. Installing the + operators did not qualify runtime placement, guest attestation, or inference. + +## Retained test state and limits + +The operator installations, `saw-trustee` configuration, bootstrap NetworkPolicy, +and lab certificate Secrets remain for continued testing. The certificates +were generated with a 30-day validity for this lab; replace them through the +site's approved certificate process before using the service for real guests. +No private material is included in this record. + +The following remain outside this PR's evidence: full pattern installation +and live Argo reconciliation, a confidential runtime, guest measurement/RVPS +approval, registration-specific credential delivery, NVIDIA inference, +provider-key rotation, and revocation. The HTTPS 401 check establishes +unauthenticated denial, not successful hardware attestation. The ordinary-Pod +connection timeout is the separate workload-ingress isolation check. diff --git a/docs/trustee.md b/docs/trustee.md new file mode 100644 index 000000000..7a2865ea5 --- /dev/null +++ b/docs/trustee.md @@ -0,0 +1,195 @@ +# Optional Red Hat build of Trustee + +SAW can install Red Hat build of Trustee through the Validated Pattern. Set +`global.confidential.enabled: true` in `values-global.yaml`, commit, and push. +The default is `false`. + +```yaml +global: + confidential: + enabled: true +``` + +`values-prod.yaml` selects `overrides/values-confidential.yaml` through +`clusterGroup.sharedValueFiles`. With the switch off it selects the neutral +`overrides/values-confidential-disabled.yaml` instead. Keep both files in the +repository. The selected file reaches the clustergroup and its applications; +the Trustee application also explicitly forwards the resolved boolean value. +Use actual YAML booleans, not quoted strings. Shared files must not set a +generic top-level `enabled`: that key also controls other charts, including +worker runtime installation in `saw-kata`. + +## What this installs + +Enabling the option adds: + +- Namespace and OperatorGroup `trustee-operator-system`. +- A `trustee-operator` Subscription from `redhat-operators`, channel `stable`, + with manual InstallPlan approval. The enabled overlay also makes OSC + InstallPlans manual so the pair's compatibility can be reviewed together. +- The `saw-trustee` Application and its `TrusteeConfig`, using the operator's + `Restricted` profile, HTTPS, and configured attestation-token signing trust. +- A bootstrap NetworkPolicy denying all ingress to KBS workload Pods. It is + installed before the TrusteeConfig and remains closed until a later reviewed + integration explicitly permits approved clients. + +The configuration uses an internal ClusterIP service with no permitted workload +ingress. There is no public +Route, workload credential mapping, or automatic approval of a workspace. +No KataConfig or worker configuration change is enabled by this switch. + +This is the installation foundation for confidential workspaces. Running a +confidential SAW workspace still requires a supported confidential runtime, +exact guest and init-data references in RVPS, registration-specific resource +policy, attested guest credential retrieval, and qualification of rotation and +revocation. This option alone does not turn existing local Kata, Container, +or VM workspaces into confidential workspaces. + +## Prerequisites and ownership + +Use an OpenShift/operator combination supported by the vendor. On the +2026-12-01 validation cluster, the catalog offered OSC 1.13.1 and Trustee +1.2.1. The vendor documents OSC 1.13 with Trustee 1.2; check compatibility +again before approving an upgrade. A `startingCSV` alone is not a permanent +version pin. See the [vendor compatibility guidance](https://docs.redhat.com/en/documentation/openshift_sandboxed_containers/1.13/html/deploying_confidential_containers_on_bare-metal_servers/confidential-workload-environment_metal-cc). + +The standard SAW pattern already installs the OpenShift sandboxed containers +Operator, including when Trustee is disabled. It belongs on the cluster that +runs Kata workspaces. The Trustee service belongs in an administratively +trusted environment; this optional same-cluster installation trusts this +cluster's administrators with Trustee and its private material. A separately +operated Trustee service requires an explicit external-service integration. + +Before enabling on an existing installation, inspect Subscriptions and +TrusteeConfig/KbsConfig objects. Adopt compatible ownership deliberately; +do not create a second operator or KBS instance in the same namespace. +This chart manages the bootstrap NetworkPolicy and TrusteeConfig. The operator +manages its generated resource/attestation policies, configuration, and deployment. +In the tested vendor build, it initializes its own generated ConfigMaps even +when a same-named map was pre-created. Do not race that initialization with +chart-owned policy content. The Restricted profile is the starting appraisal +policy; exact workspace grants and permitted ingress belong in the later +reviewed integration. The bootstrap network policy intentionally offers no +workload access. An additional overlapping allow NetworkPolicy could open it; +the trusted platform administrator controls this namespace and its policies. + +## Provide the certificates outside Git + +Before the configuration can become ready, create two existing Secrets of +type `kubernetes.io/tls` in `trustee-operator-system`: + +- `saw-trustee-https`: KBS HTTPS certificate and private key. Its SANs must + match the endpoint guests will actually use. +- `saw-trustee-token`: a separate attestation-token signing certificate and + private key, used by the Restricted profile's token verification setup. + +Use your site's certificate and secret-management process. Given existing +certificate/key files outside the repository, the upload commands are: + +```bash +oc create namespace trustee-operator-system --dry-run=client -o yaml | oc apply -f - +oc -n trustee-operator-system create secret tls saw-trustee-https \ + --cert=/secure/path/kbs.crt --key=/secure/path/kbs.key +oc -n trustee-operator-system create secret tls saw-trustee-token \ + --cert=/secure/path/token.crt --key=/secure/path/token.key +``` + +These commands create new Secrets; they deliberately do not overwrite existing +private material. The chart neither reads nor generates private keys. Publish +only the reviewed public CA/certificate material required by future guests. +For a same-cluster endpoint, account for the operator's `kbs-service` DNS name +in this namespace. Remote peer-pod guests also need network reachability to +the selected endpoint; an internal service name alone does not supply that. + +The public chart values `trustee.name`, `trustee.httpsSecretName`, and +`trustee.attestationTokenSecretName` can be set in the appropriate site values +file. Their defaults are in `charts/saw-trustee/values.yaml`. All names and +references are validated; private credential values never belong in these +files. Use a dedicated namespace for this KBS installation. + +## Install and verify + +1. Prepare the public values and existing certificate Secrets above, then + commit and push the enabled configuration to the branch used by the pattern. +2. Install/sync the pattern using the README's normal process. The operator + subscription is independent of the configuration application's first sync. + That application may retry until the CRD exists and the operator is ready. +3. Review the OSC and Trustee InstallPlans and their target CSVs, then approve + those exact plans through the console or `oc`. Manual approval applies to + initial install as well as later upgrades. Do not approve unrelated plans + in bulk. +4. Check both operators and the Trustee configuration: + + ```bash + make kata-operator-check + oc -n trustee-operator-system get subscription trustee-operator + oc -n trustee-operator-system get installplans + oc -n trustee-operator-system get csv + oc -n trustee-operator-system get trusteeconfig saw-trustee + oc -n trustee-operator-system get pods + oc -n trustee-operator-system get networkpolicy saw-trustee-bootstrap-deny -o yaml + oc -n trustee-operator-system get configmap saw-trustee-resource-policy \ + -o jsonpath='{.data.resource-policy\.rego}' + ``` + +5. Require the installed CSV to be `Succeeded`, the KBS deployment to be ready, + its generated configuration to use Restricted policies and HTTPS, and the + bootstrap NetworkPolicy to select the live KBS Pods with no ingress rules. + A connection from an ordinary Pod must time out. A trusted administrator + can use a temporary localhost port-forward to check certificate-verified + HTTPS; an unauthenticated resource request must return no resource bytes. + A port-forward bypasses the workload network boundary and is not its test. + +For an explicit context without changing your current one, run +`python3 scripts/check-sandboxed-operator.py --context=`. +The check reads only public Subscription/CSV metadata. Workspace registration +also requires a ready approved KataConfig, matching workers, and RuntimeClass; +see [Kata workspaces](kata-workspaces.md). + +The operator may create its demonstration status resource under the Restricted +profile. No real provider credential or registration is provisioned. Workload +ingress remains blocked, including access to that demonstration resource. + +## Upgrades and disabling + +Review operator upgrades against token format, reference generation, policy, +TLS, and persistence requirements before approving the InstallPlan. Restart +and repeated-sync tests must retain the Restricted profile and closed bootstrap +ingress. Certificate or +credential rotation is a separate qualification: changing a source Secret +does not prove a running KBS process reloaded it. + +Changing the global switch to false stops selecting the optional installation +resources; it is not an uninstall or revocation procedure. The namespace, +subscription, bootstrap NetworkPolicy, and TrusteeConfig carry pruning and Application-deletion +protection (`Prune=false,Delete=false`), and the +configuration Application disables automated resource pruning. Argo's parent +Application deletion/finalizer behavior must also be reviewed before removal. +Retire active registrations, revoke credentials, and remove the owned +Application/resources explicitly when their retention is no longer required. +Never turn a confidential workspace into an ordinary workspace as a fallback. + +## Validation + +Run the focused tests with: + +```bash +python3 -m pytest -q tests/charts/test_saw_trustee.py \ + tests/scripts/test_sandboxed_operator.py tests/scripts/test_saw_preflight.py +make catalog-check +make test-dependencies +helm pull clustergroup --repo https://charts.validatedpatterns.io \ + --version 0.9.61 --untar --untardir /tmp/saw-pattern-check +python3 scripts/ci/check_confidential_pattern.py \ + --chart /tmp/saw-pattern-check/clustergroup +``` + +Deployment validation includes the enabled Trustee chart and a vendored +TrusteeConfig schema. Its public upstream schema source is +[trustee-operator at 0cde072](https://github.com/confidential-containers/trustee-operator/blob/0cde07204d23de9d64b7b214362126f41af23244/config/crd/bases/confidentialcontainers.org_trusteeconfigs.yaml). +The installed vendor CRD must also accept the rendered manifest in a live +server-side dry run. Verify the complete clustergroup render in both switch +states, not only the local chart. + +See the [2026-12-01 validation record](trustee-validation-2026-12-01.md) for +the tested versions, live component results, and remaining qualification. diff --git a/overrides/values-confidential-disabled.yaml b/overrides/values-confidential-disabled.yaml new file mode 100644 index 000000000..c25bf8d36 --- /dev/null +++ b/overrides/values-confidential-disabled.yaml @@ -0,0 +1,2 @@ +# Explicit neutral selection for global.confidential.enabled: false. +{} diff --git a/overrides/values-confidential.yaml b/overrides/values-confidential.yaml new file mode 100644 index 000000000..a95588f77 --- /dev/null +++ b/overrides/values-confidential.yaml @@ -0,0 +1,42 @@ +# Selected by clusterGroup.sharedValueFiles when global.confidential.enabled +# is true. Public configuration only; provision TLS keys outside Git. +# Never set a top-level enabled here: shared files also reach saw-kata. +clusterGroup: + namespaces: + trustee-operator-system: + operatorGroup: true + targetNamespaces: + - trustee-operator-system + annotations: + argocd.argoproj.io/sync-options: Prune=false,Delete=false + subscriptions: + sandboxed-containers: + # Review OSC and Trustee as a compatible pair for confidential use. + installPlanApproval: Manual + trustee: + name: trustee-operator + namespace: trustee-operator-system + channel: stable + source: redhat-operators + # Upgrades can change token schemas and reference values. Review them. + installPlanApproval: Manual + annotations: + argocd.argoproj.io/sync-options: Prune=false,Delete=false + applications: + saw-trustee: + name: saw-trustee + namespace: trustee-operator-system + path: charts/saw-trustee + overrides: + # Explicitly forward the resolved parent value, including when supplied + # as an installation parameter rather than committed to values-global. + - name: global.confidential.enabled + value: '{{ .Values.global.confidential.enabled }}' + forceString: false + # Retain the service on disablement until its registrations are retired. + syncPolicy: + automated: + prune: false + selfHeal: true + retry: + limit: 20 diff --git a/scripts/check-sandboxed-operator.py b/scripts/check-sandboxed-operator.py new file mode 100644 index 000000000..b7fdc472e --- /dev/null +++ b/scripts/check-sandboxed-operator.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +"""Read-only OSC installation check; uses the same gate as workspace enrollment.""" +import argparse +import importlib.util +import json +from pathlib import Path +import subprocess + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--context", help="Kubernetes context; does not change the current context") + args = parser.parse_args() + source = Path(__file__).resolve().parents[1] / "charts/saw-users/files/preflight.py" + spec = importlib.util.spec_from_file_location("preflight", source) + preflight = importlib.util.module_from_spec(spec) + spec.loader.exec_module(preflight) + command = ["oc"] + (["--context", args.context] if args.context else []) + facts = [] + try: + for path in (preflight.OSC_SUBSCRIPTIONS_PATH, preflight.OSC_CSVS_PATH): + result = subprocess.run([*command, "get", "--raw", path], capture_output=True, + text=True, timeout=30, check=True) + facts.append(json.loads(result.stdout).get("items")) + ready = preflight.sandboxed_operator_ready(*facts) + except (OSError, ValueError, subprocess.SubprocessError): + ready = False + if not ready: + print("SandboxedContainersUnavailable: install the sandboxed-containers-operator " + "Subscription in openshift-sandboxed-containers-operator and wait for its " + "installed CSV to reach Succeeded (docs/kata-workspaces.md).") + return 1 + print("OpenShift sandboxed containers Operator: Succeeded. " + "KataConfig and worker/runtime readiness are checked separately during enrollment.") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/ci/check_confidential_pattern.py b/scripts/ci/check_confidential_pattern.py new file mode 100644 index 000000000..51ebde07f --- /dev/null +++ b/scripts/ci/check_confidential_pattern.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +"""Render both optional-Trustee states through the real clustergroup chart.""" +import argparse +from pathlib import Path +import subprocess +import tempfile + +import yaml + +ROOT = Path(__file__).resolve().parents[2] + + +def helm(*args): + result = subprocess.run(["helm", *map(str, args)], capture_output=True, text=True, timeout=90) + if result.returncode: + raise ValueError(result.stderr.strip()) + return [item for item in yaml.safe_load_all(result.stdout) if item] + + +def check(chart, directory): + selector = directory / "selector" + (selector / "templates").mkdir(parents=True) + (selector / "Chart.yaml").write_text("apiVersion: v2\nname: selector\nversion: 0.1.0\n") + (selector / "templates/selection.yaml").write_text( + 'apiVersion: v1\nkind: ConfigMap\nmetadata: {name: selection}\ndata:\n' + ' path: {{ tpl (index .Values.clusterGroup.sharedValueFiles 0) . | quote }}\n') + base = ["-f", ROOT / "values-global.yaml", "-f", ROOT / "values-prod.yaml"] + for enabled in ("false", "true"): + switch = ["--set", "global.confidential.enabled=" + enabled] + selection, = helm("template", "selector", selector, *base, *switch) + overlay = ROOT / selection["data"]["path"].lstrip("/") + if not overlay.is_file(): + raise ValueError("selected confidential overlay does not exist") + for multi in ("false", "true"): + docs = helm("template", "saw", chart, "--namespace", "vp-gitops", *base, + "-f", overlay, *switch, "--set", "global.multiSourceSupport=" + multi, + "--set", "global.vpArgoNamespace=vp-gitops", "--set", + "global.repoURL=https://github.com/example/secure-agent-workspace.git", + "--set", "global.targetRevision=main") + subscriptions = [x for x in docs if x["kind"] == "Subscription"] + assert any(x["spec"]["name"] == "sandboxed-containers-operator" for x in subscriptions) + trustee = [x for x in subscriptions if x["spec"]["name"] == "trustee-operator"] + apps = [x for x in docs if x["kind"] == "Application" and x["metadata"]["name"] == "saw-trustee"] + namespaces = [x for x in docs if x["kind"] == "Namespace" and x["metadata"]["name"] == "trustee-operator-system"] + groups = [x for x in docs if x["kind"] == "OperatorGroup" and x["metadata"]["namespace"] == "trustee-operator-system"] + if enabled == "false": + assert not trustee and not apps and not namespaces and not groups + continue + assert len(trustee) == len(apps) == len(namespaces) == len(groups) == 1 + assert trustee[0]["spec"]["installPlanApproval"] == "Manual" + osc, = [x for x in subscriptions if x["spec"]["name"] == "sandboxed-containers-operator"] + assert osc["spec"]["installPlanApproval"] == "Manual" + spec = apps[0]["spec"] + sources = spec.get("sources") or [spec["source"]] + source, = [x for x in sources if x.get("path") == "charts/saw-trustee"] + parameters = source["helm"]["parameters"] + setting, = [x for x in parameters if x["name"] == "global.confidential.enabled"] + assert str(setting["value"]).lower() == "true" + assert not setting.get("forceString") + assert any(x.endswith(selection["data"]["path"]) for x in source["helm"]["valueFiles"]) + # Render the actual generated child's inputs, including the parent's + # explicit parameter. This catches a value dropped across app levels. + child = helm("template", "saw-trustee", ROOT / "charts/saw-trustee", + "--namespace", "trustee-operator-system", *base, "-f", overlay, + "--set", "global.confidential.enabled=" + str(setting["value"]).lower()) + assert {x["kind"] for x in child} == {"NetworkPolicy", "TrusteeConfig"} + print("Optional Trustee: disabled/enabled parent and child renders passed (single/multi-source).") + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--chart", type=Path, required=True, help="unpacked clustergroup chart") + args = parser.parse_args() + with tempfile.TemporaryDirectory(prefix="saw-pattern-check-") as temporary: + check(args.chart, Path(temporary)) + + +if __name__ == "__main__": + main() diff --git a/scripts/ci/deployment_validation.py b/scripts/ci/deployment_validation.py index f66d01b3e..a20ac907c 100644 --- a/scripts/ci/deployment_validation.py +++ b/scripts/ci/deployment_validation.py @@ -107,6 +107,8 @@ def chart_args(chart: Path, mode="proxy") -> list[str]: return ["--namespace", "agent-sandbox-system", "--set", "enabled=true"] if name == "saw-kata": return ["--namespace", "openshift-sandboxed-containers-operator", "--set", "enabled=true"] + if name == "saw-trustee": + return ["--namespace", "trustee-operator-system", "--set", "global.confidential.enabled=true"] if name == "saw-kubernetes-controller": return ["--namespace", "saw-ci-trusted", "-f", str(ROOT / "tests/fixtures/saw-kubernetes-controller-values.yaml")] diff --git a/scripts/ci/schemas/confidentialcontainers.org/trusteeconfig_v1alpha1.json b/scripts/ci/schemas/confidentialcontainers.org/trusteeconfig_v1alpha1.json new file mode 100644 index 000000000..c5e0e0aa6 --- /dev/null +++ b/scripts/ci/schemas/confidentialcontainers.org/trusteeconfig_v1alpha1.json @@ -0,0 +1,134 @@ +{ + "properties": { + "apiVersion": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "metadata": { + "type": "object" + }, + "spec": { + "properties": { + "attestationTokenVerificationSpec": { + "properties": { + "tlsSecretName": { + "type": "string" + } + }, + "type": "object" + }, + "httpsSpec": { + "properties": { + "tlsSecretName": { + "type": "string" + } + }, + "type": "object" + }, + "ibmSE": { + "properties": { + "pvName": { + "type": "string" + } + }, + "required": [ + "pvName" + ], + "type": "object" + }, + "kbsServiceType": { + "type": "string" + }, + "profileType": { + "type": "string" + }, + "tlsConfig": { + "properties": { + "ciphers": { + "items": { + "type": "string" + }, + "type": "array" + }, + "groups": { + "items": { + "type": "string" + }, + "type": "array" + }, + "maxVersion": { + "pattern": "^1\\.[0-3]$", + "type": "string" + }, + "minVersion": { + "pattern": "^1\\.[0-3]$", + "type": "string" + }, + "profile": { + "enum": [ + "old", + "intermediate", + "modern", + "custom" + ], + "type": "string" + } + }, + "type": "object", + "x-kubernetes-validations": [ + { + "message": "minVersion must not be greater than maxVersion", + "rule": "!has(self.minVersion) || !has(self.maxVersion) || self.minVersion <= self.maxVersion" + }, + { + "message": "minVersion, maxVersion, ciphers and groups may only be set when profile is custom", + "rule": "self.profile == 'custom' || (!has(self.minVersion) && !has(self.maxVersion) && !has(self.ciphers) && !has(self.groups))" + } + ] + } + }, + "type": "object" + }, + "status": { + "properties": { + "isReady": { + "type": "boolean" + }, + "kbsConfigRef": { + "properties": { + "apiVersion": { + "type": "string" + }, + "fieldPath": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "resourceVersion": { + "type": "string" + }, + "uid": { + "type": "string" + } + }, + "type": "object", + "x-kubernetes-map-type": "atomic" + }, + "statusDescription": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" +} diff --git a/scripts/ci/vendor_crd_schemas.py b/scripts/ci/vendor_crd_schemas.py index e47fd5697..1afb8d912 100644 --- a/scripts/ci/vendor_crd_schemas.py +++ b/scripts/ci/vendor_crd_schemas.py @@ -8,6 +8,7 @@ import yaml TARGETS = { + ("confidentialcontainers.org", "TrusteeConfig"): "v1alpha1", ("kataconfiguration.openshift.io", "KataConfig"): "v1", ("rhdh.redhat.com", "Backstage"): "v1alpha5", ("hco.kubevirt.io", "HyperConverged"): "v1beta1", diff --git a/scripts/saw-profile-catalog.py b/scripts/saw-profile-catalog.py index 789e30b61..2f0ddac91 100644 --- a/scripts/saw-profile-catalog.py +++ b/scripts/saw-profile-catalog.py @@ -571,6 +571,10 @@ def main(argv=None): extra = [p for p in sorted(INSTALLER_PROFILES.glob("*.yaml")) if p not in mirror] lifecycle = TEMPLATE_OUTPUT.with_name("set-workspace-state.yaml") policy_outputs = [ + (ROOT / "charts/saw-users/files/preflight.py", + (ROOT / "charts/saw-portal-container/files/preflight.py").read_text()), + (ROOT / "charts/openshell-rhdh/files/preflight.py", + (ROOT / "charts/saw-portal-container/files/preflight.py").read_text()), (ROOT / "charts/openshell-rhdh/files/saw_keycloak_admin.py", (ROOT / "charts/openshell-keycloak/files/saw_keycloak_admin.py").read_text()), (ROOT / "charts/saw-workspace-relay/files/saw_ui_limit.py", diff --git a/tests/charts/test_openshell_rhdh_chart.py b/tests/charts/test_openshell_rhdh_chart.py index 2557ef936..523b73e83 100644 --- a/tests/charts/test_openshell_rhdh_chart.py +++ b/tests/charts/test_openshell_rhdh_chart.py @@ -801,6 +801,12 @@ def test_kata_preflight_read_access_includes_the_rhdh_generator(): ("ServiceAccount", "saw-portal-provisioner", "saw-portal"), ("ServiceAccount", "saw-workspaces-generator", "saw-portal"), } + olm = one(docs, "Role", "saw-portal-osc-preflight") + assert olm["metadata"]["namespace"] == "openshift-sandboxed-containers-operator" + assert olm["rules"] == [{"apiGroups": ["operators.coreos.com"], + "resources": ["subscriptions", "clusterserviceversions"], "verbs": ["list"]}] + olm_binding = one(docs, "RoleBinding", "saw-portal-osc-preflight") + assert olm_binding["subjects"] == binding["subjects"] @pytest.mark.ci_external diff --git a/tests/charts/test_portal_container.py b/tests/charts/test_portal_container.py index 663ba0e58..c306adf7a 100644 --- a/tests/charts/test_portal_container.py +++ b/tests/charts/test_portal_container.py @@ -405,6 +405,29 @@ def test_static_kata_projector_can_read_only_approved_platform_metadata(): assert any(rule.get("resources") == ["nodes"] and rule.get("verbs") == ["list"] for rule in role["rules"]) assert all("secrets" not in rule.get("resources", []) for rule in role["rules"]) + olm, = [obj for obj in docs if obj["kind"] == "Role" + and obj["metadata"]["namespace"] == "openshift-sandboxed-containers-operator"] + assert olm["rules"] == [{"apiGroups": ["operators.coreos.com"], + "resources": ["subscriptions", "clusterserviceversions"], "verbs": ["list"]}] + + +def test_kata_enrollment_has_only_namespace_scoped_operator_read_access(): + site = copy.deepcopy(SITE) + site["kataRuntimeClass"] = {"name": "kata", "uid": "11111111-1111-4111-8111-111111111111", + "sha256": "a" * 64} + site["automaticEnrollment"]["reference"].update( + sandboxPlacement="a" * 64, sandboxPlacementBinding="b" * 64) + resources = render("saw-portal-container", U, "saw-" + U, { + "global": GLOBAL, "owner": U, "ownerSubject": site["subject"], "registration": REG, + "installationID": user()["installationID"], "vaultPrefix": user()["vaultPrefix"], "site": site}) + olm, = [obj for obj in resources if obj["kind"] == "Role" + and obj["metadata"]["namespace"] == "openshift-sandboxed-containers-operator"] + assert olm["rules"] == [{"apiGroups": ["operators.coreos.com"], + "resources": ["subscriptions", "clusterserviceversions"], "verbs": ["list"]}] + binding, = [obj for obj in resources if obj["kind"] == "RoleBinding" + and obj["metadata"]["name"] == olm["metadata"]["name"]] + assert binding["subjects"] == [{"kind": "ServiceAccount", "name": "enroll-" + REG, + "namespace": "saw-ctl-" + REG}] def test_static_mixed_backends_keep_vm_resolution_in_the_root(): diff --git a/tests/charts/test_saw_trustee.py b/tests/charts/test_saw_trustee.py new file mode 100644 index 000000000..5831c6218 --- /dev/null +++ b/tests/charts/test_saw_trustee.py @@ -0,0 +1,94 @@ +"""The optional Trustee capability selects scoped values and starts denied.""" +from pathlib import Path +import subprocess + +import pytest +import yaml + +ROOT = Path(__file__).resolve().parents[2] +CHART = ROOT / "charts/saw-trustee" + + +def render(*args): + result = subprocess.run(["helm", "template", "saw-trustee", str(CHART), + "--namespace", "trustee-operator-system", *args], + text=True, capture_output=True) + return result, [obj for obj in yaml.safe_load_all(result.stdout) if obj] + + +def selected_overlay(tmp_path, enabled): + # Execute the real sharedValueFiles expression with Helm, as the Patterns + # Operator does. Do not implement a second Python selector for this test. + chart = tmp_path / "selector" + (chart / "templates").mkdir(parents=True) + (chart / "Chart.yaml").write_text("apiVersion: v2\nname: selector\nversion: 0.1.0\n") + (chart / "templates/selection.yaml").write_text( + 'apiVersion: v1\nkind: ConfigMap\nmetadata: {name: selection}\ndata:\n' + ' path: {{ tpl (index .Values.clusterGroup.sharedValueFiles 0) . | quote }}\n') + result = subprocess.run(["helm", "template", "selector", str(chart), + "-f", str(ROOT / "values-global.yaml"), + "-f", str(ROOT / "values-prod.yaml"), + "--set", "global.confidential.enabled=" + enabled], + capture_output=True, text=True) + return result + + +def test_default_chart_has_no_resources(): + result, documents = render("-f", str(ROOT / "values-global.yaml"), + "-f", str(ROOT / "overrides/values-confidential-disabled.yaml")) + assert result.returncode == 0, result.stderr + assert documents == [] + + +@pytest.mark.parametrize("enabled", ["true", "false"]) +def test_global_selects_an_existing_scoped_overlay(tmp_path, enabled): + result = selected_overlay(tmp_path, enabled) + assert result.returncode == 0, result.stderr + selected = yaml.safe_load(result.stdout)["data"]["path"] + path = ROOT / selected.lstrip("/") + values = yaml.safe_load(path.read_text()) + assert "enabled" not in values # would activate unrelated charts + if enabled == "false": + assert values == {} + else: + group = values["clusterGroup"] + assert group["subscriptions"]["trustee"]["name"] == "trustee-operator" + assert group["subscriptions"]["trustee"]["installPlanApproval"] == "Manual" + assert group["applications"]["saw-trustee"]["path"] == "charts/saw-trustee" + # Installing Trustee must not activate a worker runtime or create users. + assert "saw-kata" not in group["applications"] + assert "users" not in values + result, docs = render("-f", str(ROOT / "values-global.yaml"), "-f", str(path), + "--set", "global.confidential.enabled=" + enabled) + assert result.returncode == 0, result.stderr + assert len(docs) == (2 if enabled == "true" else 0) + + +def test_enabled_config_requires_https_and_denies_every_resource(): + result, docs = render("--set", "global.confidential.enabled=true") + assert result.returncode == 0, result.stderr + policy, config = docs + assert policy["kind"] == "NetworkPolicy" + assert policy["spec"] == {"podSelector": {"matchLabels": {"app": "kbs"}}, + "policyTypes": ["Ingress"], "ingress": []} + assert policy["metadata"]["annotations"]["argocd.argoproj.io/sync-wave"] == "-1" + assert config["kind"] == "TrusteeConfig" + assert config["spec"]["profileType"] == "Restricted" + assert config["spec"]["kbsServiceType"] == "ClusterIP" + assert config["spec"]["httpsSpec"]["tlsSecretName"] == "saw-trustee-https" + assert config["spec"]["attestationTokenVerificationSpec"]["tlsSecretName"] == "saw-trustee-token" + assert all("Prune=false" in obj["metadata"]["annotations"]["argocd.argoproj.io/sync-options"] + for obj in docs) + assert not any(obj["kind"] in {"Secret", "ConfigMap", "KataConfig", "RuntimeClass", "Route"} for obj in docs) + + +@pytest.mark.parametrize("override", ["trustee.httpsSecretName=", "trustee.attestationTokenSecretName=", + "trustee.name=../other"]) +def test_invalid_secret_references_and_names_fail(override): + result, _ = render("--set", "global.confidential.enabled=true", "--set", override) + assert result.returncode != 0 + + +def test_string_boolean_is_rejected(): + result, _ = render("--set-string", "global.confidential.enabled=false") + assert result.returncode != 0 diff --git a/tests/portal/test_portal.py b/tests/portal/test_portal.py index 27b0f26a4..4031cf824 100644 --- a/tests/portal/test_portal.py +++ b/tests/portal/test_portal.py @@ -515,6 +515,12 @@ def request(self, name, data, age=0, labels=None): @pytest.fixture def world(portal, monkeypatch, tmp_path): fake = Fake() + fake.objects[portal._preflight.OSC_SUBSCRIPTIONS_PATH] = {"items": [{ + "metadata": {"namespace": portal._preflight.OSC_NAMESPACE}, + "spec": {"name": "sandboxed-containers-operator"}, "status": {"installedCSV": "osc.v1"}}]} + fake.objects[portal._preflight.OSC_CSVS_PATH] = {"items": [{ + "metadata": {"name": "osc.v1", "namespace": portal._preflight.OSC_NAMESPACE}, + "status": {"phase": "Succeeded"}}]} fake.objects["/apis/config.openshift.io/v1/clusterversions/version"] = { "status": {"conditions": [{"type": "Available", "status": "True"}], "desired": {"version": "4.22.0"}}} @@ -2039,6 +2045,29 @@ def test_kata_portal_preflight_rejects_changed_runtime_before_vault(portal, worl assert not fake.vault and REGISTRY not in fake.objects +@pytest.mark.parametrize("missing", ["subscription", "csv", "failed-csv"]) +def test_kata_registration_requires_installed_operator_before_vault( + portal, world, monkeypatch, capsys, missing): + fake, signer = world + site = synthetic_preflight_site(portal, { + "subject": "478fdd1f-8db9-41e8-97ad-b563215c89e9", + "automaticEnrollment": {"approvedProfiles": {"audited-openclaw": "a" * 64}}, + }, "kata") + monkeypatch.setenv("SAW_DEPLOYMENT_MODES", '["vm","kata"]') + monkeypatch.setenv("SAW_CONTAINER_SITES", json.dumps({"alice": site})) + if missing == "subscription": + fake.objects[portal._preflight.OSC_SUBSCRIPTIONS_PATH] = {"items": []} + elif missing == "csv": + fake.objects[portal._preflight.OSC_CSVS_PATH] = {"items": []} + else: + fake.objects[portal._preflight.OSC_CSVS_PATH]["items"][0]["status"]["phase"] = "Failed" + fake.request("saw-req-nooperator", ds_request( + signer, deploymentMode="kata", profile="audited-openclaw")) + assert portal.main(["create", "saw-req-nooperator"]) == 1 + assert "SandboxedContainersUnavailable" in capsys.readouterr().out + assert not fake.vault and REGISTRY not in fake.objects + + def test_first_kata_registration_checks_approval_shape_without_existing_namespace(portal): site = synthetic_preflight_site(portal, { "automaticEnrollment": { diff --git a/tests/scripts/test_sandboxed_operator.py b/tests/scripts/test_sandboxed_operator.py new file mode 100644 index 000000000..725ff2d69 --- /dev/null +++ b/tests/scripts/test_sandboxed_operator.py @@ -0,0 +1,49 @@ +"""A stale Kata API must not qualify an absent or failed OSC installation.""" +import copy +import importlib.util +from pathlib import Path + +import pytest + +ROOT = Path(__file__).resolve().parents[2] +spec = importlib.util.spec_from_file_location("preflight", ROOT / "charts/saw-users/files/preflight.py") +preflight = importlib.util.module_from_spec(spec) +spec.loader.exec_module(preflight) + + +def facts(): + metadata = {"name": "sandboxed-containers-operator.v1.13.1", "namespace": preflight.OSC_NAMESPACE} + return ([{"metadata": {"name": "sandboxed-containers", "namespace": preflight.OSC_NAMESPACE}, + "spec": {"name": "sandboxed-containers-operator"}, + "status": {"installedCSV": metadata["name"]}}], + [{"metadata": metadata, "status": {"phase": "Succeeded"}}]) + + +def test_subscription_must_resolve_to_its_succeeded_csv(): + assert preflight.sandboxed_operator_ready(*facts()) + + +@pytest.mark.parametrize("change", ["absent-subscription", "absent-csv", "failed", "wrong-csv", + "wrong-package", "other-namespace", "deleting", "resolution-failed", + "malformed"]) +def test_missing_failed_or_unrelated_operator_is_not_ready(change): + subscriptions, csvs = copy.deepcopy(facts()) + if change == "absent-subscription": + subscriptions = [] + elif change == "absent-csv": + csvs = [] + elif change == "failed": + csvs[0]["status"]["phase"] = "Failed" + elif change == "wrong-csv": + subscriptions[0]["status"]["installedCSV"] = "another.v1" + elif change == "wrong-package": + subscriptions[0]["spec"]["name"] = "another-operator" + elif change == "other-namespace": + csvs[0]["metadata"]["namespace"] = "other" + elif change == "deleting": + subscriptions[0]["metadata"]["deletionTimestamp"] = "2026-12-01T00:00:00Z" + elif change == "resolution-failed": + subscriptions[0]["status"]["conditions"] = [{"type": "ResolutionFailed", "status": "True"}] + else: + subscriptions = None + assert not preflight.sandboxed_operator_ready(subscriptions, csvs) diff --git a/tests/scripts/test_saw_preflight.py b/tests/scripts/test_saw_preflight.py index 1952e8213..3249f3269 100644 --- a/tests/scripts/test_saw_preflight.py +++ b/tests/scripts/test_saw_preflight.py @@ -319,6 +319,7 @@ def test_kata_platform_requires_ready_cluster_kataconfig_workers_and_apis(): "spec": {}, }] api_readiness = {name: True for name in ( + "sandboxedOperator", "kataconfigs.kataconfiguration.openshift.io", "sandboxes.agents.x-k8s.io", "externalsecrets.external-secrets.io", "adminnetworkpolicies.policy.networking.k8s.io", "admissionregistration.k8s.io/v1", @@ -327,6 +328,9 @@ def test_kata_platform_requires_ready_cluster_kataconfig_workers_and_apis(): "desired": {"version": "4.22.22"}}} assert preflight.verify_kata_platform(site, observed, configs, nodes, api_readiness, version) == ("worker-a",) + del api_readiness["sandboxedOperator"] + with pytest.raises(preflight.PreflightError, match="SandboxedContainersUnavailable"): + preflight.verify_kata_platform(site, observed, configs, nodes, api_readiness, version) def test_kata_platform_rejects_no_ready_node_in_approved_placement(): @@ -349,6 +353,7 @@ def test_kata_platform_rejects_no_ready_node_in_approved_placement(): "installed": ["worker-a"]}}}], nodes, {name: True for name in ( + "sandboxedOperator", "kataconfigs.kataconfiguration.openshift.io", "sandboxes.agents.x-k8s.io", "externalsecrets.external-secrets.io", "adminnetworkpolicies.policy.networking.k8s.io", "admissionregistration.k8s.io/v1", diff --git a/tests/scripts/test_standalone_projector.py b/tests/scripts/test_standalone_projector.py index 769af76bf..c4995888f 100644 --- a/tests/scripts/test_standalone_projector.py +++ b/tests/scripts/test_standalone_projector.py @@ -80,6 +80,12 @@ def test_gitops_kata_preflight_checks_live_runtime(projector): "targets": {"default/notebook": {}}} crd = {"status": {"conditions": [{"type": "Established", "status": "True"}]}} observed = { + projector.preflight.OSC_SUBSCRIPTIONS_PATH: {"items": [{ + "metadata": {"namespace": projector.preflight.OSC_NAMESPACE}, + "spec": {"name": "sandboxed-containers-operator"}, "status": {"installedCSV": "osc.v1"}}]}, + projector.preflight.OSC_CSVS_PATH: {"items": [{ + "metadata": {"name": "osc.v1", "namespace": projector.preflight.OSC_NAMESPACE}, + "status": {"phase": "Succeeded"}}]}, "/apis/config.openshift.io/v1/clusterversions/version": {"status": { "conditions": [{"type": "Available", "status": "True"}], "desired": {"version": "4.22.22"}}}, @@ -100,6 +106,10 @@ def test_gitops_kata_preflight_checks_live_runtime(projector): observed["/apis/apiextensions.k8s.io/v1/customresourcedefinitions/" + name] = crd read = lambda path: observed.get(path, {}) projector.verify_gitops_preflight(owner, site, "kata", read) + saved = observed.pop(projector.preflight.OSC_CSVS_PATH) + with pytest.raises(projector.preflight.PreflightError, match="SandboxedContainersUnavailable"): + projector.verify_gitops_preflight(owner, site, "kata", read) + observed[projector.preflight.OSC_CSVS_PATH] = saved runtime["handler"] = "runc" with pytest.raises(projector.preflight.PreflightError, match="RuntimeClassHandlerMismatch"): projector.verify_gitops_preflight(owner, site, "kata", read) diff --git a/values-global.yaml b/values-global.yaml index a18a8ec6c..70fc214a8 100644 --- a/values-global.yaml +++ b/values-global.yaml @@ -3,6 +3,10 @@ global: singleArgoCD: true secretLoader: disabled: false + # Optional Red Hat build of Trustee installation. See docs/trustee.md. + # This does not activate a confidential runtime or approve workspaces. + confidential: + enabled: false # Turn off when Vault has no web-search key. Per-user webSearch.enabled wins. # Or install with: ./pattern.sh make install WEB_SEARCH_ENABLED=false webSearch: diff --git a/values-prod.yaml b/values-prod.yaml index a82d1a6de..96621b45e 100644 --- a/values-prod.yaml +++ b/values-prod.yaml @@ -10,6 +10,8 @@ ocpExternalSecrets: clusterGroup: name: prod + sharedValueFiles: + - '/overrides/values-{{ ternary "confidential" "confidential-disabled" $.Values.global.confidential.enabled }}.yaml' namespaces: external-secrets: external-secrets-operator: @@ -79,6 +81,8 @@ clusterGroup: namespace: redhat-ods-operator channel: fast sandboxed-containers: + # Required platform operator for Kata users; keep installed even when + # confidential.enabled is false. Runtime activation remains opt-in. name: sandboxed-containers-operator namespace: openshift-sandboxed-containers-operator channel: stable From 43cb88077615719faaed982cc21aca1bf93e2295 Mon Sep 17 00:00:00 2001 From: mtalvi Date: Tue, 1 Dec 2026 13:24:44 +0200 Subject: [PATCH 2/2] Fix preflight mirror catalog automation coverage --- .githooks/pre-commit | 2 +- .github/workflows/profile-catalog.yml | 6 ++++ .../test_profile_catalog_automation.py | 31 ++++++++++++------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 096735816..ed27c04c0 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -9,7 +9,7 @@ set -euo pipefail # Capture first: `git diff | grep -q` under pipefail can fail with SIGPIPE # when grep stops reading early, which would skip the regeneration. staged=$(git diff --cached --name-only) -if ! grep -qE '^(charts/saw-bom/profiles/|charts/governance-policy/profiles/|charts/openshell-saw/files/provider-profiles/|charts/openshell-saw/files/installer/saw_ui_limit\.py$|charts/saw-workspace-relay/files/saw_ui_limit\.py$|charts/openshell-saw/templates/_governed-proxy-policy\.tpl$|charts/saw-users/files/workspace\.py$|charts/openshell-keycloak/files/saw_keycloak_admin\.py$|scripts/saw-profile-catalog\.py$)' <<<"$staged"; then +if ! grep -qE '^(charts/saw-bom/profiles/|charts/governance-policy/profiles/|charts/openshell-saw/files/provider-profiles/|charts/openshell-saw/files/installer/saw_ui_limit\.py$|charts/saw-workspace-relay/files/saw_ui_limit\.py$|charts/(saw-portal-container|saw-users|openshell-rhdh)/files/preflight\.py$|charts/openshell-saw/templates/_governed-proxy-policy\.tpl$|charts/saw-users/files/workspace\.py$|charts/openshell-keycloak/files/saw_keycloak_admin\.py$|scripts/saw-profile-catalog\.py$)' <<<"$staged"; then exit 0 fi diff --git a/.github/workflows/profile-catalog.yml b/.github/workflows/profile-catalog.yml index b7687dc74..1df296ff1 100644 --- a/.github/workflows/profile-catalog.yml +++ b/.github/workflows/profile-catalog.yml @@ -29,6 +29,9 @@ on: - "charts/openshell-saw/files/provider-profiles/**" - "charts/openshell-saw/files/installer/saw_ui_limit.py" - "charts/saw-workspace-relay/files/saw_ui_limit.py" + - "charts/saw-portal-container/files/preflight.py" + - "charts/saw-users/files/preflight.py" + - "charts/openshell-rhdh/files/preflight.py" - "charts/openshell-keycloak/files/saw_keycloak_admin.py" - "charts/openshell-rhdh/files/saw_keycloak_admin.py" - "charts/saw-users/files/workspace.py" @@ -47,6 +50,9 @@ on: - "charts/openshell-saw/files/provider-profiles/**" - "charts/openshell-saw/files/installer/saw_ui_limit.py" - "charts/saw-workspace-relay/files/saw_ui_limit.py" + - "charts/saw-portal-container/files/preflight.py" + - "charts/saw-users/files/preflight.py" + - "charts/openshell-rhdh/files/preflight.py" - "charts/openshell-saw/templates/_governed-proxy-policy.tpl" - "charts/saw-bom/profiles/**" - "charts/openshell-keycloak/files/saw_keycloak_admin.py" diff --git a/tests/scripts/test_profile_catalog_automation.py b/tests/scripts/test_profile_catalog_automation.py index 9a392123d..9fe7df187 100644 --- a/tests/scripts/test_profile_catalog_automation.py +++ b/tests/scripts/test_profile_catalog_automation.py @@ -20,6 +20,11 @@ HOOK = ROOT / ".githooks" / "pre-commit" UI_SOURCE = "charts/openshell-saw/files/installer/saw_ui_limit.py" UI_MIRROR = "charts/saw-workspace-relay/files/saw_ui_limit.py" +PREFLIGHT_SOURCE = "charts/saw-portal-container/files/preflight.py" +PREFLIGHT_MIRRORS = ("charts/saw-users/files/preflight.py", + "charts/openshell-rhdh/files/preflight.py") +SOURCE_MIRRORS = [(UI_SOURCE, UI_MIRROR), + *((PREFLIGHT_SOURCE, mirror) for mirror in PREFLIGHT_MIRRORS)] def outputs(): @@ -76,7 +81,8 @@ def test_list_names_every_generated_file(): assert "charts/openshell-rhdh/files/workspace.py" in listed assert "charts/openshell-rhdh/files/saw_keycloak_admin.py" in listed assert UI_MIRROR in listed - assert len(listed) == 10 + len(shipped) + 1 + assert set(PREFLIGHT_MIRRORS) <= set(listed) + assert len(listed) == 12 + len(shipped) + 1 assert sorted(p.rsplit("/", 1)[1] for p in mirrored) == shipped assert "charts/openshell-saw/files/provider-profiles" in listed assert "charts/openshell-rhdh/files/create-workspace.yaml" in listed @@ -89,7 +95,7 @@ def scratch(tmp_path): """A git repo with the generator, the profiles and their outputs, and a PATH whose python/python3 are this interpreter (it has PyYAML).""" repo = tmp_path / "repo" - for rel in ["scripts/saw-profile-catalog.py", ".githooks/pre-commit", "charts/openshell-saw/templates/_governed-proxy-policy.tpl", "charts/saw-users/files/workspace.py", "charts/openshell-keycloak/files/saw_keycloak_admin.py", UI_SOURCE, *outputs()]: + for rel in ["scripts/saw-profile-catalog.py", ".githooks/pre-commit", "charts/openshell-saw/templates/_governed-proxy-policy.tpl", "charts/saw-users/files/workspace.py", "charts/openshell-keycloak/files/saw_keycloak_admin.py", UI_SOURCE, PREFLIGHT_SOURCE, *outputs()]: if (ROOT / rel).is_dir(): # the mirror directory is listed as an owned path continue (repo / rel).parent.mkdir(parents=True, exist_ok=True) @@ -242,23 +248,26 @@ def test_the_workflow_runs_on_profile_changes_without_pull_request_target(): assert "charts/saw-bom/profiles/**" in on["pull_request"]["paths"] assert doc["permissions"] == {"contents": "write"} for event in ("pull_request", "push"): - assert UI_SOURCE in on[event]["paths"] - assert UI_MIRROR in on[event]["paths"] + for source, mirror in SOURCE_MIRRORS: + assert source in on[event]["paths"] + assert mirror in on[event]["paths"] -@pytest.mark.parametrize("changed", [UI_SOURCE, UI_MIRROR]) -def test_transport_source_or_mirror_only_change_runs_generation(scratch, changed): +@pytest.mark.parametrize("source,mirror", SOURCE_MIRRORS) +@pytest.mark.parametrize("change_source", [True, False], ids=["source", "mirror"]) +def test_source_or_mirror_only_change_runs_generation(scratch, source, mirror, change_source): repo, env, git = scratch + changed = source if change_source else mirror target = repo / changed - target.write_text(target.read_text() + "\n# transport fixture change\n") + target.write_text(target.read_text() + "\n# mirror fixture change\n") git("add", changed) result = subprocess.run(["bash", ".githooks/pre-commit"], cwd=repo, env=env, capture_output=True, text=True) assert result.returncode == 0, result.stdout + result.stderr - assert (repo / UI_MIRROR).read_bytes() == (repo / UI_SOURCE).read_bytes() - assert git("show", ":" + UI_MIRROR).stdout == (repo / UI_SOURCE).read_text() - if changed == UI_SOURCE: - assert UI_MIRROR in git("diff", "--cached", "--name-only").stdout + assert (repo / mirror).read_bytes() == (repo / source).read_bytes() + assert git("show", ":" + mirror).stdout == (repo / source).read_text() + if change_source: + assert mirror in git("diff", "--cached", "--name-only").stdout else: assert git("diff", "--cached", "--name-only").stdout == ""