Skip to content

feat(snap): add snap install method to install.sh when snap is available#1697

Open
zyga wants to merge 3 commits into
NVIDIA:mainfrom
zyga:feature/install
Open

feat(snap): add snap install method to install.sh when snap is available#1697
zyga wants to merge 3 commits into
NVIDIA:mainfrom
zyga:feature/install

Conversation

@zyga

@zyga zyga commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

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

  • The install script detects the presence of snapd and if compatible conditions (docker) are met, installs the snap from the store.

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)
  • The install.sh script was tested in a LXD container

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

@copy-pr-bot

copy-pr-bot Bot commented Jun 2, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@drew drew changed the title Feature/install feat(snap): add snap install method to install.sh when snap is available Jun 3, 2026
@zyga zyga force-pushed the feature/install branch from a2a00e1 to a95c5fd Compare June 5, 2026 11:51
@zyga

zyga commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

I pushed the changes for install.sh but I'm also working on a small integration test that checks it locally.

@zyga zyga force-pushed the feature/install branch 2 times, most recently from 53f9ff3 to b2d9e05 Compare June 9, 2026 11:02
zyga added 3 commits June 9, 2026 18:24
…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>
@zyga zyga force-pushed the feature/install branch from b2d9e05 to 813d70a Compare June 9, 2026 16:25
@zyga zyga marked this pull request as ready for review June 9, 2026 16:25
@zyga zyga requested review from a team, derekwaynecarr and mrunalp as code owners June 9, 2026 16:25
@zyga

zyga commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@SDAChess @drew This should be good to review. Please have a look at each of the three patches in isolation. The spread test there checks install.sh across four OSes and three pre-conditions that matches the semantics of the current snap, deb and rpm packaging.

@olivercalder olivercalder left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Two comments...

Comment thread install.sh
# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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

Comment thread spread.yaml
# snapd-no-docker — snapd installed, no docker. The installer
# chooses the snap install path.
#
# *-classic-docker — snapd + native docker installed. The

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: this should probably be

Suggested change
# *-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 MitchellAugustin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread install.sh
as_root snap connect openshell:system-observe
as_root snap connect openshell:ssh-keys

info "installed openshell snap from Snap Store"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants