diff --git a/charts/openshell-rhdh/files/create-workspace-for-user.yaml b/charts/openshell-rhdh/files/create-workspace-for-user.yaml index a1d46dcdb..16bb26ba2 100644 --- a/charts/openshell-rhdh/files/create-workspace-for-user.yaml +++ b/charts/openshell-rhdh/files/create-workspace-for-user.yaml @@ -60,6 +60,10 @@ spec: inference__url: {title: 'inference: Endpoint base URL (OpenAI-compatible, ending in /v1)', type: string, pattern: '^https?://'} inference__model: {title: 'inference: Model', type: string} + inference__thinking: {title: 'inference: Default thinking level', type: string} + inference__reasoning: {title: 'inference: Reasoning model (true or false)', type: string} + inference__max_tokens: {title: 'inference: Maximum output tokens', type: string} + inference__context_window: {title: 'inference: Context window (tokens)', type: string} required: [inference__api_key, inference__url, inference__model] allOf: - if: @@ -116,11 +120,13 @@ spec: stringData: {action: create, token: '${{ secrets.backstageToken }}', profile: '${{ parameters.profile }}', deploymentMode: '${{ parameters.deploymentMode }}', forUser: '${{ parameters.forUser }}', inference.api_key: '${{ secrets.inference__api_key }}', inference.url: '${{ parameters.inference__url - }}', inference.model: '${{ parameters.inference__model }}', web-search.api_key: '${{ secrets.web_search__api_key - }}', inference.cuda_model: '${{ parameters.inference__cuda_model }}', gmail.client_id: '${{ - secrets.gmail__client_id }}', gmail.client_secret: '${{ secrets.gmail__client_secret }}', - gmail.refresh_token: '${{ secrets.gmail__refresh_token }}', slack.bot_token: '${{ secrets.slack__bot_token - }}'} + }}', inference.model: '${{ parameters.inference__model }}', inference.thinking: '${{ parameters.inference__thinking + }}', inference.reasoning: '${{ parameters.inference__reasoning }}', inference.max_tokens: '${{ + parameters.inference__max_tokens }}', inference.context_window: '${{ parameters.inference__context_window + }}', web-search.api_key: '${{ secrets.web_search__api_key }}', inference.cuda_model: '${{ + parameters.inference__cuda_model }}', gmail.client_id: '${{ secrets.gmail__client_id }}', + gmail.client_secret: '${{ secrets.gmail__client_secret }}', gmail.refresh_token: '${{ secrets.gmail__refresh_token + }}', slack.bot_token: '${{ secrets.slack__bot_token }}'} - id: run name: Start the pipeline action: http:backstage:request diff --git a/charts/openshell-rhdh/files/create-workspace.yaml b/charts/openshell-rhdh/files/create-workspace.yaml index 64e754a7f..35636673f 100644 --- a/charts/openshell-rhdh/files/create-workspace.yaml +++ b/charts/openshell-rhdh/files/create-workspace.yaml @@ -52,6 +52,10 @@ spec: inference__url: {title: 'inference: Endpoint base URL (OpenAI-compatible, ending in /v1)', type: string, pattern: '^https?://'} inference__model: {title: 'inference: Model', type: string} + inference__thinking: {title: 'inference: Default thinking level', type: string} + inference__reasoning: {title: 'inference: Reasoning model (true or false)', type: string} + inference__max_tokens: {title: 'inference: Maximum output tokens', type: string} + inference__context_window: {title: 'inference: Context window (tokens)', type: string} required: [inference__api_key, inference__url, inference__model] allOf: - if: @@ -108,10 +112,13 @@ spec: stringData: {action: create, token: '${{ secrets.backstageToken }}', profile: '${{ parameters.profile }}', deploymentMode: '${{ parameters.deploymentMode }}', inference.api_key: '${{ secrets.inference__api_key }}', inference.url: '${{ parameters.inference__url }}', inference.model: '${{ parameters.inference__model - }}', web-search.api_key: '${{ secrets.web_search__api_key }}', inference.cuda_model: '${{ - parameters.inference__cuda_model }}', gmail.client_id: '${{ secrets.gmail__client_id }}', - gmail.client_secret: '${{ secrets.gmail__client_secret }}', gmail.refresh_token: '${{ secrets.gmail__refresh_token - }}', slack.bot_token: '${{ secrets.slack__bot_token }}'} + }}', inference.thinking: '${{ parameters.inference__thinking }}', inference.reasoning: '${{ + parameters.inference__reasoning }}', inference.max_tokens: '${{ parameters.inference__max_tokens + }}', inference.context_window: '${{ parameters.inference__context_window }}', web-search.api_key: '${{ + secrets.web_search__api_key }}', inference.cuda_model: '${{ parameters.inference__cuda_model + }}', gmail.client_id: '${{ secrets.gmail__client_id }}', gmail.client_secret: '${{ secrets.gmail__client_secret + }}', gmail.refresh_token: '${{ secrets.gmail__refresh_token }}', slack.bot_token: '${{ secrets.slack__bot_token + }}'} - id: run name: Start the pipeline action: http:backstage:request diff --git a/charts/openshell-rhdh/files/profile-catalog.json b/charts/openshell-rhdh/files/profile-catalog.json index e8edccb1d..49cb08b08 100644 --- a/charts/openshell-rhdh/files/profile-catalog.json +++ b/charts/openshell-rhdh/files/profile-catalog.json @@ -79,6 +79,30 @@ "kind": "text", "required": true, "title": "Model" + }, + { + "key": "thinking", + "kind": "text", + "required": false, + "title": "Default thinking level" + }, + { + "key": "reasoning", + "kind": "text", + "required": false, + "title": "Reasoning model (true or false)" + }, + { + "key": "max_tokens", + "kind": "text", + "required": false, + "title": "Maximum output tokens" + }, + { + "key": "context_window", + "kind": "text", + "required": false, + "title": "Context window (tokens)" } ], "provider": "custom-inference", diff --git a/charts/openshell-saw/files/installer/apply_bom.py b/charts/openshell-saw/files/installer/apply_bom.py index 6c08f2cb2..e3f7e726d 100644 --- a/charts/openshell-saw/files/installer/apply_bom.py +++ b/charts/openshell-saw/files/installer/apply_bom.py @@ -3997,9 +3997,17 @@ def start_openclaw(self, ws, sb, provider): except ValueError as exc: raise InstallerError(f"cannot read OpenClaw managed models: {exc}") from None thinking = (sb.inference_values or {}).get("thinking", "") - if thinking: + # An explicit reasoning flag wins (MODEL_REASONING=false keeps a + # thinking default but sends no reasoning_effort); otherwise any + # thinking level but off marks the model as reasoning. + reasoning = (sb.inference_values or {}).get("reasoning") + if reasoning is None and thinking: + reasoning = thinking != "off" + limits = {k: (sb.inference_values or {})[k] for k in MODEL_LIMIT_KEYS + if k in (sb.inference_values or {})} + if reasoning is not None or limits: self.mark_reasoning_model(exec_cmd, oc_env, provider.type, model_id, - reasoning=thinking != "off") + reasoning=reasoning, limits=limits) if (sb.inference_values or {}).get("models") or previous or thinking: current_models = self.cli(*exec_cmd, "sh", "-c", f"{oc_env} openclaw config get agents.defaults --json", @@ -4088,13 +4096,17 @@ def launch_openclaw(self, ws, sb, exec_cmd, oc_env): self.clear_confinement_stop(ws, sb) self.install_keepalive(ws, sb) - def mark_reasoning_model(self, exec_cmd, oc_env, provider_type, model_id, reasoning=True): - """Set whether OpenClaw treats a custom provider's model as reasoning. + def mark_reasoning_model(self, exec_cmd, oc_env, provider_type, model_id, reasoning=True, + limits=None): + """Set whether OpenClaw treats a custom provider's model as reasoning, + and its maxTokens / contextWindow when the profile gives them. OpenClaw knows which of its own models reason; a custom model offers only default and off unless its entry says reasoning: true and lists the efforts the endpoint accepts (sent as reasoning_effort). Thinking - off marks it reasoning: false, so no effort is sent.""" + off (or reasoning: false) marks it reasoning: false, so no effort is + sent. reasoning None leaves the flag as it is.""" + limits = limits or {} key = f"models.providers.{shlex.quote(provider_type)}.models" found = self.cli(*exec_cmd, "sh", "-c", f"{oc_env} openclaw config get {key} --json", check=False, quiet=True) @@ -4108,19 +4120,21 @@ def mark_reasoning_model(self, exec_cmd, oc_env, provider_type, model_id, reason entry = next((m for m in models or [] if isinstance(m, dict) and m.get("id") in (bare, model_id)), None) if entry is None: log(f"WARN: {provider_type} has no model entry for '{bare}'; its thinking level " - "applies only if OpenClaw already treats it as a reasoning model") + "and token limits apply only if OpenClaw already has them") return - compat = entry.setdefault("compat", {}) - efforts = REASONING_EFFORTS if reasoning else None - if entry.get("reasoning") is reasoning and compat.get("supportedReasoningEfforts") == efforts: + before = json.dumps(entry, sort_keys=True) + entry.update(limits) + if reasoning is not None: + compat = entry.setdefault("compat", {}) + entry["reasoning"] = reasoning + if reasoning: + compat["supportedReasoningEfforts"] = REASONING_EFFORTS + else: + compat.pop("supportedReasoningEfforts", None) + if not compat: + entry.pop("compat") + if json.dumps(entry, sort_keys=True) == before: return - entry["reasoning"] = reasoning - if reasoning: - compat["supportedReasoningEfforts"] = REASONING_EFFORTS - else: - compat.pop("supportedReasoningEfforts", None) - if not compat: - entry.pop("compat") self.cli(*exec_cmd, "sh", "-c", f"{oc_env} openclaw config set {key} {shlex.quote(json.dumps(models))}") diff --git a/charts/openshell-saw/files/installer/saw_core.py b/charts/openshell-saw/files/installer/saw_core.py index 5138cd96e..599383085 100644 --- a/charts/openshell-saw/files/installer/saw_core.py +++ b/charts/openshell-saw/files/installer/saw_core.py @@ -200,9 +200,11 @@ class Sandbox: # (the agent, and argv, can read these): those stay on providers. env: dict = field(default_factory=dict) # `inference:` -- how the agent reaches its model: {providerRef, protocol, - # baseUrl?, model, models?, timeoutSeconds?, thinking?}. models maps optional native + # baseUrl?, model, models?, timeoutSeconds?, thinking?, reasoning?, maxTokens?, + # contextWindow?}. models maps optional native # provider names to additional chat model inputs. baseUrl/model/timeoutSeconds - # is a literal or an input ({secretKeyRef: {name, key}, default?, + # and the model settings (thinking, reasoning, maxTokens, contextWindow) + # are each a literal or an input ({secretKeyRef: {name, key}, default?, # required?, title?}); inference_values is it resolved. The installer onboards the # agent from it (by protocol, so any profile-backed provider type works). inference: dict = field(default_factory=dict) @@ -419,9 +421,12 @@ def validate_profile_document(doc, kind, where="profile"): if "protocol" in inference and not isinstance(inference["protocol"], str): raise InstallerError(f"{where}: inference.protocol must be a string") inference = _thinking_off(inference) - if "thinking" in inference and inference["thinking"] not in THINKING_LEVELS: - raise InstallerError(f"{where}: inference.thinking must be one of " - + ", ".join(THINKING_LEVELS)) + for field_name in MODEL_SETTING_KEYS: + if isinstance(inference.get(field_name), dict): + _profile_input(inference[field_name], (str,), where) + elif field_name in inference and model_setting_problem(field_name, inference[field_name]): + raise InstallerError(f"{where}: inference.{field_name} " + + model_setting_problem(field_name, inference[field_name])) for field_name in ("model", "baseUrl", "timeoutSeconds"): kinds = (str, int) if field_name == "timeoutSeconds" else (str,) if field_name in inference: @@ -732,7 +737,51 @@ def _thinking_off(inference): return inference -INFERENCE_KEYS = {"providerRef", "protocol", "baseUrl", "model", "models", "timeoutSeconds", "thinking"} +INFERENCE_KEYS = {"providerRef", "protocol", "baseUrl", "model", "models", "timeoutSeconds", "thinking", + "reasoning", "maxTokens", "contextWindow"} +# The custom model's output and context limits, written to its OpenClaw model +# entry (like NemoClaw's MODEL_MAX_TOKENS and MODEL_CONTEXT_WINDOW). +MODEL_LIMIT_KEYS = ("maxTokens", "contextWindow") +# OpenClaw model settings a profile may give as a literal or as an input +# (usually optional: {secretKeyRef, required: false}); an input that resolves +# to "" leaves the setting unapplied. +MODEL_SETTING_KEYS = ("thinking", "reasoning") + MODEL_LIMIT_KEYS + + +def _positive_int(value): + """An int (or digit string) above zero; YAML booleans are not ints here.""" + if isinstance(value, bool): + return False + if isinstance(value, str): + return value.isdigit() and int(value) > 0 + return isinstance(value, int) and value > 0 + +def model_setting_problem(key, value): + """What is wrong with a literal model setting ("" when fine).""" + if key == "thinking": + return "" if value in THINKING_LEVELS else "must be one of " + ", ".join(THINKING_LEVELS) + if key == "reasoning": + return "" if isinstance(value, bool) else "must be true or false" + return "" if _positive_int(value) else "must be a positive integer" + + +def parse_model_setting(key, text, what): + """A model setting read from a Secret (text) as its typed value.""" + text = text.strip() + if key == "reasoning": + if text.lower() not in ("true", "false"): + raise InstallerError(f"{what} must be true or false") + return text.lower() == "true" + if key == "thinking": + value = text.lower() + else: + value = int(text) if text.isdigit() else text + problem = model_setting_problem(key, value) + if problem: + raise InstallerError(f"{what} {problem}") + return value + + # OpenClaw thinking levels a profile may make the model's default. A level # other than off also marks the model as a reasoning model that accepts # these efforts, which OpenClaw only assumes for its own known models. @@ -964,8 +1013,19 @@ def resolve_inference(ws, sb, read_value, validate_endpoint, forbidden=()): if timeout and (not str(timeout).isdigit() or int(timeout) < 0): raise InstallerError(f"{where}: inference timeoutSeconds must be a non-negative integer") out["timeoutSeconds"] = int(timeout) if timeout else 0 - if spec.get("thinking"): - out["thinking"] = spec["thinking"] + for key in MODEL_SETTING_KEYS: + if key not in spec: + continue + src = spec[key] + if isinstance(src, dict): + text = resolve_bom_input(src, read_value, f"{where}: inference {key}", forbidden) + if text: + out[key] = parse_model_setting(key, text, f"{where}: inference {key}") + elif key == "thinking": + if src: + out[key] = src + else: + out[key] = int(src) if key in MODEL_LIMIT_KEYS else src if "models" in spec: out["models"] = {} for name, src in spec["models"].items(): @@ -1025,11 +1085,17 @@ def sandbox_inference_problems(sb, provider_types, declared_provider_types=None) for key in ("baseUrl", "model"): if key in spec: out += [f"inference {key} {p}" for p in input_problems(spec[key])] - if "thinking" in spec: - if spec["thinking"] not in THINKING_LEVELS: - out.append(f"inference thinking must be one of {', '.join(THINKING_LEVELS)}") + for key in MODEL_SETTING_KEYS: + if key not in spec: + continue + src = spec[key] + problems = ([f"inference {key} {p}" for p in input_problems(src)] if isinstance(src, dict) + else [f"inference {key} {model_setting_problem(key, src)}"] + if model_setting_problem(key, src) else []) + if problems: + out += problems elif sb.type != "openclaw": - out.append("inference thinking is supported only for openclaw sandboxes") + out.append(f"inference {key} is supported only for openclaw sandboxes") models = spec.get("models", {}) if not isinstance(models, dict): out.append("inference models must be a mapping of provider names to model inputs") @@ -1081,7 +1147,7 @@ def profiles_from_plan(data): 'SANDBOX_TYPES', 'BASE_URL_CONFIG_KEYS', 'InstallerError', 'Provider', 'Sandbox', 'Workspace', 'Profile', 'HarnessBundle', 'read_profile_files', '_yaml', 'parse_profiles', 'enabled_workspaces', 'validate_profiles', 'ENV_NAME_RE', 'CREDENTIAL_NAME_RE', 'ENV_VALUE_LIMIT', 'SANDBOX_ENV_KEYS', - 'INPUT_KEYS', 'secret_ref', 'secret_ref_problems', 'INFERENCE_KEYS', 'INFERENCE_PROTOCOLS', 'THINKING_LEVELS', 'REASONING_EFFORTS', + 'INPUT_KEYS', 'secret_ref', 'secret_ref_problems', 'INFERENCE_KEYS', 'MODEL_LIMIT_KEYS', 'MODEL_SETTING_KEYS', 'INFERENCE_PROTOCOLS', 'THINKING_LEVELS', 'REASONING_EFFORTS', 'PROVIDER_PROTOCOLS', 'check_env_value', 'sandbox_env_problems', 'input_problems', 'check_base_url', 'resolve_bom_input', 'resolve_inference', 'inference_protocol', 'sandbox_inference_problems', 'harness_from_plan', 'profiles_from_plan', 'validate_profile_document', 'apply_workspace_sequence', 'select_inference_provider', diff --git a/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml b/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml index 06faad112..fdb3466af 100644 --- a/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml +++ b/charts/saw-bom/profiles/custom-inference/default/sandbox.yaml @@ -31,5 +31,29 @@ spec: title: Model # Self-hosted models can take longer than the agent's default. timeoutSeconds: "300" + # Optional model settings, read from the same `inference` Secret + # (values-secret.yaml). A key that is absent or empty is not applied: + # OpenClaw keeps its own default for that setting. + # The model's default thinking level (off, minimal, low, medium or high; + # a chat's /think overrides it). + thinking: + secretKeyRef: {name: inference, key: thinking} + required: false + title: Default thinking level + # false for a model that is not a reasoning model (MODEL_REASONING=false): + # no reasoning_effort is sent, whatever the thinking level. + reasoning: + secretKeyRef: {name: inference, key: reasoning} + required: false + title: Reasoning model (true or false) + # MODEL_MAX_TOKENS / MODEL_CONTEXT_WINDOW for the model's entry. + maxTokens: + secretKeyRef: {name: inference, key: max_tokens} + required: false + title: Maximum output tokens + contextWindow: + secretKeyRef: {name: inference, key: context_window} + required: false + title: Context window (tokens) ui: route: true diff --git a/charts/saw-users/files/profile-catalog.json b/charts/saw-users/files/profile-catalog.json index e8edccb1d..49cb08b08 100644 --- a/charts/saw-users/files/profile-catalog.json +++ b/charts/saw-users/files/profile-catalog.json @@ -79,6 +79,30 @@ "kind": "text", "required": true, "title": "Model" + }, + { + "key": "thinking", + "kind": "text", + "required": false, + "title": "Default thinking level" + }, + { + "key": "reasoning", + "kind": "text", + "required": false, + "title": "Reasoning model (true or false)" + }, + { + "key": "max_tokens", + "kind": "text", + "required": false, + "title": "Maximum output tokens" + }, + { + "key": "context_window", + "kind": "text", + "required": false, + "title": "Context window (tokens)" } ], "provider": "custom-inference", diff --git a/docs/container-installation.md b/docs/container-installation.md index 01e868b88..f79d42ee6 100644 --- a/docs/container-installation.md +++ b/docs/container-installation.md @@ -18,6 +18,10 @@ owned by the pattern or RHDH. Both VM and container users can coexist in a `saw-users` installation. Each registration has one backend; it is not an in-place VM-to-container migration setting. +Kata workspaces run the same container workspace in a Kata VM, with the same +Kubernetes lifecycle and workspace BOM; for their extra placement steps, follow +the [Kata installation and Developer Hub guide](kata-workspaces.md). + ## Shared platform prerequisites Start with the SAW platform services: Keycloak/owner accounts, governance, @@ -85,8 +89,6 @@ individual workspace must not uninstall this cluster-wide dependency. ## Public inputs and credential references -For Kata workload placement, follow the [Kata installation and Developer Hub guide](kata-workspaces.md). Both modes use the same Kubernetes lifecycle and workspace BOM. - The same site object is used as `containerSites.` for static installs or `portal.containerSites.` for RHDH. It is administrator-owned, not a form field. The component wiring (namespaces, service accounts, SANs, the @@ -127,12 +129,13 @@ owner. The portal Task needs the existing read-only directory client projection ### Prepare large images on cold nodes -The pinned stock OpenShell driver rolls back a sandbox whose bootstrap remains -unfinished for five minutes. A slow first image pull can consume that entire -window. Check cold nodes when qualifying a profile. For large images, install +The stock OpenShell driver rolls back a sandbox whose runtime bootstrap is +still unfinished after `runtime_bootstrap_grace_seconds`, 300 seconds by +default (the SAW gateway chart keeps the default). A slow first image pull can +consume that entire window. Check cold nodes when qualifying a profile. For large images, install the optional `charts/saw-image-cache` chart through the clustergroup before creating workspaces. Give it the same immutable digests selected by the BOM -and site overrides. [Pinned driver](https://github.com/opendatahub-io/openshell/blob/305c8b3d7bbdb97a6f2f7264c3ad43b0087c307f/crates/openshell-driver-kubernetes/src/driver.rs#L284) +and site overrides. [Driver configuration](https://github.com/opendatahub-io/openshell/blob/c2775b8df05619cdd57cb354ea8cd829ec79ee40/crates/openshell-driver-kubernetes/src/config.rs) ```yaml # Site values @@ -750,12 +753,6 @@ python3 scripts/portal-container/check-pod-admission.py \ Each probe must report denial by the workspace Pod policy. An RBAC error, missing API, or collision with an existing Pod fails the check. -The Task reads the Tekton-owned `tekton.dev/pipelineRun` Pod label through the -downward API to identify its credential reservation. If a pending writer disappears, inspect its PipelineRun and the owned -Vault generation before clearing the writer annotation. A missing holder fails -closed. A terminated failed run can be retried for the same registration. - - ### Interrupted creates and updates RHDH reserves the registration before writing credentials. The catalog keeps @@ -766,6 +763,12 @@ project the last committed public configuration. Retry the create form with all required inputs to finish the same registration. Vault writes to multiple secrets are independent; an earlier write may already be visible to ESO. +The portal's registration Task reads the Tekton-owned `tekton.dev/pipelineRun` +Pod label through the downward API to identify its credential reservation. If a +pending writer disappears, inspect its PipelineRun and the owned Vault +generation before clearing the writer annotation. A missing holder fails +closed. A terminated failed run can be retried for the same registration. + The reconciler records the ID from a successful sandbox create before waiting for readiness. It replays an interrupted create with the original request ID on a Running pass. If shutdown encounters an outstanding create with no proven @@ -817,14 +820,15 @@ network and request decisions) over OTLP/gRPC to the collector in The demonstration debug exporter writes complete event bodies, sandbox IDs and trace details to the collector's log, with detailed output and sampling disabled. Pod logs are not durable audit storage; replace the exporter with your SIEM or -log store in `charts/saw-telemetry/values.yaml` for production. W6 inspects the -demo collector's detailed logs and requires a fresh OCSF JSON body whose sandbox -ID matches both the body and the log record's `openshell.sandbox.id` attribute. +log store in `charts/saw-telemetry/values.yaml` for production. The OCSF check +in `make e2e-workspace` (W6) inspects the demo collector's detailed logs and +requires a fresh OCSF JSON body whose sandbox ID matches both the body and the log record's `openshell.sandbox.id` attribute. When using an external exporter, verify records in that backend separately. Set `telemetry.ocsfEndpoint: ""` in `containerDefaults` to turn export off. OpenShell drops events it cannot export, and nothing waits for the collector. -OpenShell 0.1.6 does not export the agent's own tool calls; those are in the -tool gate's log below. +The gateway also relays the agent's own OTLP traces (`telemetry.agentTraces`), +but OpenClaw does not send them yet, so its tool calls appear only in the tool +gate's log below. #### Audit receipts diff --git a/docs/custom-inference.md b/docs/custom-inference.md index 696436dc1..982974418 100644 --- a/docs/custom-inference.md +++ b/docs/custom-inference.md @@ -154,6 +154,12 @@ stated (`openai`): the installer cannot infer it for a profile of your own. `off` marks it `reasoning: false` instead (like `MODEL_REASONING=false`); an unquoted YAML `off` (read as `false`) also means off. A chat's `/think` still overrides the default. VM workspaces only for now. +- `inference.reasoning: false` (like `MODEL_REASONING=false`) marks the model + not reasoning whatever the thinking level, so a level such as `high` stays + its default but no `reasoning_effort` is sent; `true` forces it on. +- `inference.maxTokens` and `inference.contextWindow` (like + `MODEL_MAX_TOKENS` and `MODEL_CONTEXT_WINDOW`) set the model entry's output + and context limits. The bundled profile uses `32768` and `128000`. ### Keycloak compatibility diff --git a/docs/versioned-bom-installer.md b/docs/versioned-bom-installer.md index 6f211d6c5..8f92d47d1 100644 --- a/docs/versioned-bom-installer.md +++ b/docs/versioned-bom-installer.md @@ -164,7 +164,9 @@ in projected Secrets mounted into the credential proxy. 1. Change `bom:` in the chart values (versions + digests; tags are refused at render time and by the installer). 2. Sync/upgrade the chart. The installer ConfigMap is part of the VM template - checksum, so KubeVirt marks the VM `RestartRequired`. + checksum, so the template no longer matches the running VM. KubeVirt does + not restart it, and may not mark it `RestartRequired`; + `make saw-restart-pending` lists it either way. 3. `virtctl restart ` (or `make saw-restart`). On boot, `saw-install` installs only the changed components. diff --git a/overrides/governance-profiles/custom-inference.yaml b/overrides/governance-profiles/custom-inference.yaml index 08bcbf272..06e8a1a2b 100644 --- a/overrides/governance-profiles/custom-inference.yaml +++ b/overrides/governance-profiles/custom-inference.yaml @@ -18,7 +18,7 @@ credentials: discovery: credentials: [api_key] endpoints: - - host: api.inference.example.com # the host of the `url` in the inference Secret + - host: api.enmaas.devshift.net # the host of the `url` in the inference Secret port: 443 # its port (443 for https without one, 8000 for a vLLM Service) protocol: rest enforcement: enforce diff --git a/overrides/saw-container-defaults.yaml b/overrides/saw-container-defaults.yaml index 5a39a8f8a..ccb0ee4c8 100644 --- a/overrides/saw-container-defaults.yaml +++ b/overrides/saw-container-defaults.yaml @@ -11,6 +11,11 @@ projection: enabled: true +# Self-service portal (openshell-rhdh reads this file too): offer Container next +# to VM. Any Keycloak user may request it; their site is containerDefaults. +portal: + deploymentModes: [vm, container, kata] + containerDefaults: # OpenClaw with /sandbox searchable by OpenShift namespace UIDs, published by # .github/workflows/build-openclaw-image.yml. OpenClaw 2026.11.8 on the AIPCC diff --git a/overrides/saw-users.yaml b/overrides/saw-users.yaml index 00565bad3..89cbfd775 100644 --- a/overrides/saw-users.yaml +++ b/overrides/saw-users.yaml @@ -1,26 +1,22 @@ # Add real account names here after creating them with keycloak-add-users. # Each entry creates saw-. Demo entries are in saw-users-demo.yaml. # -# Container workspaces: set the mode, the Keycloak subject -# (make keycloak-user-info KC_USER=) and the credential base path. -# Credentials are read from /saw-/inference (every generation). -# To start over with a fresh workspace, remove the entry, let Argo delete it, -# then add it back with a higher generation (two pushes). -# - name: alice -# ownerSubject: -# profiles: [custom-inference] -# vaultPrefix: secret/data/hub -# customInferenceURL: https:///v1 # custom-inference only -# modelInputs: -# inference.model: -# values: -# deployment: {mode: container} -users: [] +# Alice is back on the VM backend. Keep the credential base scoped to the +# current Alice registration so the VM receives the API key she just loaded. +users: + - name: alice + profiles: [custom-inference] + vaultPrefix: secret/data/hub/saw-alice + webSearch: + enabled: false + values: + deployment: {mode: vm} + # Opt in only for users of a configured custom-inference endpoint. Match # the hostname in overrides/governance-profiles/custom-inference.yaml. -# defaults: -# openshellSaw: -# egress: -# extraAllow: -# - api.inference.example.com +defaults: + openshellSaw: + egress: + extraAllow: + - api.enmaas.devshift.net diff --git a/scripts/openshell-saw-restart.sh b/scripts/openshell-saw-restart.sh index 395edc1f1..60617bacb 100755 --- a/scripts/openshell-saw-restart.sh +++ b/scripts/openshell-saw-restart.sh @@ -21,7 +21,11 @@ if [[ -z "${old_uid}" || "${phase}" != Running ]]; then exit 1 fi -if "${SCRIPT_DIR}/openshell-saw-vm-ssh.sh" 'sudo systemctl poweroff'; then +# --no-block queues the poweroff and returns at once, so the command exits 0 +# before sshd stops. A blocking poweroff races the shutdown: the tunnel drops +# first, and virtctl reports that as exit status 1, the same as a failed +# command, so the restart could not tell the two apart. +if "${SCRIPT_DIR}/openshell-saw-vm-ssh.sh" 'sudo systemctl poweroff --no-block'; then echo "Guest poweroff requested." else ssh_rc=$? diff --git a/scripts/saw-profile-catalog.py b/scripts/saw-profile-catalog.py index 789e30b61..36abecfc2 100644 --- a/scripts/saw-profile-catalog.py +++ b/scripts/saw-profile-catalog.py @@ -137,13 +137,17 @@ def secret_ref(src): def sandbox_fields(sandbox, providers=None): """(secret, field) for each input a sandbox reads from a Secret, as the - installer does: its `inference:` settings (baseUrl: a URL field; model and - timeoutSeconds: text). `env:` entries are literals fixed by the profile + installer does: its `inference:` settings (baseUrl: a URL field; model, + timeoutSeconds and the model settings: text). `env:` entries are literals fixed by the profile (a Secret value belongs on a provider) and are not asked for.""" inference = sandbox.get("inference") or {} for key, kind, title in (("baseUrl", "url", "Endpoint base URL"), ("model", "text", "Model"), - ("timeoutSeconds", "text", "Request timeout (seconds)")): + ("timeoutSeconds", "text", "Request timeout (seconds)"), + ("thinking", "text", "Default thinking level"), + ("reasoning", "text", "Reasoning model (true or false)"), + ("maxTokens", "text", "Maximum output tokens"), + ("contextWindow", "text", "Context window (tokens)")): src = inference.get(key) if secret_ref(src): yield secret_ref(src)[0], input_field(src, kind, f"{title} ({sandbox['name']})") diff --git a/scripts/saw-restart-pending.sh b/scripts/saw-restart-pending.sh index 9b5d98467..631e076b3 100755 --- a/scripts/saw-restart-pending.sh +++ b/scripts/saw-restart-pending.sh @@ -2,16 +2,28 @@ # Restart the SAW VMs whose spec changed while they were running. # # KubeVirt does not restart a running VM when its template changes (a new -# gateway.toml after switching global.governance.engine, a BOM or profile -# change without vm.liveInputs): it sets the RestartRequired condition and the -# guest keeps its old config until the next boot. This lists those VMs and, -# with CONFIRM=yes, restarts them. Users' running sandboxes stop with the VM. +# gateway.toml after switching global.governance.engine, a BOM change without +# vm.liveInputs): the guest keeps its old config until the next boot. KubeVirt +# sets RestartRequired for some changes but not for the chart's +# openshell.pattern/*-checksum annotations, so a VM is also pending when its +# template's checksums differ from the running instance's. This lists those +# VMs and, with CONFIRM=yes, restarts them. Users' running sandboxes stop with +# the VM. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" vms="$(oc get vm -A -l openshell.pattern/role=gateway -o json)" -pending="$(jq -r '.items[] - | select(any(.status.conditions[]?; .type == "RestartRequired" and .status == "True")) +vmis="$(oc get vmi -A -l openshell.pattern/role=gateway -o json)" +pending="$(jq -r --argjson vmis "${vmis}" ' + def checksums: (.metadata.annotations // {}) + | with_entries(select(.key | startswith("openshell.pattern/") and endswith("-checksum"))); + ($vmis.items | map({key: "\(.metadata.namespace)/\(.metadata.name)", value: checksums}) + | from_entries) as $running + | .items[] + | $running["\(.metadata.namespace)/\(.metadata.name)"] as $booted + | ((.spec.template // {}) | checksums) as $wanted + | select(any(.status.conditions[]?; .type == "RestartRequired" and .status == "True") + or ($booted != null and $wanted != {} and $wanted != $booted)) | [.metadata.namespace, .metadata.name] | @tsv' <<<"${vms}")" if [[ -z "${pending}" ]]; then @@ -19,7 +31,7 @@ if [[ -z "${pending}" ]]; then exit 0 fi -echo "SAW VMs waiting for a restart (RestartRequired):" +echo "SAW VMs waiting for a restart:" while IFS=$'\t' read -r ns name; do printf ' %-20s %s\n' "${name}" "${ns}" done <<<"${pending}" diff --git a/tests/charts/test_saw_users_chart.py b/tests/charts/test_saw_users_chart.py index 4311ad49c..287d76cb4 100644 --- a/tests/charts/test_saw_users_chart.py +++ b/tests/charts/test_saw_users_chart.py @@ -216,6 +216,101 @@ def test_container_entry_without_defaults_or_site_fails(tmp_path): assert result.returncode != 0 and "requires containerDefaults or a containerSites entry" in result.stderr +def container_alice(**extra): + site = yaml.safe_load((ROOT / "tests/fixtures/container-site.yaml").read_text())["portal"]["containerSites"]["alice"] + user = {"name": "alice", "registration": "3f9a1c0e7b2d4a68", "ownerSubject": site["subject"], + "profiles": ["data-science"], "intentGeneration": 1, "pruneOnRemove": True, + "vaultPrefix": "secret/data/hub/saw-alice/3f9a1c0e7b2d4a68", + "values": {"deployment": {"mode": "container"}}, **extra} + return user, {"containerSites": {"alice": site}} + + +@pytest.mark.parametrize(("given", "expected"), [ + (None, "c4d7d813-fd00-5645-b4b9-7b73e372d0dd"), # uuid5 of urn:saw:portal:alice:3f9a1c0e7b2d4a68 + ("22222222-2222-4222-8222-222222222222", "22222222-2222-4222-8222-222222222222"), +]) +def test_container_installation_id_defaults_to_portal_uuid5(tmp_path, given, expected): + user, extra = container_alice(**({"installationID": given} if given else {})) + docs = docs_from(render_file(tmp_path, [user], extra)) + namespace = [d for d in by_kind(docs, "Namespace") if d["metadata"]["name"] == "saw-alice"][0] + assert namespace["metadata"]["labels"]["saw.redhat.com/runtime-owner"] == expected + assert helm_values(app(docs, "saw-alice"))["installationID"] == expected + + +def test_minimal_container_entry_uses_cluster_defaults(tmp_path): + site = yaml.safe_load((ROOT / "tests/fixtures/container-site.yaml").read_text())["portal"]["containerSites"]["alice"] + subject = site.pop("subject") + for item in site["stack"].values(): + item.pop("revision") + site["automaticEnrollment"].pop("revision") + site["automaticEnrollment"]["relay"].pop("revision") + user = {"name": "alice", "ownerSubject": subject, "profiles": ["data-science"], + "vaultPrefix": "secret/data/hub", "values": {"deployment": {"mode": "container"}}} + docs = docs_from(render_file(tmp_path, [user], {"containerDefaults": site})) + values = helm_values(app(docs, "saw-alice")) + registration = "1f732dc2bd1766a0" # sha256("alice:1")[:16] + assert values["registration"] == registration + assert values["installationID"] == "a4300afa-4ae4-5da1-a5b1-44e50a34eb59" + assert values["vaultPrefix"] == "secret/data/hub/saw-alice/" + registration + assert values["site"]["subject"] == subject + assert {item["revision"] for item in values["site"]["stack"].values()} == {"main"} + assert values["site"]["automaticEnrollment"]["relay"]["revision"] == "main" + + +def test_vm_and_container_users_coexist(tmp_path): + site = yaml.safe_load((ROOT / "tests/fixtures/container-site.yaml").read_text())["portal"]["containerSites"]["alice"] + subject = site.pop("subject") + alice = {"name": "alice", "ownerSubject": subject, "profiles": ["data-science"], + "vaultPrefix": "secret/data/hub", "values": {"deployment": {"mode": "container"}}} + bob = {"name": "bob"} + projection = {"enabled": True, "applicationSetControllerLabels": { + "app.kubernetes.io/name": "vp-gitops-applicationset-controller"}, + "egress": [{"to": [{"ipBlock": {"cidr": "10.0.0.3/32"}}], + "ports": [{"protocol": "TCP", "port": 6443}]}]} + extra = {"containerDefaults": site, "projection": projection, "ownerResolution": {"enabled": True}} + mixed = docs_from(render_file(tmp_path, [alice, bob], extra)) + (tmp_path / "vm").mkdir() + alone = docs_from(render_file(tmp_path / "vm", [bob], {"ownerResolution": {"enabled": True}})) + + # Bob's VM resources are exactly what a VM-only list renders. + def bobs(docs): + return sorted((d["kind"], d["metadata"]["name"], json.dumps(d, sort_keys=True)) for d in docs + if d["metadata"].get("labels", {}).get("openshell.pattern/owner") == "bob" + or d["metadata"].get("namespace") == "saw-bob" or d["metadata"]["name"] == "saw-bob") + assert bobs(mixed) and bobs(mixed) == bobs(alone) + assert {"saw-bob", "saw-bob-secrets", "saw-bob-bom"} <= {d["metadata"]["name"] for d in by_kind(mixed, "Application")} + + # Alice goes through the projector only: no direct Application or Namespace. + names = {(d["kind"], d["metadata"]["name"]) for d in mixed} + assert ("Application", "saw-alice") not in names and ("Namespace", "saw-alice") not in names + config = [d for d in by_kind(mixed, "ConfigMap") if d["metadata"]["name"].endswith("-configuration")] + workspaces = json.loads(config[0]["data"]["workspaces.json"]) + assert [u["name"] for u in workspaces["users"]] == ["alice"] + assert list(workspaces["containerSites"]) == ["alice"] + assert workspaces["containerSites"]["alice"]["subject"] == subject + assert workspaces["users"][0]["registration"] == "1f732dc2bd1766a0" + assert "containerDefaults" not in workspaces + + +def test_container_user_without_subject_waits_without_blocking_others(tmp_path): + site = yaml.safe_load((ROOT / "tests/fixtures/container-site.yaml").read_text())["portal"]["containerSites"]["alice"] + site.pop("subject") + alice = {"name": "alice", "profiles": ["data-science"], "values": {"deployment": {"mode": "container"}}} + docs = docs_from(render_file(tmp_path, [alice, {"name": "bob"}], {"containerDefaults": site})) + names = {(d["kind"], d["metadata"]["name"]) for d in docs} + assert ("Application", "saw-bob") in names + assert not any(n == "saw-alice" or n.startswith("saw-alice-") for _, n in names) + waiting = [d for d in by_kind(docs, "ConfigMap") if d["metadata"]["name"] == "saw-users-awaiting-owner"] + assert waiting[0]["data"]["users"] == "alice" + + +def test_container_entry_without_defaults_or_site_fails(tmp_path): + user = {"name": "alice", "ownerSubject": "11111111-1111-4111-8111-111111111111", + "profiles": ["data-science"], "values": {"deployment": {"mode": "container"}}} + result = render_file(tmp_path, [user]) + assert result.returncode != 0 and "requires containerDefaults or a containerSites entry" in result.stderr + + def test_static_owner_revision_pin_selects_all_children_and_preserves_sibling(tmp_path): docs = docs_from(render_file(tmp_path, [ALICE, {"name": "bob"}], {"workspaceRevisions": {"alice": "a"*40}})) diff --git a/tests/installer/test_custom_endpoint.py b/tests/installer/test_custom_endpoint.py index b139c6351..27143ac2b 100644 --- a/tests/installer/test_custom_endpoint.py +++ b/tests/installer/test_custom_endpoint.py @@ -19,6 +19,9 @@ MODEL = "meta-llama/Llama-3.1-8B-Instruct" ROOT = Path(__file__).resolve().parents[2] EXTRA_PROFILE = ROOT / "overrides/governance-profiles/custom-inference.yaml" +# The optional model settings, as the inference Secret carries them. +MODEL_SETTINGS = {"thinking": "high", "reasoning": "false", "max_tokens": "32768", + "context_window": "128000"} DEFAULT_CATALOG = {"web-search": ["api.tavily.com", "api.search.brave.com", "registry.npmjs.org"], "brave": ["api.search.brave.com"], "nvidia": ["integrate.api.nvidia.com"]} @@ -36,7 +39,7 @@ def governed_catalog(fake_env): def custom_secrets(secrets_dir): inference = secrets_dir / "inference" for key, value in {"provider": "custom-inference", - "url": URL + "/", "model": MODEL}.items(): + "url": URL + "/", "model": MODEL, **MODEL_SETTINGS}.items(): (inference / key).write_text(value + "\n") return secrets_dir @@ -64,7 +67,9 @@ def test_profile_is_valid_and_reads_url_and_model_from_the_secret(ab, profiles, # ...the endpoint and model are the sandbox's (the URL normalised). sb = notebook(profiles) assert sb.inference_values == {"providerRef": "custom-inference", "protocol": "openai", - "baseUrl": URL, "model": MODEL, "timeoutSeconds": 300} + "baseUrl": URL, "model": MODEL, "timeoutSeconds": 300, + "thinking": "high", "reasoning": False, + "maxTokens": 32768, "contextWindow": 128000} assert (ab.sandbox_endpoint(sb, custom), ab.sandbox_model(sb, custom)) == (URL, MODEL) @@ -391,6 +396,8 @@ def test_a_thinking_level_marks_the_model_as_reasoning_and_sets_its_default( """OpenClaw offers only default/off for a custom model unless its entry says reasoning: true and lists the efforts; the level is then the model's default (a chat's /think still overrides it).""" + for key in ("reasoning", "maxTokens", "contextWindow"): + notebook(profiles).inference.pop(key, None) notebook(profiles).inference["thinking"] = "medium" creds = resolve(ab, profiles, custom_secrets) ab.ProfileApplier(ab.Shell(), config, creds).apply(profiles) @@ -422,6 +429,34 @@ def test_a_thinking_level_marks_the_model_as_reasoning_and_sets_its_default( "agents.defaults.models"][model_id] == {} +def test_reasoning_false_keeps_the_thinking_default_and_sets_the_token_limits( + ab, fake_env, config, profiles, custom_secrets, governed_catalog): + """MODEL_REASONING=false with a thinking level: the level stays the + model's default but no reasoning_effort is sent; maxTokens and + contextWindow land on the model's entry.""" + creds = resolve(ab, profiles, custom_secrets) + ab.ProfileApplier(ab.Shell(), config, creds).apply(profiles) + state = fake_env.openshell_state() + sb = state["sandboxes"]["default/notebook"] + sb["openclawConfig"]["models.providers.custom-inference.models"] = [ + {"id": MODEL, "name": MODEL, "contextWindow": 200000, "reasoning": True, + "compat": {"supportedReasoningEfforts": ["low", "medium", "high"]}}] + fake_env.set_openshell_state(state) + ab.ProfileApplier(ab.Shell(), config, creds).apply(profiles) + cfg = fake_env.openshell_state()["sandboxes"]["default/notebook"]["openclawConfig"] + assert cfg["models.providers.custom-inference.models"] == [ + {"id": MODEL, "name": MODEL, "contextWindow": 128000, "maxTokens": 32768, "reasoning": False}] + assert cfg["agents.defaults.models"][f"custom-inference/{MODEL}"] == {"params": {"thinking": "high"}} + + +@pytest.mark.parametrize("key,value", [("reasoning", "no"), ("maxTokens", 0), + ("contextWindow", "big"), ("maxTokens", True)]) +def test_bad_reasoning_or_token_limits_are_refused(ab, profiles, key, value): + sb = notebook(profiles) + sb.inference[key] = value + assert ab.sandbox_inference_problems(sb, {"custom-inference": "custom-inference"}) + + @pytest.mark.parametrize("level", ["max", "Medium", 1]) def test_an_unknown_thinking_level_is_refused(ab, profiles, level): sb = notebook(profiles) @@ -433,5 +468,39 @@ def test_an_unquoted_yaml_off_means_off(ab): """YAML 1.1 reads `thinking: off` as false; it still means off.""" files = profile_files("custom-inference") key = next(k for k in files if k.endswith("__sandbox.yaml")) - files[key] = files[key].replace('timeoutSeconds: "300"', 'timeoutSeconds: "300"\n thinking: off') + doc = yaml.safe_load(files[key]) + doc["spec"]["sandboxes"][0]["inference"]["thinking"] = "off" + files[key] = yaml.safe_dump(doc).replace("thinking: 'off'", "thinking: off") assert notebook(ab.parse_profiles(files)).inference["thinking"] == "off" + + +def test_model_settings_left_out_of_the_secret_are_not_applied(ab, profiles, custom_secrets): + """The settings are optional Secret inputs: an absent or empty key leaves + the setting out, so OpenClaw keeps its own default.""" + (custom_secrets / "inference" / "thinking").unlink() + (custom_secrets / "inference" / "max_tokens").write_text("\n") + resolve(ab, profiles, custom_secrets) + values = notebook(profiles).inference_values + assert "thinking" not in values and "maxTokens" not in values + assert (values["reasoning"], values["contextWindow"]) == (False, 128000) + for key in ("reasoning", "context_window"): + (custom_secrets / "inference" / key).unlink() + profiles2 = ab.parse_profiles(profile_files("custom-inference")) + resolve(ab, profiles2, custom_secrets) + assert not set(ab.MODEL_SETTING_KEYS) & set(notebook(profiles2).inference_values) + + +@pytest.mark.parametrize("key,value", [("thinking", "max"), ("reasoning", "no"), + ("max_tokens", "0"), ("context_window", "big")]) +def test_bad_model_settings_in_the_secret_are_refused(ab, profiles, custom_secrets, key, value): + (custom_secrets / "inference" / key).write_text(value + "\n") + with pytest.raises(ab.InstallerError, match="inference"): + resolve(ab, profiles, custom_secrets) + + +def test_the_secret_settings_are_optional_form_fields(ab, profiles): + """Shipped as inputs, not literals: valid, and not required.""" + spec = notebook(profiles).inference + for key in ab.MODEL_SETTING_KEYS: + assert spec[key]["required"] is False + assert not ab.sandbox_inference_problems(notebook(profiles), {"custom-inference": "custom-inference"}) diff --git a/tests/installer/test_review_135.py b/tests/installer/test_review_135.py index 38a7a5f13..e7125b0b5 100644 --- a/tests/installer/test_review_135.py +++ b/tests/installer/test_review_135.py @@ -859,7 +859,11 @@ def test_the_shipped_form_fields_match_the_profiles(): cat = json.loads((ROOT / "charts" / "openshell-rhdh" / "files" / "profile-catalog.json").read_text())["profiles"] custom = {f["key"]: f for f in cat["custom-inference"]["secrets"]["inference"]["fields"]} - assert set(custom) == {"api_key", "url", "model"} + assert set(custom) == {"api_key", "url", "model", "thinking", "reasoning", "max_tokens", + "context_window"} + # The model settings are optional: absent, OpenClaw keeps its default. + assert not any(custom[k]["required"] for k in ("thinking", "reasoning", "max_tokens", + "context_window")) assert custom["url"]["kind"] == "url" and custom["url"]["required"] ds = {f["key"]: f for f in cat["data-science"]["secrets"]["inference"]["fields"]} # One model field per sandbox: selections are not coupled. diff --git a/tests/scripts/test_make_interface.py b/tests/scripts/test_make_interface.py index 8407d8041..b4b48a5fb 100644 --- a/tests/scripts/test_make_interface.py +++ b/tests/scripts/test_make_interface.py @@ -693,11 +693,13 @@ def test_discovery_log_error_does_not_hide_build_phase(tmp_path, terminal): assert not any("imageDigest" in line for line in calls) -def fake_cluster(tmp_path, vms): +def fake_cluster(tmp_path, vms, vmis='{"items": []}'): bin_dir = tmp_path / "bin" bin_dir.mkdir() (tmp_path / "vms.json").write_text(vms) - executable(bin_dir / "oc", f'cat "{tmp_path}/vms.json"\n') + (tmp_path / "vmis.json").write_text(vmis) + executable(bin_dir / "oc", f'case " $* " in *" vmi "*) cat "{tmp_path}/vmis.json";; ' + f'*) cat "{tmp_path}/vms.json";; esac\n') executable(bin_dir / "virtctl", f'echo "$*" >> "{tmp_path}/restarted"\n') return dict(os.environ, PATH=f"{bin_dir}:{os.environ['PATH']}") @@ -735,6 +737,39 @@ def test_saw_restart_pending_restarts_only_pending_vms(tmp_path): assert (tmp_path / "restarted").read_text() == "saw-alice alice\n" +CHECKSUM_VMS = """{"items": [ + {"metadata": {"name": "alice", "namespace": "saw-alice"}, + "spec": {"template": {"metadata": {"annotations": { + "openshell.pattern/installer-checksum": "new", "openshell.pattern/cloudinit-checksum": "c1"}}}}, + "status": {"conditions": [{"type": "Ready", "status": "True"}]}}, + {"metadata": {"name": "bob", "namespace": "saw-bob"}, + "spec": {"template": {"metadata": {"annotations": { + "openshell.pattern/installer-checksum": "same", "openshell.pattern/cloudinit-checksum": "c1"}}}}, + "status": {"conditions": [{"type": "Ready", "status": "True"}]}}, + {"metadata": {"name": "carol", "namespace": "saw-carol"}, + "spec": {"template": {"metadata": {"annotations": { + "openshell.pattern/installer-checksum": "new"}}}}, + "status": {"conditions": []}} +]}""" + +CHECKSUM_VMIS = """{"items": [ + {"metadata": {"name": "alice", "namespace": "saw-alice", "annotations": { + "openshell.pattern/installer-checksum": "old", "openshell.pattern/cloudinit-checksum": "c1"}}}, + {"metadata": {"name": "bob", "namespace": "saw-bob", "annotations": { + "openshell.pattern/installer-checksum": "same", "openshell.pattern/cloudinit-checksum": "c1"}}} +]}""" + + +def test_saw_restart_pending_finds_checksum_drift_without_condition(tmp_path): + """KubeVirt 1.8 does not set RestartRequired when only the template's + checksum annotations change; a stopped VM (carol) has nothing to restart.""" + env = fake_cluster(tmp_path, CHECKSUM_VMS, CHECKSUM_VMIS) + result = run_make("saw-restart-pending", env=env) + assert result.returncode == 0, result.stderr + assert "alice" in result.stdout + assert "bob" not in result.stdout and "carol" not in result.stdout + + def test_saw_restart_pending_with_nothing_pending(tmp_path): env = fake_cluster(tmp_path, '{"items": []}') result = run_make("saw-restart-pending", "CONFIRM=yes", env=env) diff --git a/tests/scripts/test_vm_restart.py b/tests/scripts/test_vm_restart.py index a0f01ab90..47fe69a81 100644 --- a/tests/scripts/test_vm_restart.py +++ b/tests/scripts/test_vm_restart.py @@ -55,7 +55,7 @@ def run(restart_env, **overrides): def test_waits_through_old_missing_and_starting_instances(restart_env): result = run(restart_env) assert result.returncode == 0, result.stderr - assert Path(restart_env[1]["CALLS"]).read_text() == "sudo systemctl poweroff\n" + assert Path(restart_env[1]["CALLS"]).read_text() == "sudo systemctl poweroff --no-block\n" assert not Path(restart_env[1]["HOST_CALLS"]).exists() assert "Replacement VM saw-alice/alice is Running" in result.stdout assert "boot install/apply" in result.stdout @@ -75,7 +75,7 @@ def test_failed_guest_command_does_not_claim_restart_or_force_it(restart_env, ss assert "Replacement VM" not in result.stdout assert not Path(restart_env[1]["HOST_CALLS"]).exists() assert Path(restart_env[1]["COUNTER"]).read_text() == "1" - assert Path(restart_env[1]["CALLS"]).read_text() == "sudo systemctl poweroff\n" + assert Path(restart_env[1]["CALLS"]).read_text() == "sudo systemctl poweroff --no-block\n" def test_ssh_disconnect_during_poweroff_still_verifies_replacement(restart_env): diff --git a/values-secret.yaml.template b/values-secret.yaml.template index abd0437e9..d627af4e1 100644 --- a/values-secret.yaml.template +++ b/values-secret.yaml.template @@ -46,6 +46,15 @@ secrets: # # Custom keyed ports and service-CA trust are follow-up #137. # - name: api_key # path: ~/.custom-inference-api-key # may be empty for a keyless endpoint + # # Optional model settings; leave any out to keep OpenClaw's default. + # - name: thinking # off, minimal, low, medium or high + # value: high + # - name: reasoning # false: not a reasoning model, no reasoning_effort sent + # value: "false" + # - name: max_tokens # maximum output tokens + # value: "32768" + # - name: context_window # context window in tokens + # value: "128000" # Optional official APIs: enable each provider and add its name to # notebook.providers in charts/saw-bom/profiles/data-science/default.