feat(snap): add snap install method to install.sh when snap is available#1697
feat(snap): add snap install method to install.sh when snap is available#1697zyga wants to merge 3 commits into
install.sh when snap is available#1697Conversation
install.sh when snap is available
|
I pushed the changes for install.sh but I'm also working on a small integration test that checks it locally. |
53f9ff3 to
b2d9e05
Compare
…ovisioning Add snap install path to install.sh so that on Linux systems with snapd available and no native Docker Engine installed, the installer chooses the snap path. Snap is preferred when 'snap' command exists and 'snapd.socket' is active. New functions: - has_snapd(): detects snapd availability via snap command + snapd.socket - has_native_docker(): pre-flight check for conflicting native Docker - install_linux_snap(): installs openshell snap, Docker snap if missing, connects interfaces (best-effort), registers gateway via HTTP, verifies status - register_local_gateway_snap(): gateway add with http:// URL (no mTLS) - wait_for_local_gateway_listener_snap(): waits for HTTP listener linux_package_method() returns 'snap' when snapd is available and no native docker, respecting OPENSHELL_INSTALL_METHOD=classic override. The installer handles the full flow: installing Docker snap if missing, connecting all required interfaces, and registering the gateway. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Fix the snap gateway protocol from https to http to match what the installer actually registers. Correct misleading claims that the installer "exits with an error" and "refuses" snap installs on hosts with native Docker — it silently falls back to classic. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
… backend
Add Spread integration tests for install.sh using the image-garden
backend to provision cloud VMs. The test suite covers three install
paths across Ubuntu 24.04/26.04, Debian 13, and Fedora 44:
- install-snap-only: installs OpenShell as a snap on systems with
snapd but no docker
- install-classic: installs OpenShell via native packages (deb/rpm)
on systems with docker (either with or without snapd)
Cloud-init instance templates in .image-garden.mk define the pre-
installed software per system variant. A .gitignore in .image-garden/
excludes generated disk images and VM artifacts.
Tests require image-garden snap, version 0.6 from the --candidate
channel.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
| # on install; the remaining plugs need explicit connection. snap connect | ||
| # is idempotent — it succeeds whether the connection was just made or | ||
| # already existed. | ||
| as_root snap connect openshell:docker docker:docker-daemon |
There was a problem hiding this comment.
In installation.mdx it discussed this connection possibly failing due to the docker daemon not being ready yet. If that's the case, we probably want a similar comment here.
Also, if this is the problem and waiting a bit longer or retrying could be a solution, then would it make more sense to try this after the other connections, and ideally stick it in a retry loop? Something like:
| as_root snap connect openshell:docker docker:docker-daemon | |
| info "connecting openshell snap to docker daemon..." | |
| local docker_connect_attempts=0 | |
| while true; do | |
| docker_connect_attempts="$((docker_connect_attempts + 1))" | |
| if as_root snap connect openshell:docker docker:docker-daemon ; then | |
| info "openshell connected to docker daemon." | |
| break | |
| fi | |
| if [ "$docker_connect_attempts" -gt 5 ]; then | |
| info "timed out waiting for docker daemon to start." | |
| info "please ensure docker daemon has started and then run:" | |
| info " snap connect openshell:docker docker:docker-daemon" | |
| break | |
| fi | |
| info "waiting for docker daemon to start..." | |
| sleep 1 | |
| done |
| # snapd-no-docker — snapd installed, no docker. The installer | ||
| # chooses the snap install path. | ||
| # | ||
| # *-classic-docker — snapd + native docker installed. The |
There was a problem hiding this comment.
Nitpick: this should probably be
| # *-classic-docker — snapd + native docker installed. The | |
| # snapd-classic-docker — snapd + native docker installed. The |
Right now there are only snapd-classic-docker variants in spread tests and the description says snapd is present. If in the future there could be no-snapd-classic-docker, then we want to change this description here.
MitchellAugustin
left a comment
There was a problem hiding this comment.
Looks good overall. I think some of these initial setup steps might change if we change things like the snap assertions in the future, but most of it is appropriate for the current state of things.
I added an inline comment about a recommended additional step for the gateway.
I did not look in depth at the spread tests, so deferring that for the moment.
| as_root snap connect openshell:system-observe | ||
| as_root snap connect openshell:ssh-keys | ||
|
|
||
| info "installed openshell snap from Snap Store" |
There was a problem hiding this comment.
On my system with (a dev version of) the openshell snap installed that had crashed, we hang on waiting for the gateway to start. I'd recommend adding a gateway restart before we call register_local_gateway_snap here so that a restart is at least triggered, even if the actual snap install was skipped. (fixed it for me).
diff --git a/install.sh b/install.sh
index 03e41bfc..cb58ed64 100755
--- a/install.sh
+++ b/install.sh
@@ -1000,6 +1000,8 @@ install_linux_snap() {
as_root snap connect openshell:ssh-keys
info "installed openshell snap from Snap Store"
+ info "restarting local gateway..."
+ as_root systemctl restart snap.openshell.gateway.service
info "registering local gateway as ${TARGET_USER}..."
register_local_gateway_snap
wait_for_local_gateway_listener_snap
Summary
Update the installation script to use the snap package if snapd is available on the system and conditions are met. The installation instructions are updated to match.
Related Issue
#1674
Changes
Testing
mise run pre-commitpassesChecklist