From a94a88d646c277fa0d14491347e9aa1619b7908d Mon Sep 17 00:00:00 2001 From: utkarsh bhatt Date: Mon, 18 Nov 2024 17:16:46 +0530 Subject: [PATCH] Moved docker registry to inside LXD vm --- .github/workflows/build_and_test.yaml | 31 +++++++++++---------------- test/scripts/cephadm_helper.sh | 28 +++++++++++++++++++++--- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index 678c7fc0..9470fe96 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -77,19 +77,6 @@ jobs: - name: install dependencies run: ./scripts/deploy-helper.sh install_custom_runner_dependencies - - name: Load image to registry - run: | - ls - rock_file=$(ls *.rock | head -1) - docker run -d -p 5000:5000 --restart=always --name registry registry:2 - sleep 10 - skopeo --insecure-policy copy oci-archive:$rock_file docker-daemon:canonical/ceph:latest - docker image ls -a - docker image tag canonical/ceph:latest localhost:5000/canonical/ceph:latest - sleep 10 - docker push localhost:5000/canonical/ceph - echo $'[registries.insecure]\nregistries = ["localhost:5000"]' | sudo tee -a /etc/containers/registries.conf - - name: Setup LXD uses: canonical/setup-lxd@v0.1.1 with: @@ -115,15 +102,21 @@ jobs: lxc storage volume attach default osd_two cephadm lxc storage volume attach default osd_three cephadm - - name: Copy helper scripts to LXD vm + - name: Copy necessary assets to LXD vm run: | - lxc file push ./scripts/*.sh cephadm/root/ -r + rock_file=$(ls *.rock | head -1) + lxc file push ./test/scripts/cephadm_helper.sh cephadm/root/ -r + lxc file push $rock_file cephadm/root/ + + - name: Prepare the docker registry + run: | + lxc exec cephadm -- sh -c "~/cephadm_helper.sh install_dependencies" + lxc exec cephadm -- sh -c "~/cephadm_helper.sh prep_registry - name: Install cephadm with local image run: | - reg_addr=$(lxc exec cephadm -- sh -c "~/cephadm_helper.sh get_ip) - lxc exec cephadm -- sh -c "~/cephadm_helper.sh deploy_cephadm $reg_addr:5000/canonical/ceph:latest" - sleep 2m + lxc exec cephadm -- sh -c "~/cephadm_helper.sh deploy_cephadm" + sleep 3m - name: Check health run: | @@ -137,7 +130,7 @@ jobs: sleep 2m lxc exec cephadm --sh -c "ceph -s" - - name: check healthy + - name: check health run: lxc exec cephadm -- sh -c "~/cephadm_helper.sh poll_obj_count osd 3" RookTest: diff --git a/test/scripts/cephadm_helper.sh b/test/scripts/cephadm_helper.sh index bb09cec0..6defc667 100755 --- a/test/scripts/cephadm_helper.sh +++ b/test/scripts/cephadm_helper.sh @@ -14,6 +14,27 @@ function prep_docker() { docker push localhost:5000/canonical/ceph:latest } +function install_dependencies() { + sudo apt-get -y update + sudo apt-get -y install skopeo + sudo python -m pip install --upgrade pip + sudo snap install docker + sleep 10 +} + +function prep_registry() { + ls + rock_file=$(ls *.rock | head -1) + docker run -d -p 5000:5000 --restart=always --name registry registry:2 + sleep 10 + skopeo --insecure-policy copy oci-archive:$rock_file docker-daemon:canonical/ceph:latest + docker image ls -a + docker image tag canonical/ceph:latest localhost:5000/canonical/ceph:latest + sleep 10 + docker push localhost:5000/canonical/ceph + echo $'[registries.insecure]\nregistries = ["localhost:5000"]' | sudo tee -a /etc/containers/registries.conf +} + function use_local_disk() { sudo lsblk -f datadisk=$(sudo lsblk --paths | awk '/14G/ || /64G/ {print $1}' | head -1) @@ -60,9 +81,10 @@ function get_ip() { } function deploy_cephadm() { - local image=${1:?missing} + local ip=$( get_ip ) + install_apt - bootstrap $image $( get_ip ) + bootstrap $ip:5000/canonical/ceph:latest $ip test_num_objs mon 1 } @@ -112,4 +134,4 @@ function poll_obj_count() { FUNCTION="$1" shift -$FUNCTION "$@" \ No newline at end of file +$FUNCTION "$@"