Compare commits

...

6 Commits

Author SHA1 Message Date
7223073afc Don't show stderr here 2023-11-16 18:30:32 -05:00
c1c22c81e7 Ensure script cleanup is done in chroot 2023-11-16 18:27:23 -05:00
712a50ca27 Avoid use of fail here
It causes a reraise with a bunch of extra entries that we don't need.
2023-11-16 18:22:59 -05:00
815041ff20 Fix bugs when main installs fail 2023-11-16 18:20:26 -05:00
823ce8cbf2 Remove duplicate cleanups 2023-11-16 18:19:05 -05:00
fca02238d7 Adjust starting text 2023-11-16 18:06:31 -05:00
4 changed files with 17 additions and 14 deletions

View File

@ -495,9 +495,11 @@ class VMBuilderScript(VMBuilder):
self.log_info(
f"Installing system with debootstrap: debootstrap --include={','.join(deb_packages)} {deb_release} {temp_dir} {deb_mirror}"
)
os.system(
ret = os.system(
f"debootstrap --include={','.join(deb_packages)} {deb_release} {temp_dir} {deb_mirror}"
)
if ret > 0:
self.fail("Failed to run debootstrap")
# Bind mount the devfs so we can grub-install later
os.system("mount --bind /dev {}/dev".format(temp_dir))
@ -733,6 +735,7 @@ GRUB_DISABLE_LINUX_UUID=false
dst_volume = f"{volume['pool']}/{dst_volume_name}"
mapped_dst_volume = f"/dev/rbd/{dst_volume}"
mount_path = f"{temp_dir}/{volume['mountpoint']}"
self.log_info(f"Unmounting {dst_volume} from {mount_path}")
if (
volume.get("source_volume") is None

View File

@ -521,9 +521,11 @@ class VMBuilderScript(VMBuilder):
self.log_info(
f"Installing system with rinse: rinse --arch {rinse_architecture} --directory {temporary_directory} --distribution {rinse_release} --cache-dir {rinse_cache} --add-pkg-list /tmp/addpkg --verbose {mirror_arg}"
)
os.system(
ret = os.system(
f"rinse --arch {rinse_architecture} --directory {temporary_directory} --distribution {rinse_release} --cache-dir {rinse_cache} --add-pkg-list /tmp/addpkg --verbose {mirror_arg}"
)
if ret > 0:
self.fail("Failed to run rinse")
# Bind mount the devfs, sysfs, and procfs so we can grub-install later
os.system("mount --bind /dev {}/dev".format(temporary_directory))

View File

@ -100,7 +100,7 @@ class VMBuilder(object):
log_err(None, msg)
def fail(self, msg, exception=ProvisioningError):
fail(None, msg, exception=exception)
raise exception(msg)
#
# Primary class functions; implemented by the individual scripts
@ -223,7 +223,7 @@ def create_vm(
total_stages = 10
start(
celery,
f"Starting provisioning of VM '{vm_name}' with profile '{vm_profile}'",
f"Provisioning new VM '{vm_name}' with profile '{vm_profile}'",
current=current_stage,
total=total_stages,
)
@ -681,9 +681,15 @@ def create_vm(
def fail_clean(celery, msg, exception=ProvisioningError):
try:
vm_builder.cleanup()
with chroot(temp_dir):
vm_builder.cleanup()
except Exception:
# We're already failing, do the best we can
pass
try:
general_cleanup()
except Exception:
# We're already failing, do the best we can
pass
fail(celery, msg, exception=exception)
@ -698,7 +704,6 @@ def create_vm(
with chroot(temp_dir):
vm_builder.setup()
except Exception as e:
general_cleanup()
fail_clean(
celery,
f"Error in script setup() step: {e}",
@ -720,7 +725,6 @@ def create_vm(
with chroot(temp_dir):
vm_schema = vm_builder.create()
except Exception as e:
general_cleanup()
fail_clean(
celery,
f"Error in script create() step: {e}",
@ -766,9 +770,6 @@ def create_vm(
with chroot(temp_dir):
vm_builder.prepare()
except Exception as e:
with chroot(temp_dir):
vm_builder.cleanup()
general_cleanup()
fail_clean(
celery,
f"Error in script prepare() step: {e}",
@ -789,9 +790,6 @@ def create_vm(
with chroot(temp_dir):
vm_builder.install()
except Exception as e:
with chroot(temp_dir):
vm_builder.cleanup()
general_cleanup()
fail_clean(
celery,
f"Error in script install() step: {e}",

View File

@ -62,7 +62,7 @@ for HOST in ${HOSTS[@]}; do
ssh $HOST $SUDO systemctl restart pvcnoded &>/dev/null
echo " done."
echo -n "Waiting for node daemon to be running..."
while [[ $( ssh $HOST "pvc -q node list -f json ${HOST%%.*} | jq -r '.[].daemon_state'" ) != "run" ]]; do
while [[ $( ssh $HOST "pvc -q node list -f json ${HOST%%.*} | jq -r '.[].daemon_state'" 2>/dev/null ) != "run" ]]; do
sleep 5
echo -n "."
done