From 7135e68d42f2ebb9223a800294a9021d74e298dc Mon Sep 17 00:00:00 2001 From: Alexandre MERLIN <alexandre.merlin@inria.fr> Date: Mon, 2 May 2022 15:49:04 +0200 Subject: [PATCH] API: do not consume log/debug when making a get on /deployment/[ID]/{logs,debugs} cf 13867. --- lib/kadeploy3/server/debug.rb | 21 +++++++++++++++++++++ lib/kadeploy3/server/kaworkflow.rb | 9 ++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/kadeploy3/server/debug.rb b/lib/kadeploy3/server/debug.rb index a2995689..4761b2e6 100644 --- a/lib/kadeploy3/server/debug.rb +++ b/lib/kadeploy3/server/debug.rb @@ -95,6 +95,12 @@ module Debug end end + def read() + @lock.synchronize do + @output + end + end + def pop() @lock.synchronize do ret = @output @@ -182,6 +188,21 @@ module Debug end end + def read(node = nil) + @lock.synchronize do + if node + @debug[node] + else + ret = '' + @debug.each_key do |n| + ret << @debug[n] if @debug[n] + end + (ret.empty? ? nil : ret) + end + end + end + + def empty?() ret = true @lock.synchronize do diff --git a/lib/kadeploy3/server/kaworkflow.rb b/lib/kadeploy3/server/kaworkflow.rb index b544676b..ca8a683d 100644 --- a/lib/kadeploy3/server/kaworkflow.rb +++ b/lib/kadeploy3/server/kaworkflow.rb @@ -691,13 +691,13 @@ module Kaworkflow error_not_found! if info[:workflows] and cluster and !info[:workflows][cluster] if info[:workflows] and info[:workflows][cluster] - info[:workflows][cluster].output.pop unless info[:workflows][cluster].done? + info[:workflows][cluster].output.read unless info[:workflows][cluster].done? else log = '' - log << info[:output].pop + log << info[:output].read if info[:workflows] info[:workflows].each_value do |workflow| - log << workflow.output.pop unless workflow.done? + log << workflow.output.read unless workflow.done? end end log @@ -710,7 +710,7 @@ module Kaworkflow break if info[:error] error_not_found! if (node and !info[:nodelist].include?(node)) or !info[:debugger] - info[:debugger].pop(node) + info[:debugger].read(node) end end @@ -774,4 +774,3 @@ module Kaworkflow end end - -- GitLab