Change in vdsm[ovirt-3.6]: hooks: openstack hook should wait a while for nic activation
Francesco Romani has submitted this change and it was merged. Change subject: hooks: openstack hook should wait a while for nic activation .. hooks: openstack hook should wait a while for nic activation The vm will be stated in a paused state if a nic managed by an external openstack network provider is present. The openstack hook after_vm_start must then wait a given time to allow the nic to be activated before unpausing the vm. Change-Id: Ib4f455789909f090a039863fdcfeb61b9db1042f Bug-Url: https://bugzilla.redhat.com/1314371 Signed-off-by: mireckiReviewed-on: https://gerrit.ovirt.org/58917 Continuous-Integration: Jenkins CI Reviewed-by: Dan Kenigsberg Reviewed-by: Francesco Romani Reviewed-on: https://gerrit.ovirt.org/60035 --- A vdsm_hooks/openstacknet/after_vm_start.py M vdsm_hooks/openstacknet/before_device_create.py M vdsm_hooks/openstacknet/openstacknet_utils.py 3 files changed, 84 insertions(+), 0 deletions(-) Approvals: Marcin Mirecki: Verified Jenkins CI: Passed CI tests Dan Kenigsberg: Looks good to me, approved Francesco Romani: Looks good to me, approved -- To view, visit https://gerrit.ovirt.org/60035 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib4f455789909f090a039863fdcfeb61b9db1042f Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.6 Gerrit-Owner: Marcin Mirecki Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Marcin Mirecki ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[ovirt-3.6]: hooks: openstack hook should wait a while for nic activation
Francesco Romani has posted comments on this change. Change subject: hooks: openstack hook should wait a while for nic activation .. Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.ovirt.org/60035 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib4f455789909f090a039863fdcfeb61b9db1042f Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.6 Gerrit-Owner: Marcin MireckiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Marcin Mirecki Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[ovirt-3.6]: hooks: openstack hook should wait a while for nic activation
Dan Kenigsberg has posted comments on this change. Change subject: hooks: openstack hook should wait a while for nic activation .. Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.ovirt.org/60035 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib4f455789909f090a039863fdcfeb61b9db1042f Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.6 Gerrit-Owner: Marcin MireckiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Marcin Mirecki Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[ovirt-3.6]: hooks: openstack hook should wait a while for nic activation
Marcin Mirecki has posted comments on this change. Change subject: hooks: openstack hook should wait a while for nic activation .. Patch Set 1: Verified+1 -- To view, visit https://gerrit.ovirt.org/60035 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib4f455789909f090a039863fdcfeb61b9db1042f Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.6 Gerrit-Owner: Marcin MireckiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Marcin Mirecki Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[ovirt-3.6]: hooks: openstack hook should wait a while for nic activation
Francesco Romani has posted comments on this change. Change subject: hooks: openstack hook should wait a while for nic activation .. Patch Set 1: Code-Review+1 seems ok, deeper review later. -- To view, visit https://gerrit.ovirt.org/60035 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib4f455789909f090a039863fdcfeb61b9db1042f Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.6 Gerrit-Owner: Marcin MireckiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[ovirt-3.6]: hooks: openstack hook should wait a while for nic activation
Hello Dan Kenigsberg, Francesco Romani, I'd like you to do a code review. Please visit https://gerrit.ovirt.org/60035 to review the following change. Change subject: hooks: openstack hook should wait a while for nic activation .. hooks: openstack hook should wait a while for nic activation The vm will be stated in a paused state if a nic managed by an external openstack network provider is present. The openstack hook after_vm_start must then wait a given time to allow the nic to be activated before unpausing the vm. Change-Id: Ib4f455789909f090a039863fdcfeb61b9db1042f Bug-Url: https://bugzilla.redhat.com/1314371 Signed-off-by: mireckiReviewed-on: https://gerrit.ovirt.org/58917 Continuous-Integration: Jenkins CI Reviewed-by: Dan Kenigsberg Reviewed-by: Francesco Romani --- A vdsm_hooks/openstacknet/after_vm_start.py M vdsm_hooks/openstacknet/before_device_create.py M vdsm_hooks/openstacknet/openstacknet_utils.py 3 files changed, 84 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/35/60035/1 diff --git a/vdsm_hooks/openstacknet/after_vm_start.py b/vdsm_hooks/openstacknet/after_vm_start.py new file mode 100644 index 000..6f5c1e5 --- /dev/null +++ b/vdsm_hooks/openstacknet/after_vm_start.py @@ -0,0 +1,53 @@ +#!/usr/bin/python + +''' +OpenStack Network Hook (Post vm start) += +The hook unpauses a vm if it was started in the paused state. + +Syntax: +{ 'vmId': 'VM_ID', 'vnic_id': 'port_id' } +Where: +VM_ID should be replaced with the vm id.''' + +import libvirt +import os +import time +import traceback +import hooking +from openstacknet_utils import MARK_FOR_UNPAUSE_PATH +from openstacknet_utils import VM_ID_KEY +from vdsm import vdscli + + +OPENSTACK_NIC_WAIT_TIME = 15 + + +def resume_paused_vm(vm_id): +unpause_file = MARK_FOR_UNPAUSE_PATH % vm_id +if os.path.isfile(unpause_file): +vdscli.connect().cont(vm_id) +os.remove(unpause_file) + + +def main(): + +# TODO (HACK): +# This code waits for the nic to be attached to neutron for a +# certain amount of time. This is one way of going around the +# race between the code and the vm nic becoming active. It is +# a very fragile hack, as there is no guarantee the nic will +# actually be ready after this. +vm_id = os.environ[VM_ID_KEY] +launch_flags = hooking.load_vm_launch_flags_from_file(vm_id) +if launch_flags == libvirt.VIR_DOMAIN_START_PAUSED: +time.sleep(OPENSTACK_NIC_WAIT_TIME) +resume_paused_vm(vm_id) + + +if __name__ == '__main__': +try: +main() +except: +hooking.exit_hook('openstacknet hook: [unexpected error]: %s\n' % + traceback.format_exc()) diff --git a/vdsm_hooks/openstacknet/before_device_create.py b/vdsm_hooks/openstacknet/before_device_create.py index c37f81a..3cc8376 100755 --- a/vdsm_hooks/openstacknet/before_device_create.py +++ b/vdsm_hooks/openstacknet/before_device_create.py @@ -31,6 +31,7 @@ ''' from __future__ import print_function +import libvirt import os import sys import traceback @@ -39,12 +40,14 @@ import hooking from openstacknet_utils import DUMMY_BRIDGE from openstacknet_utils import INTEGRATION_BRIDGE +from openstacknet_utils import MARK_FOR_UNPAUSE_PATH from openstacknet_utils import OPENSTACK_NET_PROVIDER_TYPE from openstacknet_utils import PLUGIN_TYPE_KEY from openstacknet_utils import PROVIDER_TYPE_KEY from openstacknet_utils import PT_BRIDGE from openstacknet_utils import PT_OVS from openstacknet_utils import SECURITY_GROUPS_KEY +from openstacknet_utils import VM_ID_KEY from openstacknet_utils import VNIC_ID_KEY from openstacknet_utils import devName from openstacknet_utils import setUpSecurityGroupVnic @@ -120,6 +123,16 @@ hooking.exit_hook("Unknown plugin type: %s" % pluginType) +def mark_for_unpause(vm_id): +unpause_file = MARK_FOR_UNPAUSE_PATH % vm_id +try: +os.makedirs(os.path.dirname(unpause_file)) +except OSError: +pass +with open(unpause_file, mode='w') as f: +f.write("true") + + def main(): if PROVIDER_TYPE_KEY not in os.environ: return @@ -135,6 +148,15 @@ addOpenstackVnic(domxml, pluginType, vNicId, hasSecurityGroups) hooking.write_domxml(domxml) +vm_id = os.environ[VM_ID_KEY] +PAUSE_FLAG = libvirt.VIR_DOMAIN_START_PAUSED +flags = hooking.load_vm_launch_flags_from_file(vm_id) + +if (flags & PAUSE_FLAG) != PAUSE_FLAG: +flags |= PAUSE_FLAG +hooking.dump_vm_launch_flags_to_file(vm_id, flags) +mark_for_unpause(vm_id) + def test(ovs, withSecurityGroups): domxml = minidom.parseString(""" diff --git a/vdsm_hooks/openstacknet/openstacknet_utils.py