Skip to content

Commit

Permalink
Make SONiC the default flavor. (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Apr 29, 2024
1 parent 87ab548 commit 45eb9d6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
echo "MINI_LAB_VM_IMAGE=ghcr.io/metal-stack/mini-lab-vms:${IMAGE_TAG}" >> $GITHUB_ENV
echo "MINI_LAB_SONIC_IMAGE=ghcr.io/metal-stack/mini-lab-sonic:${IMAGE_TAG}" >> $GITHUB_ENV
SONIC_IMAGE_HASH=$(grep 'SONIC_REMOTE_IMG :=' Makefile | awk '{ print $3 }' | sha256sum | awk '{ print $1 }')
echo "SONIC_IMAGE_HASH=${SONIC_IMAGE_HASH}" >> $GITHUB_ENV
- name: Build and push mini-lab-vms container
uses: docker/build-push-action@v5
with:
Expand All @@ -53,6 +57,13 @@ jobs:
push: true
tags: ${{ env.MINI_LAB_SONIC_IMAGE }}

- name: Cache
uses: actions/cache@v4
with:
path: |
./sonic-vs.img
key: ${{ env.SONIC_IMAGE_HASH }}

- name: Run integration tests
shell: bash
run: |
Expand Down
24 changes: 17 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CONTAINERLAB=$(shell which containerlab)
# extra vars can be used by projects that built on the mini-lab, which want to override default configuration
ANSIBLE_EXTRA_VARS_FILE := $(or $(ANSIBLE_EXTRA_VARS_FILE),)

MINI_LAB_FLAVOR := $(or $(MINI_LAB_FLAVOR),default)
MINI_LAB_FLAVOR := $(or $(MINI_LAB_FLAVOR),sonic)
MINI_LAB_VM_IMAGE := $(or $(MINI_LAB_VM_IMAGE),ghcr.io/metal-stack/mini-lab-vms:latest)
MINI_LAB_SONIC_IMAGE := $(or $(MINI_LAB_SONIC_IMAGE),ghcr.io/metal-stack/mini-lab-sonic:latest)

Expand All @@ -24,12 +24,9 @@ MACHINE_OS=ubuntu-22.04
SONIC_REMOTE_IMG := https://sonic-build.azurewebsites.net/api/sonic/artifacts?branchName=202211&platform=vs&target=target%2Fsonic-vs.img.gz

# Machine flavors
ifeq ($(MINI_LAB_FLAVOR),default)
ifeq ($(MINI_LAB_FLAVOR),cumulus)
LAB_MACHINES=machine01,machine02
LAB_TOPOLOGY=mini-lab.cumulus.yaml
else ifeq ($(MINI_LAB_FLAVOR),cluster-api)
LAB_MACHINES=machine01,machine02,machine03
LAB_TOPOLOGY=mini-lab.cumulus.yaml
else ifeq ($(MINI_LAB_FLAVOR),sonic)
LAB_MACHINES=machine01,machine02
LAB_TOPOLOGY=mini-lab.sonic.yaml
Expand Down Expand Up @@ -85,7 +82,14 @@ partition: partition-bake

.PHONY: partition-bake
partition-bake:
# docker pull $(MINI_LAB_VM_IMAGE)
ifeq ($(MINI_LAB_FLAVOR),sonic)
ifeq ("$(wildcard sonic-vs.img)","")
$(MAKE) sonic-vs.img
endif
endif

docker pull $(MINI_LAB_VM_IMAGE)

@if ! sudo $(CONTAINERLAB) --topo $(LAB_TOPOLOGY) inspect | grep -i leaf01 > /dev/null; then \
sudo --preserve-env $(CONTAINERLAB) deploy --topo $(LAB_TOPOLOGY) --reconfigure && \
./scripts/deactivate_offloading.sh; fi
Expand Down Expand Up @@ -127,7 +131,13 @@ cleanup-control-plane:
.PHONY: cleanup-partition
cleanup-partition:
mkdir -p clab-mini-lab
sudo $(CONTAINERLAB) destroy --topo $(LAB_TOPOLOGY)

sudo $(CONTAINERLAB) destroy --topo mini-lab.cumulus.yaml

# destroying the sonic lab requires the image to exist, otherwise it fails with bind path verification
touch sonic-vs.img
sudo $(CONTAINERLAB) destroy --topo mini-lab.sonic.yaml
rm -f sonic-vs.img

.PHONY: _privatenet
_privatenet: env
Expand Down
9 changes: 9 additions & 0 deletions test/ci-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ set -e

echo "Cleanup artifacts of previous runs"

# containerlab will figure out previous run locations from the docker containers
previous_topos=$(docker inspect -f '{{ index .Config.Labels "clab-topo-file" }}' $(docker ps -aq))
for topo in previous_topos; do
previous_lab_dir=$(dirname $topo)
mkdir -p "${previous_lab_dir}/clab-mini-lab"
# destroying the sonic lab requires the image to exist, otherwise it fails with bind path verification
touch "${previous_lab_dir}/sonic-vs.img"
done

make cleanup

sudo ip r d 100.255.254.0/24 || true

0 comments on commit 45eb9d6

Please sign in to comment.