From 953bbba18301739fe2a6dd5bb5bc104ef41bec88 Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Wed, 7 Sep 2022 11:28:05 -0400 Subject: [PATCH] kojivmd: narrow error handling for missing VMs lookupByName() could raise libvirt.libvirtError for many different reasons (libvirt connection problems, etc). If this kojivmd host does not have this VM available (VIR_ERR_NO_DOMAIN), and we should log the "VM not available" message and skip taking the task. If the error is something else, this is unexpected, and we should raise it in the logs so the administrator can see it at non-debug log levels. --- vm/kojivmd | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/vm/kojivmd b/vm/kojivmd index b791a230..21bf69ad 100755 --- a/vm/kojivmd +++ b/vm/kojivmd @@ -1033,11 +1033,14 @@ class VMTaskManager(TaskManager): vm_name = task_info['request'][0] try: self.libvirt_conn.lookupByName(vm_name) - except libvirt.libvirtError: - # if this builder does not have the requested VM, - # we can't handle the task - self.logger.debug('VM %s not available, ignoring task %i', vm_name, task['id']) - return False + except libvirt.libvirtError as e: + if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN: + # if this builder does not have the requested VM, + # we can't handle the task + self.logger.debug('VM %s not available, ignoring task %i', vm_name, task['id']) + return False + else: + raise return super(VMTaskManager, self).takeTask(task) def cleanupVM(self, vm_name):