Skip to content

Commit c933855

Browse files
authored
Put sonic image directy into container. (#164)
1 parent f4f6a95 commit c933855

File tree

7 files changed

+27
-40
lines changed

7 files changed

+27
-40
lines changed

.github/workflows/integration.yaml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ jobs:
2121
run: |
2222
[ -d "${GITHUB_WORKSPACE}" ] && sudo chown -R $USER:$USER ${GITHUB_WORKSPACE}
2323
24+
- name: Setup Containerlab
25+
run: |
26+
bash -c "$(curl -sL https://get.containerlab.dev)"
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
# we can remove desired version again after this fix was released: https://github.com/srl-labs/containerlab/pull/2000
30+
DESIRED_VERSION: v0.52.0
31+
2432
- name: Log in to the container registry
2533
uses: docker/login-action@v3
2634
with:
@@ -38,31 +46,24 @@ jobs:
3846
echo "MINI_LAB_VM_IMAGE=ghcr.io/metal-stack/mini-lab-vms:${IMAGE_TAG}" >> $GITHUB_ENV
3947
echo "MINI_LAB_SONIC_IMAGE=ghcr.io/metal-stack/mini-lab-sonic:${IMAGE_TAG}" >> $GITHUB_ENV
4048
41-
SONIC_IMAGE_HASH=$(grep 'SONIC_REMOTE_IMG :=' Makefile | awk '{ print $3 }' | sha256sum | awk '{ print $1 }')
42-
43-
echo "SONIC_IMAGE_HASH=${SONIC_IMAGE_HASH}" >> $GITHUB_ENV
44-
4549
- name: Build and push mini-lab-vms container
4650
uses: docker/build-push-action@v5
4751
with:
4852
context: ./images
4953
file: ./images/Dockerfile.vms
5054
push: true
5155
tags: ${{ env.MINI_LAB_VM_IMAGE }}
56+
cache-from: type=registry,ref=${{ env.MINI_LAB_VM_IMAGE }}
57+
cache-to: type=inline
5258

5359
- name: Build and push mini-lab-sonic container
5460
uses: docker/build-push-action@v5
5561
with:
5662
context: ./images/sonic
5763
push: true
5864
tags: ${{ env.MINI_LAB_SONIC_IMAGE }}
59-
60-
- name: Cache
61-
uses: actions/cache@v4
62-
with:
63-
path: |
64-
./sonic-vs.img
65-
key: ${{ env.SONIC_IMAGE_HASH }}
65+
cache-from: type=registry,ref=${{ env.MINI_LAB_SONIC_IMAGE }}
66+
cache-to: type=inline
6667

6768
- name: Run integration tests
6869
shell: bash
@@ -72,3 +73,4 @@ jobs:
7273
env:
7374
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
7475
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ MINI_LAB_SONIC_IMAGE := $(or $(MINI_LAB_SONIC_IMAGE),ghcr.io/metal-stack/mini-la
2020

2121
MACHINE_OS=ubuntu-22.04
2222

23-
# Check: https://sonic-build.azurewebsites.net/ui/sonic/pipelines
24-
SONIC_REMOTE_IMG := https://sonic-build.azurewebsites.net/api/sonic/artifacts?branchName=202211&platform=vs&target=target%2Fsonic-vs.img.gz
25-
2623
# Machine flavors
2724
ifeq ($(MINI_LAB_FLAVOR),cumulus)
2825
LAB_MACHINES=machine01,machine02
@@ -82,12 +79,6 @@ partition: partition-bake
8279

8380
.PHONY: partition-bake
8481
partition-bake:
85-
ifeq ($(MINI_LAB_FLAVOR),sonic)
86-
ifeq ("$(wildcard sonic-vs.img)","")
87-
$(MAKE) sonic-vs.img
88-
endif
89-
endif
90-
9182
docker pull $(MINI_LAB_VM_IMAGE)
9283

9384
@if ! sudo $(CONTAINERLAB) --topo $(LAB_TOPOLOGY) inspect | grep -i leaf01 > /dev/null; then \
@@ -131,13 +122,8 @@ cleanup-control-plane:
131122
.PHONY: cleanup-partition
132123
cleanup-partition:
133124
mkdir -p clab-mini-lab
134-
135125
sudo $(CONTAINERLAB) destroy --topo mini-lab.cumulus.yaml
136-
137-
# destroying the sonic lab requires the image to exist, otherwise it fails with bind path verification
138-
touch sonic-vs.img
139126
sudo $(CONTAINERLAB) destroy --topo mini-lab.sonic.yaml
140-
rm -f sonic-vs.img
141127

142128
.PHONY: _privatenet
143129
_privatenet: env
@@ -242,6 +228,3 @@ dev-env:
242228
@echo "export METALCTL_API_URL=http://api.172.17.0.1.nip.io:8080/metal"
243229
@echo "export METALCTL_HMAC=metal-admin"
244230
@echo "export KUBECONFIG=$(KUBECONFIG)"
245-
246-
sonic-vs.img:
247-
curl --location --output - "${SONIC_REMOTE_IMG}" | gunzip > sonic-vs.img

images/sonic/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
FROM ubuntu:22.04
22

33
ENV LIBGUESTFS_BACKEND=direct
4+
# Check: https://sonic-build.azurewebsites.net/ui/sonic/pipelines
5+
ENV SONIC_REMOTE_IMG=https://sonic-build.azurewebsites.net/api/sonic/artifacts?branchName=202211&platform=vs&target=target%2Fsonic-vs.img.gz
46

57
RUN apt-get update && \
68
apt-get --no-install-recommends install --yes \
9+
curl \
710
linux-image-5.15.0-102-generic \
811
net-tools \
912
ovmf \
1013
python3 \
1114
python3-guestfs \
1215
qemu-system-x86 \
1316
telnet \
14-
tini
17+
tini && \
18+
curl --location --output - "${SONIC_REMOTE_IMG}" | gunzip > sonic-vs.img
1519

1620
ENTRYPOINT ["/usr/bin/tini", "--"]
1721

inventories/group_vars/all/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
metal_registry_auth_enabled: "{{ lookup('env', 'CI') | default(false, true) | bool }}"
33
metal_registry_auth_user: "{{ lookup('env', 'DOCKER_HUB_USER') | default('', true) }}"
44
metal_registry_auth_password: "{{ lookup('env', 'DOCKER_HUB_TOKEN') | default('', true) }}"
5+
6+
github_runner_token: "{{ lookup('env', 'GITHUB_TOKEN') | default('', true) }}"

inventories/group_vars/control-plane/metal.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ metal_api_admin_key: metal-admin
1111

1212
metal_api_nsq_tcp_address: nsqd:4150
1313

14-
metal_api_latest_os_image_release_name: "{{ (lookup('url', 'https://api.github.com/repos/metal-stack/metal-images/releases/latest') | from_json).get('name') }}"
14+
metal_api_latest_os_image_release_name: "{{ (lookup('url', 'https://api.github.com/repos/metal-stack/metal-images/releases/latest', headers=({'authorization': 'Bearer ' + github_runner_token} if github_runner_token else {})) | from_json).get('name') }}"
1515

1616
metal_api_images:
17-
- id: firewall-ubuntu-3.0.{{ metal_api_latest_os_image_release_name }}
18-
name: Firewall 3 Ubuntu {{ metal_api_latest_os_image_release_name }}
19-
description: Firewall 3 Ubuntu {{ metal_api_latest_os_image_release_name }}
17+
- id: firewall-ubuntu-3.0
18+
name: Firewall 3 Ubuntu
19+
description: Firewall 3 Ubuntu Latest Release
2020
url: https://images.metal-stack.io/metal-os/{{ metal_api_latest_os_image_release_name }}/firewall/3.0-ubuntu/img.tar.lz4
2121
features:
2222
- firewall
23-
- id: ubuntu-22.04.{{ metal_api_latest_os_image_release_name }}
24-
name: Ubuntu 22.04 {{ metal_api_latest_os_image_release_name }}
25-
description: Ubuntu 22.04 {{ metal_api_latest_os_image_release_name }}
23+
- id: ubuntu-22.04
24+
name: Ubuntu 22.04
25+
description: Ubuntu 22.04 Latest Release
2626
url: https://images.metal-stack.io/metal-os/{{ metal_api_latest_os_image_release_name }}/ubuntu/22.04/img.tar.lz4
2727
features:
2828
- machine

mini-lab.sonic.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ topology:
1414
binds:
1515
- /dev:/dev
1616
- files/ssh/id_rsa.pub:/authorized_keys
17-
- sonic-vs.img:/sonic-vs.img
1817
leaf02:
1918
kind: linux
2019
image: ${MINI_LAB_SONIC_IMAGE}
@@ -23,7 +22,6 @@ topology:
2322
binds:
2423
- /dev:/dev
2524
- files/ssh/id_rsa.pub:/authorized_keys
26-
- sonic-vs.img:/sonic-vs.img
2725
inet:
2826
kind: linux
2927
image: quay.io/frrouting/frr:9.1.0

test/ci-cleanup.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ previous_topos=$(docker inspect -f '{{ index .Config.Labels "clab-topo-file" }}'
88
for topo in previous_topos; do
99
previous_lab_dir=$(dirname $topo)
1010
mkdir -p "${previous_lab_dir}/clab-mini-lab"
11-
# destroying the sonic lab requires the image to exist, otherwise it fails with bind path verification
12-
touch "${previous_lab_dir}/sonic-vs.img"
1311
done
1412

1513
make cleanup

0 commit comments

Comments
 (0)