diff --git a/.github/workflows/build-snap.yml b/.github/workflows/build-snap.yml index 45e5ee52..a00ad7b4 100644 --- a/.github/workflows/build-snap.yml +++ b/.github/workflows/build-snap.yml @@ -48,15 +48,6 @@ jobs: sudo apt remove --purge docker.io containerd runc -y sudo rm -rf /run/containerd - sudo lxd init --auto - sudo lxc network create br0 - sudo lxc profile device remove default eth0 - sudo lxc profile device add default eth0 nic network=br0 name=eth0 - sudo lxc network delete lxdbr0 - - sudo snap install juju --channel 3.6/stable - juju bootstrap localhost lxdcloud - # Allow lxd controller to reach to k8s controller on loadbalancer ip # sudo nft insert rule ip filter FORWARD tcp dport 17070 accept # sudo nft insert rule ip filter FORWARD tcp sport 17070 accept @@ -65,9 +56,12 @@ jobs: # Accept all packets filtered for forward sudo nft chain ip filter FORWARD '{policy accept;}' + sudo snap remove --purge lxd + sudo snap install --channel 3.6 juju + sudo snap install ${{ needs.build.outputs.snap }} --dangerous - openstack.sunbeam prepare-node-script | bash -x sudo snap connect openstack:juju-bin juju:juju-bin + openstack.sunbeam prepare-node-script --bootstrap | bash -x sudo snap connect openstack:dot-local-share-juju sudo snap connect openstack:dot-config-openstack sudo snap connect openstack:dot-local-share-openstack diff --git a/.github/workflows/test-snap.yml b/.github/workflows/test-snap.yml index 963e955c..644a9d13 100644 --- a/.github/workflows/test-snap.yml +++ b/.github/workflows/test-snap.yml @@ -66,16 +66,11 @@ jobs: # 2023.x, 2024.1/beta does not support k8s provider if [[ ! ${{ inputs.snap-channel }} =~ "2024.1/edge" && ${{ inputs.k8s-provider }} == "k8s" ]]; then echo "k8s provider not supported"; exit 1; fi - sudo lxd init --auto - sudo lxc network create br0 - sudo lxc profile device remove default eth0 - sudo lxc profile device add default eth0 nic network=br0 name=eth0 - sudo lxc network delete lxdbr0 - + sudo snap remove --purge lxd sudo snap install juju --channel 3.6/stable - juju bootstrap localhost lxdcloud sudo snap install openstack --channel ${{ inputs.snap-channel }} + sudo snap connect openstack:juju-bin juju:juju-bin sudo snap set openstack k8s.provider=${{ inputs.k8s-provider }} # New manifest is applicable from 2024.1/edge @@ -95,7 +90,7 @@ jobs: sed -i 's|MYSQL_ROUTER_CHARM|${{ inputs.mysql-router-charm-channel }}|' manifest.yml echo "Manifest used:" cat manifest.yml - sunbeam prepare-node-script | bash -x + sunbeam prepare-node-script --bootstrap | bash -x sg snap_daemon "sunbeam cluster bootstrap --manifest ./manifest.yml --accept-defaults --topology single --database ${{ inputs.multi-mysql }}" sg snap_daemon "sunbeam cluster list" # Note: Moving configure before enabling caas just to ensure caas images are not downloaded diff --git a/docs/deploy-locally-built-snap.md b/docs/deploy-locally-built-snap.md index a6767fa2..49b40e1b 100644 --- a/docs/deploy-locally-built-snap.md +++ b/docs/deploy-locally-built-snap.md @@ -37,7 +37,7 @@ sudo snap alias openstack.sunbeam sunbeam Prepare the node: ``` -sunbeam prepare-node-script | bash -x && newgrp snap_daemon +sunbeam prepare-node-script --bootstrap | bash -x && newgrp snap_daemon ``` Because it's installed in dangerous mode, snap connections aren't added automatically. This must be done after installing the Juju snap (Juju is installed by running the prepare node script above), and before we begin bootstrapping. So add the connections now: diff --git a/sunbeam-python/sunbeam/commands/prepare_node.py b/sunbeam-python/sunbeam/commands/prepare_node.py index c39f42b0..8c087e55 100644 --- a/sunbeam-python/sunbeam/commands/prepare_node.py +++ b/sunbeam-python/sunbeam/commands/prepare_node.py @@ -16,7 +16,7 @@ import click from rich.console import Console -from sunbeam.versions import JUJU_CHANNEL, SUPPORTED_RELEASE +from sunbeam.versions import JUJU_CHANNEL, LXD_CHANNEL, SUPPORTED_RELEASE console = Console() @@ -111,8 +111,61 @@ fi """ +BOOTSTRAP_TEMPLATE = f""" +# Install the lxd snap +sudo snap install lxd --channel {LXD_CHANNEL} +USER=$(whoami) +# Ensure current user is part of the LXD group +sudo usermod --append --groups lxd $USER + +if [ -n "$(sudo --user $USER lxc network list --format csv | grep lxdbr0)" ]; then + echo 'Sunbeam requires the LXD bridge to be called anything except lxdbr0' + exit 1 +fi + +# Try to determine if LXD is already bootstrapped +if [ -z "$(sudo --user $USER lxc storage list --format csv)" ]; +then + echo 'Bootstrapping LXD' + cat < None: +def prepare_node_script(bootstrap: bool = False, client: bool = False) -> None: """Generate script to prepare a node for Sunbeam use.""" + if bootstrap and client: + raise click.UsageError("Cannot prepare node as both client and bootstrap") script = "#!/bin/bash\n" if not client: script += PREPARE_NODE_TEMPLATE script += COMMON_TEMPLATE + if bootstrap: + script += BOOTSTRAP_TEMPLATE console.print(script, soft_wrap=True) diff --git a/sunbeam-python/sunbeam/versions.py b/sunbeam-python/sunbeam/versions.py index e259b3d0..1dd067bd 100644 --- a/sunbeam-python/sunbeam/versions.py +++ b/sunbeam-python/sunbeam/versions.py @@ -33,6 +33,7 @@ CONSUL_CHANNEL = "1.19/edge" TEMPEST_CHANNEL = "2024.1/stable" K8S_CHANNEL = "1.32/beta" +LXD_CHANNEL = "5.21/stable" # List of charms with default channels OPENSTACK_CHARMS_K8S = {