From 3f67dda33e22c5868447ee6a2c99c127e2e19e0b Mon Sep 17 00:00:00 2001 From: Daniel Clavijo Coca Date: Fri, 26 Feb 2021 08:35:31 -0600 Subject: [PATCH] B #5103: Improve state transition flag system (#884) (cherry picked from commit 6930839e8733a93113e18152213e97378929dee3) --- src/vmm_mad/remotes/lib/lxd/container.rb | 27 +++++++++++------------- src/vmm_mad/remotes/lxd/deploy | 5 +---- src/vmm_mad/remotes/lxd/reboot | 1 + 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/vmm_mad/remotes/lib/lxd/container.rb b/src/vmm_mad/remotes/lib/lxd/container.rb index 58b5ca2904..90602dce81 100644 --- a/src/vmm_mad/remotes/lib/lxd/container.rb +++ b/src/vmm_mad/remotes/lib/lxd/container.rb @@ -129,8 +129,7 @@ class Container # Create a container without a base image def create(wait: true, timeout: '') @lxc['source'] = { 'type' => 'none' } - - transition_start # not ready to report status yet + @lxc['config']['user.one_status'] = '0' # not ready to report status yet wait?(@client.post(CONTAINERS, @lxc), wait, timeout) @@ -253,16 +252,10 @@ class Container # Extended reboot required for OpenNebula execution flow def reboot(force) - if transient? - start - - transition_end # container reached the final state of rebooting - update - else - transition_start # container will be started later - update - + if check_status == 'Running' check_stop(force) + else + start end end @@ -476,14 +469,16 @@ class Container end # Flags a container indicating current status not definitive - # Stalls monitoring status query. Requires updating the container - def transition_start + # Stalls monitoring status query. + def avoid_monitoring @lxc['config']['user.one_status'] = '0' + update end - # Removes transient state flag. Requires updating the container. - def transition_end + # Removes transient state flag. + def allow_monitoring @lxc['config'].delete('user.one_status') + update end # Helper method for querying transition phase @@ -534,6 +529,8 @@ class Container def change_state(action, options) options.update(:action => action) + avoid_monitoring + response = @client.put("#{CONTAINERS}/#{name}/state", options) status = wait?(response, options[:wait], options[:timeout]) diff --git a/src/vmm_mad/remotes/lxd/deploy b/src/vmm_mad/remotes/lxd/deploy index 3616680fa1..dd1d2bd0ae 100755 --- a/src/vmm_mad/remotes/lxd/deploy +++ b/src/vmm_mad/remotes/lxd/deploy @@ -84,9 +84,6 @@ end # Updates container configuration with the OpenNebulaVM description # ------------------------------------------------------------------------------ container.save_xml(xml) -container.transition_end unless container.wild? -container.update - container.vnc('start') - puts container.name +container.allow_monitoring diff --git a/src/vmm_mad/remotes/lxd/reboot b/src/vmm_mad/remotes/lxd/reboot index 0ccbdc53f7..be68f6cdee 100755 --- a/src/vmm_mad/remotes/lxd/reboot +++ b/src/vmm_mad/remotes/lxd/reboot @@ -49,3 +49,4 @@ force = false force = true if ARGV[-1] == '-f' container.reboot(force) +container.allow_monitoring