-
Notifications
You must be signed in to change notification settings - Fork 0
feat(control-plane): add extra software step with mise-based runtime installs #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,6 +141,9 @@ workspace: | |
|
|
||
| env: {} | ||
|
|
||
| extraSoftware: | ||
| toolVersions: "" | ||
|
|
||
| backup: | ||
| enabled: false | ||
| restoreOnStartup: false | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -33,13 +33,33 @@ data: | |||||
| echo "Applying managed configFile.content to $CONFIG_FILE" | ||||||
| cat >"$CONFIG_FILE" <<'CLAWMACHINE_OPENCLAW_CONFIG' | ||||||
| {{ .Values.configFile.content | nindent 4 }} | ||||||
| CLAWMACHINE_OPENCLAW_CONFIG | ||||||
| CLAWMACHINE_OPENCLAW_CONFIG | ||||||
| {{- end }} | ||||||
|
Comment on lines
33
to
37
|
||||||
|
|
||||||
| warn() { | ||||||
| echo "WARNING: $*" | ||||||
| } | ||||||
|
|
||||||
| {{- if .Values.extraSoftware.toolVersions }} | ||||||
| TOOL_VERSIONS_DIR="{{ .Values.openclawConfigDir }}/workspace" | ||||||
| TOOL_VERSIONS_FILE="$TOOL_VERSIONS_DIR/.tool-versions" | ||||||
| mkdir -p "$TOOL_VERSIONS_DIR" | ||||||
|
|
||||||
| echo "Applying extra software tools from $TOOL_VERSIONS_FILE" | ||||||
| cat >"$TOOL_VERSIONS_FILE" <<'CLAWMACHINE_TOOL_VERSIONS' | ||||||
| {{ .Values.extraSoftware.toolVersions | nindent 4 }} | ||||||
| CLAWMACHINE_TOOL_VERSIONS | ||||||
|
||||||
| CLAWMACHINE_TOOL_VERSIONS | |
| CLAWMACHINE_TOOL_VERSIONS |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,6 +96,8 @@ spec: | |
| - name: picoclaw | ||
| image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
| imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
| command: ["/bin/sh", "/scripts/start-picoclaw.sh"] | ||
| args: ["gateway"] | ||
| ports: | ||
|
Comment on lines
+99
to
101
|
||
| - name: http | ||
| containerPort: {{ .Values.service.port }} | ||
|
|
@@ -128,9 +130,15 @@ spec: | |
| resources: | ||
| {{- toYaml .Values.resources | nindent 12 }} | ||
| volumeMounts: | ||
| - name: startup-script | ||
| mountPath: /scripts | ||
| - name: workspace | ||
| mountPath: {{ .Values.configFile.mountPath }} | ||
| volumes: | ||
| - name: startup-script | ||
| configMap: | ||
| name: {{ include "picoclaw.fullname" . }}-startup | ||
| defaultMode: 0755 | ||
| - name: workspace | ||
| {{- if .Values.persistence.enabled }} | ||
| persistentVolumeClaim: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,10 @@ data: | |
| #!/bin/sh | ||
| set -e | ||
|
|
||
| warn() { | ||
| echo "WARNING: $*" | ||
| } | ||
|
|
||
| # Load secrets from volume files into environment | ||
| SECRETS_DIR="/etc/claw/secrets" | ||
| if [ -d "$SECRETS_DIR" ]; then | ||
|
|
@@ -19,5 +23,29 @@ data: | |
| done | ||
| fi | ||
|
|
||
| {{- if .Values.extraSoftware.toolVersions }} | ||
| WORKSPACE_DIR="${HOME:-/home/picoclaw}/.picoclaw/workspace" | ||
| TOOL_VERSIONS_FILE="$WORKSPACE_DIR/.tool-versions" | ||
| mkdir -p "$WORKSPACE_DIR" | ||
|
|
||
| echo "Applying extra software tools from $TOOL_VERSIONS_FILE" | ||
| cat >"$TOOL_VERSIONS_FILE" <<'CLAWMACHINE_TOOL_VERSIONS' | ||
| {{ .Values.extraSoftware.toolVersions | nindent 4 }} | ||
| CLAWMACHINE_TOOL_VERSIONS | ||
| sed -i 's/^ //' "$TOOL_VERSIONS_FILE" | ||
|
|
||
|
Comment on lines
+31
to
+36
|
||
| export MISE_CACHE_DIR="$WORKSPACE_DIR/.cache/mise" | ||
| mkdir -p "$MISE_CACHE_DIR" | ||
| if ! command -v mise >/dev/null 2>&1; then | ||
| warn "mise is not available in the container; skipping extra software installation" | ||
| elif ! (cd "$WORKSPACE_DIR" && mise install); then | ||
| warn "mise install failed; continuing startup" | ||
| fi | ||
| {{- end }} | ||
|
|
||
| # Bind gateway on all interfaces for Kubernetes probes/services unless overridden. | ||
| export PICOCLAW_GATEWAY_HOST="${PICOCLAW_GATEWAY_HOST:-0.0.0.0}" | ||
| export PICOCLAW_GATEWAY_PORT="${PICOCLAW_GATEWAY_PORT:-{{ .Values.service.port }}}" | ||
|
|
||
| # Exec the picoclaw binary | ||
| exec /usr/local/bin/picoclaw "$@" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| //go:build e2e | ||
|
|
||
| package e2e | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "io" | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
|
|
||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| func waitForPodReadyBySelector(t *testing.T, namespace, labelSelector string, timeout time.Duration) string { | ||
| t.Helper() | ||
| clientset, _ := getK8sClients(t) | ||
|
|
||
| deadline := time.Now().Add(timeout) | ||
| for time.Now().Before(deadline) { | ||
| pods, err := clientset.CoreV1().Pods(namespace).List(context.Background(), metav1.ListOptions{ | ||
| LabelSelector: labelSelector, | ||
| }) | ||
| if err == nil && len(pods.Items) > 0 { | ||
| for _, pod := range pods.Items { | ||
| for _, cond := range pod.Status.Conditions { | ||
| if cond.Type == "Ready" && cond.Status == "True" { | ||
| return pod.Name | ||
| } | ||
| } | ||
| } | ||
| } | ||
| time.Sleep(3 * time.Second) | ||
| } | ||
|
|
||
| t.Fatalf("timed out waiting for ready pod with selector %q", labelSelector) | ||
| return "" | ||
| } | ||
|
|
||
| func TestOpenClawExtraSoftwareInstallsClaude(t *testing.T) { | ||
| skipIfNoServer(t) | ||
|
|
||
| clientset, config := getK8sClients(t) | ||
| const namespace = "claw-machine" | ||
| const testBotName = "e2e-openclaw-mise" | ||
|
|
||
| doDelete(t, baseURL+"/bots/"+testBotName) | ||
| time.Sleep(2 * time.Second) | ||
|
|
||
| t.Cleanup(func() { | ||
| doDelete(t, baseURL+"/bots/"+testBotName) | ||
| }) | ||
|
|
||
| body := map[string]any{ | ||
| "releaseName": testBotName, | ||
| "botType": "openclaw", | ||
| "values": map[string]any{ | ||
| "persistence": map[string]any{ | ||
| "enabled": true, | ||
| "size": "1Gi", | ||
| }, | ||
| "networkPolicy": map[string]any{ | ||
| "ingress": false, | ||
| "egress": true, | ||
| }, | ||
| "extraSoftware": map[string]any{ | ||
| "toolVersions": "claude latest", | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| resp := doPost(t, baseURL+"/bots", body) | ||
| if resp.StatusCode != 201 && resp.StatusCode != 200 && resp.StatusCode != 204 && resp.StatusCode != 202 { | ||
| b, _ := io.ReadAll(resp.Body) | ||
| t.Fatalf("create bot failed: %d — %s", resp.StatusCode, string(b)) | ||
| } | ||
| resp.Body.Close() | ||
|
|
||
| selector := fmt.Sprintf("app.kubernetes.io/instance=%s", testBotName) | ||
| waitForPodRunning(t, clientset, namespace, selector, 4*time.Minute) | ||
| podName := waitForPodReadyBySelector(t, namespace, selector, 4*time.Minute) | ||
| t.Logf("openclaw pod ready: %s", podName) | ||
|
|
||
| stdout, stderr, err := execInPod(t, clientset, config, namespace, podName, []string{ | ||
| "sh", "-lc", "cat /root/.openclaw/workspace/.tool-versions", | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("read .tool-versions failed: %v\nstderr=%s", err, stderr) | ||
| } | ||
| if !strings.Contains(stdout, "claude latest") { | ||
| t.Fatalf(".tool-versions missing expected entry; got:\n%s", stdout) | ||
| } | ||
|
|
||
| stdout, stderr, err = execInPod(t, clientset, config, namespace, podName, []string{ | ||
| "sh", "-lc", "cd /root/.openclaw/workspace && CLAUDE_BIN=\"$(mise which claude 2>/dev/null)\" && [ -n \"$CLAUDE_BIN\" ] && [ -x \"$CLAUDE_BIN\" ] && echo \"$CLAUDE_BIN\"", | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("claude binary lookup failed: %v\nstderr=%s\nstdout=%s", err, stderr, stdout) | ||
| } | ||
| t.Logf("claude binary found: %s", strings.TrimSpace(stdout)) | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -500,6 +500,23 @@ func (h *HelmHandler) NewConfigPage(w http.ResponseWriter, r *http.Request) { | |||||
| h.renderInstallConfigPage(w, r, botType, allFormValues(r)) | ||||||
| } | ||||||
|
|
||||||
| // NewSoftwarePage renders step 3 after validating step 2. | ||||||
|
||||||
| // NewSoftwarePage renders step 3 after validating step 2. | |
| // NewSoftwarePage renders step 3 after validating the release name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
.tool-versionsheredoc terminator (CLAWMACHINE_TOOL_VERSIONS) is indented. Insh, heredoc terminators must match exactly at the start of the line (unless using<<-with tabs), so the heredoc won’t close and the startup script will fail whenextraSoftware.toolVersionsis set. Remove the extra indentation or change to<<-with tab-indented terminators.