1.delete machine's history
don't need this info.
2.add testbox
this field is used to find the corresponding host when a phssical
machine is restarted.
3.modify mq queue
testbox: vm-2p8g.wuzhende-1
before queue: wuzhende
now queue: vm-2p8g.wuzhende
Signed-off-by: Wu Zhende <wuzhende666(a)163.com>
---
src/lib/lifecycle.cr | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/lib/lifecycle.cr b/src/lib/lifecycle.cr
index 3dab6e8..1eb6264 100644
--- a/src/lib/lifecycle.cr
+++ b/src/lib/lifecycle.cr
@@ -110,7 +110,7 @@ class Lifecycle
def mq_event_loop
puts "deal job events"
- q = @mq.ch.queue("job_mq")
+ q = @mq.ch.queue("job_mq", durable: false)
q.subscribe(no_ack: false) do |msg|
event = JSON.parse(msg.body_io.to_s)
job_state = event["job_state"]?
@@ -311,6 +311,8 @@ class Lifecycle
return if Time.local < deadline
mq_queue = get_machine_reboot_queue(testbox)
+ machine.as_h.delete("history")
+ machine.as_h["testbox"] = JSON::Any.new(testbox)
@mq.pushlish_confirm(mq_queue, machine.to_json, durable: true)
machine["state"] = "rebooting_queue"
@@ -320,7 +322,7 @@ class Lifecycle
def get_machine_reboot_queue(testbox)
if testbox.includes?(".")
- testbox =~ /.*\.(.*)-\d+$/
+ testbox =~ /(.*)-\d+$/
else
testbox =~ /(.*)--.*/
end
--
2.23.0