Skip to content

Instantly share code, notes, and snippets.

@ShyamsundarR
Created September 22, 2021 12:44
Show Gist options
  • Save ShyamsundarR/13e50c655ab8b9aabf042d05ebce5034 to your computer and use it in GitHub Desktop.
Save ShyamsundarR/13e50c655ab8b9aabf042d05ebce5034 to your computer and use it in GitHub Desktop.
Script that demonstrates Ceph RBD image promotion/demotion across clusters, and results in an image leak
# This was tested using 2 ceph clusters setup with Rook
# Ceph version reported was: 15.2.13 (c44bc49e7a57a87d84dfff2a077a2058aa2172e2) octopus (stable)
# There were 2 k8s clusters in use named "east" and "west"
# tbox.sh is a script to run commands within Rook toolbox, IOW a shell to execute commands on the ceph clusters
# tbox.sh looks like so (for reference)
# Begin (commented) tbox.sh
##! /bin/bash
#scriptdir="$(dirname "$(realpath "$0")")"
#ctx=${1}
#shift 1
#kubectl --context=$ctx -n rook-ceph exec -it $(kubectl get pods --context=$ctx -n rook-ceph --selector=app=rook-ceph-tools -o jsonpath='{.items[0].metadata.name}') -- $@
# End tbox.sh
# Begin main testing script!
#!/bin/bash
echo "=== Creating image EAST ==="
./tbox.sh east rbd create replicapool/test-1 --size 1G
echo
echo "=== Enabling mirror EAST ==="
./tbox.sh east rbd mirror image enable replicapool/test-1 snapshot
echo
echo "=== Listing snapshot schedule EAST ==="
./tbox.sh east rbd mirror snapshot schedule list -p replicapool
echo
echo "=== Mirror image status EAST ==="
./tbox.sh east rbd mirror image status replicapool/test-1
echo
echo "=== Mirror image status WEST ==="
./tbox.sh west rbd mirror image status replicapool/test-1
echo
echo "=== Perform IO on EAST ==="
./tbox.sh east rbd bench --io-type write --io-size 4K --io-threads 2 --io-total 15M --io-pattern seq replicapool/test-1
echo
echo "=== Sleeping for 150 seconds for snap schedule to catch up ==="
sleep 150
echo
echo "=== Force promote image on WEST ==="
./tbox.sh west rbd mirror image promote replicapool/test-1 --force
echo
echo "=== Perform IO on WEST ==="
./tbox.sh west rbd bench --io-type write --io-size 4K --io-threads 2 --io-total 15M --io-pattern seq replicapool/test-1
echo
# EAST
echo "=== Perform IO on EAST ==="
./tbox.sh east rbd bench --io-type write --io-size 4K --io-threads 2 --io-total 15M --io-pattern seq replicapool/test-1
echo
echo "=== Sleeping for 150 seconds for snap schedule to catch up ==="
sleep 150
echo
echo "=== Mirror image status EAST ==="
./tbox.sh east rbd mirror image status replicapool/test-1
echo
echo "=== Mirror image status WEST ==="
./tbox.sh west rbd mirror image status replicapool/test-1
echo
echo "=== Demoting EAST ==="
./tbox.sh east rbd mirror image demote replicapool/test-1
echo
echo "=== Sleeping for 150 seconds for snap schedule to catch up ==="
sleep 150
echo
echo "=== Mirror image status EAST ==="
./tbox.sh east rbd mirror image status replicapool/test-1
echo
echo "=== Mirror image status WEST ==="
./tbox.sh west rbd mirror image status replicapool/test-1
echo
echo "=== Resync EAST ==="
./tbox.sh east rbd mirror image resync replicapool/test-1
echo
echo "=== Sleeping for 150 seconds for resync catch up ==="
sleep 150
echo
echo "=== Mirror image status EAST ==="
./tbox.sh east rbd mirror image status replicapool/test-1
echo
echo "=== Mirror image status WEST ==="
./tbox.sh west rbd mirror image status replicapool/test-1
echo
# WEST
echo "=== Perform IO on WEST ==="
./tbox.sh west rbd bench --io-type write --io-size 4K --io-threads 2 --io-total 15M --io-pattern seq replicapool/test-1
echo
echo "=== Sleeping for 150 seconds for snap schedule to catch up ==="
sleep 150
echo
echo "=== Mirror image status EAST ==="
./tbox.sh east rbd mirror image status replicapool/test-1
echo
echo "=== Mirror image status WEST ==="
./tbox.sh west rbd mirror image status replicapool/test-1
echo
echo "=== Demote on WEST ==="
./tbox.sh west rbd mirror image demote replicapool/test-1
echo
# EAST
echo "=== Sleeping for 150 seconds for snap schedule to catch up ==="
sleep 150
echo
echo "=== Mirror image status EAST ==="
./tbox.sh east rbd mirror image status replicapool/test-1
echo
echo "=== Mirror image status WEST ==="
./tbox.sh west rbd mirror image status replicapool/test-1
echo
echo "=== Promote on EAST ==="
./tbox.sh east rbd mirror image promote replicapool/test-1
echo
echo "=== Sleeping for 150 seconds for snap schedule to catch up ==="
sleep 150
echo
echo "=== Mirror image status EAST ==="
./tbox.sh east rbd mirror image status replicapool/test-1
echo
echo "=== Mirror image status WEST ==="
./tbox.sh west rbd mirror image status replicapool/test-1
echo
echo "=== Perform IO EAST ==="
./tbox.sh east rbd bench --io-type write --io-size 4K --io-threads 2 --io-total 15M --io-pattern seq replicapool/test-1
echo
echo "=== Sleeping for 150 seconds for snap schedule to catch up ==="
sleep 150
echo
echo "=== Mirror image disable EAST ==="
./tbox.sh east rbd mirror image disable replicapool/test-1
echo
echo "=== Sleeping for 150 seconds for snap schedule to catch up ==="
sleep 150
echo
echo "=== Image delete EAST ==="
./tbox.sh east rbd rm replicapool/test-1
echo
echo "=== Ls pool EAST ==="
./tbox.sh east rbd ls replicapool
echo
# WEST
echo "=== Ls pool WEST ==="
./tbox.sh west rbd ls replicapool
echo
echo "=== Mirror image status WEST ==="
./tbox.sh west rbd mirror image status replicapool/test-1
echo
echo "=== Sleeping for 150 seconds for snap schedule to catch up ==="
sleep 150
echo
echo "=== Ls pool WEST ==="
./tbox.sh west rbd ls replicapool
echo
echo "=== Mirror image status WEST ==="
./tbox.sh west rbd mirror image status replicapool/test-1
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment