Skip to content

Commit ab3e357

Browse files
committed
ci(release): simplify linux canary startup
1 parent 3d1f15e commit ab3e357

1 file changed

Lines changed: 85 additions & 120 deletions

File tree

.github/workflows/release-canary.yml

Lines changed: 85 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,22 @@ jobs:
108108
set -euo pipefail
109109
110110
CONTAINER="openshell-deb-${{ matrix.deb_arch }}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
111-
IMAGE="openshell-canary-deb-systemd:${{ matrix.deb_arch }}"
111+
IMAGE="openshell-canary-deb:${{ matrix.deb_arch }}"
112112
113113
cleanup() {
114114
status=$?
115115
if docker inspect "$CONTAINER" >/dev/null 2>&1; then
116116
if [ "$status" -ne 0 ]; then
117-
echo "=== container system journal ==="
118-
docker exec "$CONTAINER" journalctl -b --no-pager -n 300 || true
119-
echo "=== openshell-gateway user journal ==="
117+
echo "=== container logs ==="
118+
docker logs "$CONTAINER" || true
119+
echo "=== podman service log ==="
120+
docker exec "$CONTAINER" tail -n 300 /tmp/podman-service.log || true
121+
echo "=== openshell gateway log ==="
122+
docker exec "$CONTAINER" tail -n 300 /tmp/openshell-gateway.log || true
123+
echo "=== podman containers ==="
120124
docker exec "$CONTAINER" bash -lc '
121-
uid="$(id -u canary 2>/dev/null || true)"
122-
if [ -n "$uid" ]; then
123-
runuser -u canary -- env \
124-
HOME=/home/canary \
125-
XDG_RUNTIME_DIR="/run/user/${uid}" \
126-
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${uid}/bus" \
127-
journalctl --user -u openshell-gateway --no-pager -n 300 || true
128-
fi
125+
podman ps -a || true
126+
podman images || true
129127
' || true
130128
fi
131129
docker rm -f "$CONTAINER" >/dev/null 2>&1 || true
@@ -136,26 +134,21 @@ jobs:
136134
137135
cat > Dockerfile.deb-canary <<'EOF'
138136
FROM ubuntu:24.04
139-
ENV container=docker
140137
RUN apt-get update && apt-get install -y --no-install-recommends \
141138
ca-certificates \
142139
curl \
143-
dbus \
144-
dbus-user-session \
145140
fuse-overlayfs \
146141
iproute2 \
147142
iptables \
143+
openssl \
148144
passwd \
149145
podman \
150146
slirp4netns \
151147
sudo \
152-
systemd \
153-
systemd-sysv \
154148
uidmap \
155149
&& apt-get clean \
156150
&& rm -rf /var/lib/apt/lists/*
157-
STOPSIGNAL SIGRTMIN+3
158-
CMD ["/sbin/init"]
151+
CMD ["sleep", "infinity"]
159152
EOF
160153
161154
docker build -t "$IMAGE" -f Dockerfile.deb-canary .
@@ -171,19 +164,6 @@ jobs:
171164
--volume /sys/fs/cgroup:/sys/fs/cgroup:rw \
172165
"$IMAGE"
173166
174-
for _ in {1..60}; do
175-
state="$(docker exec "$CONTAINER" systemctl is-system-running 2>/dev/null || true)"
176-
if [ "$state" = "running" ] || [ "$state" = "degraded" ]; then
177-
break
178-
fi
179-
sleep 1
180-
done
181-
state="$(docker exec "$CONTAINER" systemctl is-system-running 2>/dev/null || true)"
182-
if [ "$state" != "running" ] && [ "$state" != "degraded" ]; then
183-
echo "::error::systemd did not become ready in container; state=${state:-unknown}"
184-
exit 1
185-
fi
186-
187167
docker exec "$CONTAINER" mkdir -p /artifacts
188168
docker cp release-assets/. "$CONTAINER:/artifacts/"
189169
@@ -196,48 +176,48 @@ jobs:
196176
197177
apt-get update
198178
apt-get install -y /artifacts/*.deb
199-
systemctl enable --now podman.socket
200-
chmod 666 /run/podman/podman.sock
201-
202-
uid="$(id -u canary)"
203-
mkdir -p /home/canary/.config/openshell
204-
cat > /home/canary/.config/openshell/gateway.env <<EOF
205-
OPENSHELL_DRIVERS=podman
206-
OPENSHELL_PODMAN_SOCKET=/run/podman/podman.sock
207-
OPENSHELL_GRPC_ENDPOINT=http://host.containers.internal:17670
208-
EOF
209-
chown -R canary:canary /home/canary/.config/openshell
210-
chmod 600 /home/canary/.config/openshell/gateway.env
211-
212-
loginctl enable-linger canary || true
213-
systemctl start "user@${uid}.service"
214179
180+
mkdir -p /run/podman
181+
nohup podman system service --time=0 unix:///run/podman/podman.sock > /tmp/podman-service.log 2>&1 &
215182
for _ in {1..30}; do
216-
[ -S "/run/user/${uid}/bus" ] && break
183+
[ -S /run/podman/podman.sock ] && break
217184
sleep 1
218185
done
219-
test -S "/run/user/${uid}/bus"
186+
test -S /run/podman/podman.sock
187+
chmod 666 /run/podman/podman.sock
188+
189+
mkdir -p /home/canary/.config/openshell /home/canary/.local/state/openshell/gateway
190+
chown -R canary:canary /home/canary/.config/openshell /home/canary/.local/state/openshell
191+
secret="$(openssl rand -hex 32)"
192+
gateway_env=(
193+
HOME=/home/canary
194+
XDG_CONFIG_HOME=/home/canary/.config
195+
XDG_STATE_HOME=/home/canary/.local/state
196+
OPENSHELL_BIND_ADDRESS=0.0.0.0
197+
OPENSHELL_SERVER_PORT=17670
198+
OPENSHELL_DISABLE_TLS=true
199+
OPENSHELL_DISABLE_GATEWAY_AUTH=true
200+
OPENSHELL_DRIVERS=podman
201+
OPENSHELL_DB_URL=sqlite:/home/canary/.local/state/openshell/gateway/openshell.db
202+
OPENSHELL_PODMAN_SOCKET=/run/podman/podman.sock
203+
OPENSHELL_GRPC_ENDPOINT=http://host.containers.internal:17670
204+
OPENSHELL_SSH_GATEWAY_HOST=127.0.0.1
205+
OPENSHELL_SSH_GATEWAY_PORT=17670
206+
OPENSHELL_SSH_HANDSHAKE_SECRET="${secret}"
207+
OPENSHELL_PROVISION_TIMEOUT=300
208+
)
209+
210+
nohup runuser -u canary -- env "${gateway_env[@]}" openshell-gateway > /tmp/openshell-gateway.log 2>&1 &
220211
221212
as_canary() {
222213
runuser -u canary -- env \
223214
HOME=/home/canary \
224-
XDG_RUNTIME_DIR="/run/user/${uid}" \
225-
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${uid}/bus" \
215+
XDG_CONFIG_HOME=/home/canary/.config \
216+
XDG_STATE_HOME=/home/canary/.local/state \
226217
OPENSHELL_PROVISION_TIMEOUT=300 \
227218
"$@"
228219
}
229220
230-
as_canary systemctl --user daemon-reload
231-
as_canary systemctl --user enable --now openshell-gateway
232-
233-
for _ in {1..30}; do
234-
if as_canary systemctl --user is-active --quiet openshell-gateway; then
235-
break
236-
fi
237-
sleep 2
238-
done
239-
as_canary systemctl --user is-active --quiet openshell-gateway
240-
241221
as_canary openshell gateway add http://127.0.0.1:17670 --local --name local
242222
243223
for _ in {1..60}; do
@@ -311,24 +291,22 @@ jobs:
311291
set -euo pipefail
312292
313293
CONTAINER="openshell-rpm-${{ matrix.rpm_arch }}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
314-
IMAGE="openshell-canary-rpm-systemd:${{ matrix.rpm_arch }}"
294+
IMAGE="openshell-canary-rpm:${{ matrix.rpm_arch }}"
315295
316296
cleanup() {
317297
status=$?
318298
if docker inspect "$CONTAINER" >/dev/null 2>&1; then
319299
if [ "$status" -ne 0 ]; then
320-
echo "=== container system journal ==="
321-
docker exec "$CONTAINER" journalctl -b --no-pager -n 300 || true
322-
echo "=== openshell-gateway user journal ==="
300+
echo "=== container logs ==="
301+
docker logs "$CONTAINER" || true
302+
echo "=== podman service log ==="
303+
docker exec "$CONTAINER" tail -n 300 /tmp/podman-service.log || true
304+
echo "=== openshell gateway log ==="
305+
docker exec "$CONTAINER" tail -n 300 /tmp/openshell-gateway.log || true
306+
echo "=== podman containers ==="
323307
docker exec "$CONTAINER" bash -lc '
324-
uid="$(id -u canary 2>/dev/null || true)"
325-
if [ -n "$uid" ]; then
326-
runuser -u canary -- env \
327-
HOME=/home/canary \
328-
XDG_RUNTIME_DIR="/run/user/${uid}" \
329-
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${uid}/bus" \
330-
journalctl --user -u openshell-gateway --no-pager -n 300 || true
331-
fi
308+
podman ps -a || true
309+
podman images || true
332310
' || true
333311
fi
334312
docker rm -f "$CONTAINER" >/dev/null 2>&1 || true
@@ -339,24 +317,20 @@ jobs:
339317
340318
cat > Dockerfile.rpm-canary <<'EOF'
341319
FROM fedora:latest
342-
ENV container=docker
343320
RUN dnf -y install \
344321
ca-certificates \
345322
curl \
346-
dbus-daemon \
347323
fuse-overlayfs \
348324
iproute \
349325
iptables-nft \
326+
openssl \
350327
podman \
351328
shadow-utils \
352329
slirp4netns \
353330
sudo \
354-
systemd \
355-
systemd-udev \
356331
util-linux \
357332
&& dnf clean all
358-
STOPSIGNAL SIGRTMIN+3
359-
CMD ["/usr/sbin/init"]
333+
CMD ["sleep", "infinity"]
360334
EOF
361335
362336
docker build -t "$IMAGE" -f Dockerfile.rpm-canary .
@@ -372,19 +346,6 @@ jobs:
372346
--volume /sys/fs/cgroup:/sys/fs/cgroup:rw \
373347
"$IMAGE"
374348
375-
for _ in {1..60}; do
376-
state="$(docker exec "$CONTAINER" systemctl is-system-running 2>/dev/null || true)"
377-
if [ "$state" = "running" ] || [ "$state" = "degraded" ]; then
378-
break
379-
fi
380-
sleep 1
381-
done
382-
state="$(docker exec "$CONTAINER" systemctl is-system-running 2>/dev/null || true)"
383-
if [ "$state" != "running" ] && [ "$state" != "degraded" ]; then
384-
echo "::error::systemd did not become ready in container; state=${state:-unknown}"
385-
exit 1
386-
fi
387-
388349
docker exec "$CONTAINER" mkdir -p /artifacts
389350
docker cp release-assets/. "$CONTAINER:/artifacts/"
390351
@@ -397,44 +358,48 @@ jobs:
397358
398359
dnf install -y /artifacts/*.rpm
399360
400-
uid="$(id -u canary)"
401-
loginctl enable-linger canary || true
402-
systemctl start "user@${uid}.service"
403-
361+
mkdir -p /run/podman
362+
nohup podman system service --time=0 unix:///run/podman/podman.sock > /tmp/podman-service.log 2>&1 &
404363
for _ in {1..30}; do
405-
[ -S "/run/user/${uid}/bus" ] && break
364+
[ -S /run/podman/podman.sock ] && break
406365
sleep 1
407366
done
408-
test -S "/run/user/${uid}/bus"
367+
test -S /run/podman/podman.sock
368+
chmod 666 /run/podman/podman.sock
369+
370+
mkdir -p /home/canary/.config/openshell /home/canary/.local/state/openshell/gateway
371+
chown -R canary:canary /home/canary/.config/openshell /home/canary/.local/state/openshell
372+
secret="$(openssl rand -hex 32)"
373+
gateway_env=(
374+
HOME=/home/canary
375+
XDG_CONFIG_HOME=/home/canary/.config
376+
XDG_STATE_HOME=/home/canary/.local/state
377+
OPENSHELL_BIND_ADDRESS=0.0.0.0
378+
OPENSHELL_SERVER_PORT=17670
379+
OPENSHELL_DISABLE_TLS=true
380+
OPENSHELL_DISABLE_GATEWAY_AUTH=true
381+
OPENSHELL_DRIVERS=podman
382+
OPENSHELL_DB_URL=sqlite:/home/canary/.local/state/openshell/gateway/openshell.db
383+
OPENSHELL_PODMAN_SOCKET=/run/podman/podman.sock
384+
OPENSHELL_GRPC_ENDPOINT=http://host.containers.internal:17670
385+
OPENSHELL_SSH_GATEWAY_HOST=127.0.0.1
386+
OPENSHELL_SSH_GATEWAY_PORT=17670
387+
OPENSHELL_SSH_HANDSHAKE_SECRET="${secret}"
388+
OPENSHELL_PROVISION_TIMEOUT=300
389+
)
390+
391+
nohup runuser -u canary -- env "${gateway_env[@]}" openshell-gateway > /tmp/openshell-gateway.log 2>&1 &
409392
410393
as_canary() {
411394
runuser -u canary -- env \
412395
HOME=/home/canary \
413-
XDG_RUNTIME_DIR="/run/user/${uid}" \
414-
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${uid}/bus" \
396+
XDG_CONFIG_HOME=/home/canary/.config \
397+
XDG_STATE_HOME=/home/canary/.local/state \
415398
OPENSHELL_PROVISION_TIMEOUT=300 \
416399
"$@"
417400
}
418401
419-
as_canary systemctl --user daemon-reload
420-
as_canary systemctl --user enable --now podman.socket
421-
as_canary systemctl --user enable --now openshell-gateway
422-
423-
for _ in {1..30}; do
424-
if as_canary systemctl --user is-active --quiet openshell-gateway; then
425-
break
426-
fi
427-
sleep 2
428-
done
429-
as_canary systemctl --user is-active --quiet openshell-gateway
430-
431-
for _ in {1..30}; do
432-
[ -f /home/canary/.config/openshell/gateways/openshell/mtls/ca.crt ] && break
433-
sleep 1
434-
done
435-
test -f /home/canary/.config/openshell/gateways/openshell/mtls/ca.crt
436-
437-
as_canary openshell gateway add --local https://127.0.0.1:8080
402+
as_canary openshell gateway add http://127.0.0.1:17670 --local --name local
438403
439404
for _ in {1..60}; do
440405
if as_canary openshell status; then

0 commit comments

Comments
 (0)