Skip to content

Commit ab91bc9

Browse files
committed
merge: refresh v0.41.0 release from main
2 parents 132b02e + 81c0a60 commit ab91bc9

58 files changed

Lines changed: 4706 additions & 253 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 377 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,377 @@
1+
name: Broker Soak Canary
2+
run-name: Broker soak Daytona canary
3+
4+
on:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: broker-soak-canary
12+
cancel-in-progress: false
13+
14+
jobs:
15+
guard:
16+
name: Guard protected canary
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 5
19+
steps:
20+
- name: Require the protected default-branch workflow
21+
shell: bash
22+
env:
23+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
24+
REF_PROTECTED: ${{ github.ref_protected }}
25+
RUN_SHA: ${{ github.sha }}
26+
WORKFLOW_SHA: ${{ github.workflow_sha }}
27+
run: |
28+
set -euo pipefail
29+
expected_ref="refs/heads/$DEFAULT_BRANCH"
30+
expected_workflow_ref="$GITHUB_REPOSITORY/.github/workflows/broker-soak-canary.yml@$expected_ref"
31+
[[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]]
32+
[[ "$GITHUB_REF" == "$expected_ref" ]]
33+
[[ "$GITHUB_WORKFLOW_REF" == "$expected_workflow_ref" ]]
34+
[[ "$REF_PROTECTED" == true ]]
35+
[[ "$WORKFLOW_SHA" == "$RUN_SHA" ]]
36+
37+
canary:
38+
name: Audit maintenance and run Daytona
39+
needs: guard
40+
runs-on: ubuntu-latest
41+
timeout-minutes: 45
42+
environment: image-publisher
43+
env:
44+
CRABBOX_COORDINATOR: ${{ vars.CRABBOX_COORDINATOR }}
45+
CRABBOX_COORDINATOR_TOKEN: ${{ secrets.CRABBOX_COORDINATOR_ADMIN_TOKEN }}
46+
CRABBOX_COORDINATOR_ADMIN_TOKEN: ${{ secrets.CRABBOX_COORDINATOR_ADMIN_TOKEN }}
47+
CRABBOX_ACCESS_CLIENT_ID: ${{ secrets.CRABBOX_ACCESS_CLIENT_ID }}
48+
CRABBOX_ACCESS_CLIENT_SECRET: ${{ secrets.CRABBOX_ACCESS_CLIENT_SECRET }}
49+
CRABBOX_OWNER: broker-soak-canary-${{ github.run_id }}@openclaw.invalid
50+
CRABBOX_ORG: openclaw
51+
CRABBOX_ENV_ALLOW: CI
52+
steps:
53+
- name: Verify broker configuration
54+
shell: bash
55+
run: |
56+
set -euo pipefail
57+
if [[ -z "$CRABBOX_COORDINATOR" ]]; then
58+
echo "::error::Set the CRABBOX_COORDINATOR variable on the image-publisher environment."
59+
exit 1
60+
fi
61+
if [[ -z "$CRABBOX_COORDINATOR_ADMIN_TOKEN" ]]; then
62+
echo "::error::Set the CRABBOX_COORDINATOR_ADMIN_TOKEN secret on the image-publisher environment."
63+
exit 1
64+
fi
65+
66+
- name: Check out protected source
67+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
68+
with:
69+
ref: ${{ github.workflow_sha }}
70+
persist-credentials: false
71+
72+
- name: Set up Go
73+
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
74+
with:
75+
go-version-file: go.mod
76+
cache: false
77+
78+
- name: Build trusted Crabbox CLI
79+
run: go build -trimpath -o bin/crabbox ./cmd/crabbox
80+
81+
- name: Collect scheduled maintenance evidence
82+
shell: bash
83+
run: |
84+
set -euo pipefail
85+
PROOF_DIR="$RUNNER_TEMP/broker-soak-proof"
86+
mkdir -p "$PROOF_DIR"
87+
88+
admin_get() {
89+
local route="$1"
90+
local output="$2"
91+
{
92+
printf 'Authorization: Bearer '
93+
printf '%s' "$CRABBOX_COORDINATOR_ADMIN_TOKEN"
94+
printf '\n'
95+
if [[ -n "$CRABBOX_ACCESS_CLIENT_ID" && -n "$CRABBOX_ACCESS_CLIENT_SECRET" ]]; then
96+
printf 'CF-Access-Client-Id: %s\n' "$CRABBOX_ACCESS_CLIENT_ID"
97+
printf 'CF-Access-Client-Secret: %s\n' "$CRABBOX_ACCESS_CLIENT_SECRET"
98+
fi
99+
} | curl --fail --silent --show-error \
100+
--connect-timeout 10 \
101+
--max-time 30 \
102+
-H @- \
103+
-o "$output" \
104+
"$CRABBOX_COORDINATOR$route"
105+
}
106+
107+
sanitize_sweep() {
108+
jq '{
109+
config: {
110+
enabled: .config.enabled,
111+
intervalSeconds: .config.intervalSeconds,
112+
graceSeconds: .config.graceSeconds
113+
},
114+
lastRun: (
115+
.lastRun
116+
| if . == null then null else {
117+
startedAt,
118+
finishedAt,
119+
mode,
120+
trigger,
121+
enabled,
122+
regions,
123+
scanned,
124+
candidateCount: (.candidates | length),
125+
terminated,
126+
errorCount: (.errors | length),
127+
nextRunAt
128+
}
129+
end
130+
)
131+
}'
132+
}
133+
134+
admin_get "/v1/admin/aws-orphan-sweep" "$RUNNER_TEMP/aws-sweep.json"
135+
admin_get "/v1/admin/azure-orphan-sweep" "$RUNNER_TEMP/azure-sweep.json"
136+
sanitize_sweep <"$RUNNER_TEMP/aws-sweep.json" >"$RUNNER_TEMP/aws-sweep-sanitized.json"
137+
sanitize_sweep <"$RUNNER_TEMP/azure-sweep.json" >"$RUNNER_TEMP/azure-sweep-sanitized.json"
138+
jq -n \
139+
--slurpfile aws "$RUNNER_TEMP/aws-sweep-sanitized.json" \
140+
--slurpfile azure "$RUNNER_TEMP/azure-sweep-sanitized.json" \
141+
'{
142+
capturedAt: (now | todateiso8601),
143+
aws: $aws[0],
144+
azure: $azure[0]
145+
}' >"$PROOF_DIR/maintenance.json"
146+
147+
jq -e '
148+
def iso_epoch:
149+
sub("\\.[0-9]+Z$"; "Z") | fromdateiso8601;
150+
def healthy_sweep:
151+
. as $sweep
152+
| ($sweep.lastRun.finishedAt | iso_epoch) as $finished
153+
| ($sweep.lastRun.nextRunAt | iso_epoch) as $next
154+
| $sweep.config.enabled == true
155+
and $sweep.lastRun.enabled == true
156+
and $sweep.lastRun.trigger == "alarm"
157+
and $sweep.lastRun.errorCount == 0
158+
and $finished <= (now + 60)
159+
and (now - $finished) <= ($sweep.config.intervalSeconds * 1.5)
160+
and now <= ($next + ($sweep.config.intervalSeconds * 0.5));
161+
(.aws | healthy_sweep) and (.azure | healthy_sweep)
162+
' "$PROOF_DIR/maintenance.json" >/dev/null
163+
164+
- name: Verify Daytona readiness
165+
shell: bash
166+
run: |
167+
set -euo pipefail
168+
PROOF_DIR="$RUNNER_TEMP/broker-soak-proof"
169+
set +e
170+
bin/crabbox doctor --provider daytona --json >"$RUNNER_TEMP/daytona-doctor.json"
171+
doctor_status=$?
172+
set -e
173+
jq '{
174+
ok,
175+
provider,
176+
checks: [
177+
.checks[] | {
178+
status,
179+
check,
180+
provider,
181+
details: {
182+
class: .details.class,
183+
hint: .details.hint,
184+
timeout: .details.timeout
185+
}
186+
}
187+
]
188+
}' "$RUNNER_TEMP/daytona-doctor.json" >"$PROOF_DIR/daytona-doctor.json"
189+
jq -e '.ok == true and .provider == "daytona"' "$PROOF_DIR/daytona-doctor.json" >/dev/null
190+
[[ "$doctor_status" -eq 0 ]]
191+
192+
- name: Run bounded Daytona canary
193+
shell: bash
194+
run: |
195+
set -euo pipefail
196+
PROOF_DIR="$RUNNER_TEMP/broker-soak-proof"
197+
set +e
198+
# The single-quoted script expands on the remote lease.
199+
# shellcheck disable=SC2016
200+
timeout --signal=TERM --kill-after=30s 20m bin/crabbox run \
201+
--provider daytona \
202+
--target linux \
203+
--network public \
204+
--tailscale=false \
205+
--ttl 20m \
206+
--idle-timeout 5m \
207+
--no-sync \
208+
--stop-after always \
209+
--timing-json \
210+
--shell -- \
211+
'set -eu; test "$(uname -s)" = Linux; printf "daytona-canary-ok\n"' \
212+
>"$RUNNER_TEMP/daytona-canary.log" 2>&1
213+
canary_status=$?
214+
set -e
215+
216+
jq -Rsc '
217+
[
218+
split("\n")[]
219+
| fromjson?
220+
| select(type == "object" and has("provider") and has("exitCode"))
221+
]
222+
| last // {}
223+
| {
224+
provider,
225+
syncMs,
226+
commandMs,
227+
totalMs,
228+
exitCode,
229+
runStatus
230+
}
231+
' "$RUNNER_TEMP/daytona-canary.log" >"$PROOF_DIR/daytona-canary.json"
232+
233+
jq -e '.provider == "daytona" and .exitCode == 0' "$PROOF_DIR/daytona-canary.json" >/dev/null
234+
[[ "$canary_status" -eq 0 ]]
235+
236+
- name: Release and verify dedicated canary leases
237+
if: always()
238+
shell: bash
239+
run: |
240+
set -euo pipefail
241+
PROOF_DIR="$RUNNER_TEMP/broker-soak-proof"
242+
mkdir -p "$PROOF_DIR"
243+
244+
request_headers() {
245+
printf 'Authorization: Bearer '
246+
printf '%s' "$CRABBOX_COORDINATOR_ADMIN_TOKEN"
247+
printf '\n'
248+
if [[ -n "$CRABBOX_ACCESS_CLIENT_ID" && -n "$CRABBOX_ACCESS_CLIENT_SECRET" ]]; then
249+
printf 'CF-Access-Client-Id: %s\n' "$CRABBOX_ACCESS_CLIENT_ID"
250+
printf 'CF-Access-Client-Secret: %s\n' "$CRABBOX_ACCESS_CLIENT_SECRET"
251+
fi
252+
}
253+
254+
admin_get() {
255+
local route="$1"
256+
local output="$2"
257+
request_headers | curl --fail --silent --show-error \
258+
--connect-timeout 10 \
259+
--max-time 30 \
260+
-H @- \
261+
-o "$output" \
262+
"$CRABBOX_COORDINATOR$route"
263+
}
264+
265+
admin_release() {
266+
local lease_id="$1"
267+
request_headers | curl --fail --silent --show-error \
268+
--connect-timeout 10 \
269+
--max-time 90 \
270+
-X POST \
271+
-H @- \
272+
-H 'Content-Type: application/json' \
273+
--data '{"delete":true}' \
274+
-o /dev/null \
275+
"$CRABBOX_COORDINATOR/v1/admin/leases/$lease_id/release"
276+
}
277+
278+
encoded_owner="$(jq -rn --arg value "$CRABBOX_OWNER" '$value | @uri')"
279+
route="/v1/admin/leases?owner=$encoded_owner&limit=100"
280+
admin_get "$route" "$RUNNER_TEMP/canary-leases-before.json"
281+
total_before="$(jq '.leases | length' "$RUNNER_TEMP/canary-leases-before.json")"
282+
[[ "$total_before" -lt 100 ]]
283+
284+
# Released/expired records are clean only after provider deletion has
285+
# completed and no retained-resource or retry marker remains.
286+
unsafe_count() {
287+
jq '[
288+
.leases[]
289+
| select(
290+
(.state != "released" and .state != "expired")
291+
or .releaseDeletesServer != null
292+
or .cleanupStartedAt != null
293+
or .cleanupError != null
294+
or .provisioningResourceMayExist == true
295+
or .providerKeyCleanupPending == true
296+
or .runtimeAdapterDeleteRequestedAt != null
297+
)
298+
] | length' "$1"
299+
}
300+
unsafe_before="$(unsafe_count "$RUNNER_TEMP/canary-leases-before.json")"
301+
302+
jq -r '
303+
.leases[]
304+
| select(
305+
(.state != "released" and .state != "expired")
306+
or .releaseDeletesServer != null
307+
or .cleanupStartedAt != null
308+
or .cleanupError != null
309+
or .provisioningResourceMayExist == true
310+
or .providerKeyCleanupPending == true
311+
or .runtimeAdapterDeleteRequestedAt != null
312+
)
313+
| select(.cleanupStartedAt == null and .runtimeAdapterDeleteRequestedAt == null)
314+
| .id
315+
' "$RUNNER_TEMP/canary-leases-before.json" |
316+
while IFS= read -r lease_id; do
317+
[[ -n "$lease_id" ]] || continue
318+
admin_release "$lease_id"
319+
done
320+
321+
remaining="$unsafe_before"
322+
total_after="$total_before"
323+
for attempt in $(seq 1 40); do
324+
admin_get "$route" "$RUNNER_TEMP/canary-leases-after.json"
325+
total_after="$(jq '.leases | length' "$RUNNER_TEMP/canary-leases-after.json")"
326+
[[ "$total_after" -lt 100 ]]
327+
remaining="$(unsafe_count "$RUNNER_TEMP/canary-leases-after.json")"
328+
[[ "$remaining" -eq 0 ]] && break
329+
[[ "$attempt" -lt 40 ]] && sleep 15
330+
done
331+
332+
jq -n \
333+
--argjson totalBefore "$total_before" \
334+
--argjson unsafeBefore "$unsafe_before" \
335+
--argjson totalAfter "$total_after" \
336+
--argjson unsafeAfter "$remaining" \
337+
'{
338+
ownerRecordsBefore: $totalBefore,
339+
unsafeBeforeCleanup: $unsafeBefore,
340+
ownerRecordsAfter: $totalAfter,
341+
unsafeAfterCleanup: $unsafeAfter
342+
}' >"$PROOF_DIR/cleanup.json"
343+
[[ "$remaining" -eq 0 ]]
344+
345+
- name: Summarize broker soak
346+
if: always()
347+
shell: bash
348+
run: |
349+
PROOF_DIR="$RUNNER_TEMP/broker-soak-proof"
350+
{
351+
echo "## Broker soak canary"
352+
echo
353+
echo "- Source commit: \`$GITHUB_SHA\`"
354+
if [[ -f "$PROOF_DIR/maintenance.json" ]]; then
355+
jq -r '
356+
"- AWS maintenance: trigger=\(.aws.lastRun.trigger) finished=\(.aws.lastRun.finishedAt) scanned=\(.aws.lastRun.scanned) candidates=\(.aws.lastRun.candidateCount) terminated=\(.aws.lastRun.terminated) errors=\(.aws.lastRun.errorCount)",
357+
"- Azure maintenance: trigger=\(.azure.lastRun.trigger) finished=\(.azure.lastRun.finishedAt) scanned=\(.azure.lastRun.scanned) candidates=\(.azure.lastRun.candidateCount) terminated=\(.azure.lastRun.terminated) errors=\(.azure.lastRun.errorCount)"
358+
' "$PROOF_DIR/maintenance.json"
359+
fi
360+
if [[ -f "$PROOF_DIR/daytona-canary.json" ]]; then
361+
jq -r '"- Daytona: status=\(.runStatus) totalMs=\(.totalMs) commandMs=\(.commandMs) exitCode=\(.exitCode)"' \
362+
"$PROOF_DIR/daytona-canary.json"
363+
fi
364+
if [[ -f "$PROOF_DIR/cleanup.json" ]]; then
365+
jq -r '"- Cleanup: unsafeBefore=\(.unsafeBeforeCleanup) unsafeAfter=\(.unsafeAfterCleanup) ownerRecords=\(.ownerRecordsAfter)"' \
366+
"$PROOF_DIR/cleanup.json"
367+
fi
368+
} >>"$GITHUB_STEP_SUMMARY"
369+
370+
- name: Upload sanitized broker soak proof
371+
if: always()
372+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
373+
with:
374+
name: broker-soak-${{ github.run_id }}
375+
path: ${{ runner.temp }}/broker-soak-proof
376+
if-no-files-found: warn
377+
retention-days: 14

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
windows-pond-mesh-cancellation:
7070
name: Windows Pond Mesh Cancellation
7171
runs-on: windows-latest
72-
timeout-minutes: 10
72+
timeout-minutes: 20
7373

7474
steps:
7575
- name: Check out
@@ -81,6 +81,9 @@ jobs:
8181
go-version-file: go.mod
8282
cache: false
8383

84+
- name: Test user directory isolation
85+
run: go test ./internal/testutil ./internal/providers/aws ./internal/providers/daytona ./internal/providers/digitalocean ./internal/providers/hyperv ./internal/providers/namespace ./internal/providers/scaleway ./internal/providers/vast ./internal/providers/vultr -count=1
86+
8487
- name: Test pond mesh cancellation
8588
run: go test ./internal/cli/ -run PondMeshCancel -count=1 -v
8689

0 commit comments

Comments
 (0)