From ab38c10c2db726cf664500ca483ac6a7c5133a96 Mon Sep 17 00:00:00 2001 From: Satoru Takeuchi Date: Thu, 5 May 2022 13:11:21 +0000 Subject: [PATCH 1/2] test: avoid to create a corrupted GPT headers The following steps in CI scripts create corrupted GPT headers. ```console $ sudo sgdisk --zap-all --clear --mbrtogpt -g -- "$DISK" $ sudo dd if=/dev/zero of="$DISK" bs=1M count=10 ``` It results in the failure of the succeeding `sgdisk --print "$DISK". Here is an example. ```console $ sudo parted /dev/sdb mklabel msdos ... $ sudo sgdisk --zap-all --clear --mbrtogpt -g -- /dev/sdb ... $ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=10 ... $ sudo sgdisk --print /dev/sdb Caution: invalid main GPT header, but valid backup; regenerating main header from backup! Warning: Invalid CRC on main header data; loaded backup partition table. Warning! One or more CRCs don't match. You should repair the disk! Main header: ERROR Backup header: OK Main partition table: OK Backup partition table: OK Invalid partition data! $ echo $? 2 ``` We can safely use the simple `sgdisk --zap-all "$DEVICE"` here. It's not necessary to convert "mbr" to "gpt" because we'll make new GPT labels just after this command. Signed-off-by: Satoru Takeuchi --- tests/scripts/create-bluestore-partitions.sh | 2 +- tests/scripts/github-action-helper.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scripts/create-bluestore-partitions.sh b/tests/scripts/create-bluestore-partitions.sh index 0c5f0891e..e06001892 100755 --- a/tests/scripts/create-bluestore-partitions.sh +++ b/tests/scripts/create-bluestore-partitions.sh @@ -35,7 +35,7 @@ function usage { } function wipe_disk { - sudo sgdisk --zap-all --clear --mbrtogpt -g -- "$DISK" + sudo sgdisk --zap-all -- "$DISK" sudo dd if=/dev/zero of="$DISK" bs=1M count=10 sudo parted -s "$DISK" mklabel gpt sudo partprobe "$DISK" diff --git a/tests/scripts/github-action-helper.sh b/tests/scripts/github-action-helper.sh index 6582739d7..6f58dfef9 100755 --- a/tests/scripts/github-action-helper.sh +++ b/tests/scripts/github-action-helper.sh @@ -49,7 +49,7 @@ function use_local_disk() { sudo wipefs --all --force "$BLOCK_DATA_PART" else # it's the hosted runner! - sudo sgdisk --zap-all --clear --mbrtogpt -g -- "${BLOCK}" + sudo sgdisk --zap-all -- "${BLOCK}" sudo dd if=/dev/zero of="${BLOCK}" bs=1M count=10 oflag=direct,dsync sudo parted -s "${BLOCK}" mklabel gpt fi From 805163e2e2bee16da601fced6d2beacd9414ee52 Mon Sep 17 00:00:00 2001 From: Satoru Takeuchi Date: Thu, 5 May 2022 13:15:18 +0000 Subject: [PATCH 2/2] test: add canary integration tests for osd on device OSD on PVC is tested in many patterns but OSD on device is not. It's preferable to add the following patterns for OSD on device. - An OSD on a raw disk - Two OSDs on a device Signed-off-by: Satoru Takeuchi --- .github/workflows/canary-integration-test.yml | 92 +++++++++++++++++++ tests/scripts/create-bluestore-partitions.sh | 46 +++++++--- tests/scripts/github-action-helper.sh | 6 +- 3 files changed, 128 insertions(+), 16 deletions(-) diff --git a/.github/workflows/canary-integration-test.yml b/.github/workflows/canary-integration-test.yml index ccb3afe5f..c1367c3b2 100644 --- a/.github/workflows/canary-integration-test.yml +++ b/.github/workflows/canary-integration-test.yml @@ -164,6 +164,98 @@ jobs: uses: mxschmitt/action-tmate@v3 timeout-minutes: 60 + raw-disk: + runs-on: ubuntu-18.04 + if: "!contains(github.event.pull_request.labels.*.name, 'skip-ci')" + steps: + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: setup cluster resources + uses: ./.github/workflows/setup-cluster-resources + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: validate-yaml + run: tests/scripts/github-action-helper.sh validate_yaml + + - name: use local disk as OSD + run: | + tests/scripts/github-action-helper.sh use_local_disk + BLOCK=$(sudo lsblk --paths|awk '/14G/ {print $1}'| head -1) + tests/scripts/create-bluestore-partitions.sh --disk "$BLOCK" --wipe-only + + - name: deploy cluster + run: tests/scripts/github-action-helper.sh deploy_cluster + + - name: wait for prepare pod + run: tests/scripts/github-action-helper.sh wait_for_prepare_pod + + - name: wait for ceph to be ready + run: tests/scripts/github-action-helper.sh wait_for_ceph_to_be_ready osd 1 + + - name: check-ownerreferences + run: tests/scripts/github-action-helper.sh check_ownerreferences + + - name: collect common logs + if: always() + uses: ./.github/workflows/collect-logs + with: + name: canary + + - name: setup tmate session for debugging when event is PR + if: failure() && github.event_name == 'pull_request' + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 60 + + two-osds-in-device: + runs-on: ubuntu-18.04 + if: "!contains(github.event.pull_request.labels.*.name, 'skip-ci')" + steps: + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: setup cluster resources + uses: ./.github/workflows/setup-cluster-resources + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: validate-yaml + run: tests/scripts/github-action-helper.sh validate_yaml + + - name: use local disk as OSD + run: | + tests/scripts/github-action-helper.sh use_local_disk + BLOCK=$(sudo lsblk --paths|awk '/14G/ {print $1}'| head -1) + tests/scripts/create-bluestore-partitions.sh --disk "$BLOCK" --wipe-only + + - name: deploy cluster + run: tests/scripts/github-action-helper.sh deploy_cluster two_osds_in_device + + - name: wait for prepare pod + run: tests/scripts/github-action-helper.sh wait_for_prepare_pod + + - name: wait for ceph to be ready + run: tests/scripts/github-action-helper.sh wait_for_ceph_to_be_ready osd 2 + + - name: check-ownerreferences + run: tests/scripts/github-action-helper.sh check_ownerreferences + + - name: collect common logs + if: always() + uses: ./.github/workflows/collect-logs + with: + name: canary + + - name: setup tmate session for debugging when event is PR + if: failure() && github.event_name == 'pull_request' + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 60 + pvc: runs-on: ubuntu-18.04 if: "!contains(github.event.pull_request.labels.*.name, 'skip-ci')" diff --git a/tests/scripts/create-bluestore-partitions.sh b/tests/scripts/create-bluestore-partitions.sh index e06001892..b5c7adbd7 100755 --- a/tests/scripts/create-bluestore-partitions.sh +++ b/tests/scripts/create-bluestore-partitions.sh @@ -37,6 +37,12 @@ function usage { function wipe_disk { sudo sgdisk --zap-all -- "$DISK" sudo dd if=/dev/zero of="$DISK" bs=1M count=10 + if [ -n "$WIPE_ONLY" ]; then + # `parted "$DISK -s print" exits with 1 if the partition label doesn't exist. + # It's no problem in "--wipe-only" mode + sudo parted "$DISK" -s print || : + return + fi sudo parted -s "$DISK" mklabel gpt sudo partprobe "$DISK" sudo udevadm settle @@ -82,6 +88,9 @@ while [ "$1" != "" ]; do shift OSD_COUNT="$1" ;; + --wipe-only) + WIPE_ONLY=1 + ;; -h | --help) usage exit @@ -96,22 +105,29 @@ done # First wipe the disk wipe_disk -if [ -n "$BLUESTORE_TYPE" ]; then - case "$BLUESTORE_TYPE" in - block.db) - create_partition block.db - ;; - block.wal) - create_partition block.db - create_partition block.wal - ;; - *) - printf "invalid bluestore configuration %q" "$BLUESTORE_TYPE" >&2 - exit 1 - esac +if [ -n "$WIPE_ONLY" ]; then + exit +fi + +if [ -z "$WIPE_ONLY" ]; then + if [ -n "$BLUESTORE_TYPE" ]; then + case "$BLUESTORE_TYPE" in + block.db) + create_partition block.db + ;; + block.wal) + create_partition block.db + create_partition block.wal + ;; + *) + printf "invalid bluestore configuration %q" "$BLUESTORE_TYPE" >&2 + exit 1 + esac + fi + + # Create final block partitions + create_block_partition "$OSD_COUNT" fi -# Create final block partitions -create_block_partition "$OSD_COUNT" # Inform the kernel of partition table changes sudo partprobe "$DISK" diff --git a/tests/scripts/github-action-helper.sh b/tests/scripts/github-action-helper.sh index 6f58dfef9..156666e37 100755 --- a/tests/scripts/github-action-helper.sh +++ b/tests/scripts/github-action-helper.sh @@ -208,7 +208,11 @@ function replace_ceph_image() { function deploy_cluster() { cd deploy/examples deploy_manifest_with_local_build operator.yaml - sed -i "s|#deviceFilter:|deviceFilter: ${BLOCK/\/dev\/}|g" cluster-test.yaml + if [ $# == 0 ]; then + sed -i "s|#deviceFilter:|deviceFilter: ${BLOCK/\/dev\/}|g" cluster-test.yaml + elif [ "$1" = "two_osds_in_device" ] ; then + sed -i "s|#deviceFilter:|deviceFilter: ${BLOCK/\/dev\/}\n config:\n osdsPerDevice: \"2\"|g" cluster-test.yaml + fi kubectl create -f cluster-test.yaml kubectl create -f object-test.yaml kubectl create -f pool-test.yaml