Skip to content

Commit c3e9dfe

Browse files
committed
fix(snap): defer gateway start until Docker connects
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 5609d5c commit c3e9dfe

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

python/openshell/release_formula_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,15 @@ def test_snap_wrapper_uses_optional_gateway_config_without_generating_toml() ->
131131
assert 'exec "${SNAP}/bin/openshell-gateway" "$@"' in wrapper
132132

133133

134-
def test_snap_docker_connect_hook_restarts_gateway() -> None:
134+
def test_snap_docker_connect_hook_enables_and_starts_gateway() -> None:
135135
repo_root = Path(__file__).resolve().parents[2]
136136
hook = repo_root / "snap/hooks/connect-plug-docker"
137+
snapcraft = (repo_root / "snapcraft.yaml").read_text(encoding="utf-8")
137138

138139
assert hook.is_file()
139140
assert hook.stat().st_mode & stat.S_IXUSR
140-
assert 'snapctl restart "${SNAP_INSTANCE_NAME}.gateway"' in hook.read_text(
141+
assert "install-mode: disable" in snapcraft
142+
assert 'snapctl start --enable "${SNAP_INSTANCE_NAME}.gateway"' in hook.read_text(
141143
encoding="utf-8"
142144
)
143145

snap/hooks/connect-plug-docker

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
# SPDX-License-Identifier: Apache-2.0
44

5-
# The gateway daemon can start when this plug is still disconnected. Restart it
6-
# after Docker access becomes available so driver auto-detection runs with the
7-
# socket exposed by docker:docker-daemon. This hook does not make normal gateway
8-
# startup conditional on Docker; it runs only after an operator connects Docker.
5+
# The gateway is disabled on installation so it cannot start before this plug is
6+
# connected. Enable and start it after Docker access becomes available so driver
7+
# auto-detection runs with the socket exposed by docker:docker-daemon.
98

109
set -eu
1110

12-
snapctl restart "${SNAP_INSTANCE_NAME}.gateway"
11+
snapctl start --enable "${SNAP_INSTANCE_NAME}.gateway"

snapcraft.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ apps:
8282
gateway:
8383
command: bin/openshell-gateway-wrapper
8484
daemon: simple
85+
# Do not start before the Docker interface is available. The
86+
# connect-plug-docker hook enables and starts the gateway after Docker
87+
# access is granted, including for store-managed auto-connections.
88+
install-mode: disable
8589
# refresh-mode: endure prevents snapd from restarting the gateway daemon
8690
# during snap refreshes, which would kill active sandbox sessions.
8791
# Operators must manually restart the service after a refresh if needed.

0 commit comments

Comments
 (0)