openebs / lvm-localpv

Dynamically provision Stateful Persistent Node-Local Volumes & Filesystems for Kubernetes that is integrated with a backend LVM2 data storage stack.
Apache License 2.0
235 stars 92 forks source link

ci/ci-test.sh leaves generated resources present in system. #249

Closed kro-cat closed 10 months ago

kro-cat commented 11 months ago

Describe the problem/challenge you have a successful or unsuccessful run of ci/ci-test.sh leaves the temporary file /tmp/disk.img, a loopback device /dev/loopN, and a volume group lvmvg present on the host. This may be an issue when running ci tests locally.

Describe the solution you'd like Add an exit handler to ci/ci-test.sh which cleans up generated resources from the system:

sudo pvcreate "$disk"
sudo vgcreate lvmvg "$disk"

# --------------------  Addition --------------------
# Clean this stuff up on termination
cleanup() {
  echo "Exiting: Cleaning up test resources"
  sudo vgremove lvmvg
  sudo pvremove "$disk"
  sudo losetup -d "${disk}"
  rm /tmp/disk.img
}
trap cleanup EXIT
# -------------------- /Addition --------------------

# install snapshot and thin volume module for lvm
sudo modprobe dm-snapshot

Environment:

kro-cat commented 11 months ago

Any tests for issue #247 will most likely involve modifying the ci-test.sh script, so I might wind up combining this with the PR for that one.

abhilashshetty04 commented 11 months ago

@kro-cat Thanks for creating issue. We look forward to your PR :)