Why not just get the whole job? (to reduce a special API) It's no much difference in performance POV. Do you have security concerns?
Thanks, Fengguang
On Thu, Feb 25, 2021 at 02:15:32PM +0800, Cao Xueliang wrote:
We can expose assist-result host/port to the SUT, then the SUT can get the job stats.
Signed-off-by: Cao Xueliang caoxl78320@163.com
container/assist-result/routes.rb | 11 +++++++++++ container/assist-result/views/get_job_stats.rb | 10 ++++++++++ 2 files changed, 21 insertions(+) create mode 100644 container/assist-result/views/get_job_stats.rb
diff --git a/container/assist-result/routes.rb b/container/assist-result/routes.rb index 077a427..02956aa 100755 --- a/container/assist-result/routes.rb +++ b/container/assist-result/routes.rb @@ -7,6 +7,7 @@ require 'json' require 'sinatra'
require_relative './views/get_job_yaml' +require_relative './views/get_job_stats' require_relative './views/check_job_credible'
configure do @@ -34,3 +35,13 @@ post '/check_job_credible' do
return [200, {'credible' => result}.to_json] end
+get '/get_job_stats/:job_id' do
- begin
- result = get_job_stats(params[:job_id])
- rescue StandardError => e
- return [400, e.backtrace.inspect]
- end
- return [200, result.to_json]
+end diff --git a/container/assist-result/views/get_job_stats.rb b/container/assist-result/views/get_job_stats.rb new file mode 100644 index 0000000..d294df3 --- /dev/null +++ b/container/assist-result/views/get_job_stats.rb @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true
+require_relative "#{ENV['CCI_SRC']}/lib/es_query"
+def get_job_stats(job_id)
- content = ESQuery.new.query_by_id(job_id)
- return content['stats']
+end
2.23.0