[why] 1. load job from result's job yaml has key "my_email", like my_email: compass-ci-robot@qq.com my_name: compass-ci-robot lab: z9 2. load job from result's job yaml has key "SCHED_HOST" which from /etc/compass-ci/defaults/*.yaml, like SCHED_HOST: 172.168.131.2 SCHED_PORT: 3000
each of these fields needs to be reset when submit job.yaml for reprodution task. however, these fields already exist in yaml file, can not to be reload, so delete these fields when submit reproduction job.
Signed-off-by: Li Ping 1477412247@qq.com --- lib/job.rb | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/lib/job.rb b/lib/job.rb index 640b25a5f..867c3d193 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -258,6 +258,13 @@ class Job @overrides.merge!(hash['override']){ |_key, a, _b| a} hash.delete('override') end + if hash.has_key?('id') + hash.delete_if { |key, _| key == "SCHED_HOST" } + hash.delete_if { |key, _| key == "SCHED_PORT" } + hash.delete_if { |key, _| key == "my_name" } + hash.delete_if { |key, _| key == "my_email" } + hash.delete_if { |key, _| key == "lab" } + end
revise_hash(hash, load_include_yamls(@default_yamls), false) unless @default_yamls.empty? revise_hash(hash, load_include_yamls(@override_yamls), true) unless @override_yamls.empty?
hash.delete('override') end
if hash.has_key?('id')
hash.delete_if { |key, _| key == "SCHED_HOST" }
hash.delete_if { |key, _| key == "SCHED_PORT" }
hash.delete_if { |key, _| key == "my_name" }
hash.delete_if { |key, _| key == "my_email" }
hash.delete_if { |key, _| key == "lab" }
for each line it may traverse the hash. you can just delete the key no matter the hash has the key or not, hash.delete 'SCHED_HOST' ... or you can do like this: if hash.has_key?('id') d_keys = ["SCHED_HOST", "SCHED_PORT", "my_name", "my_email", "lab"] hash.delete_if { |k| d_keys.include? k } end
Thanks, Luan Shengde
end revise_hash(hash, load_include_yamls(@default_yamls), false) unless @default_yamls.empty? revise_hash(hash, load_include_yamls(@override_yamls), true) unless @override_yamls.empty?
-- 2.23.0
On Mon, Feb 01, 2021 at 09:16:16AM +0800, Luan Shengde wrote:
hash.delete('override') end
if hash.has_key?('id')
hash.delete_if { |key, _| key == "SCHED_HOST" }
hash.delete_if { |key, _| key == "SCHED_PORT" }
hash.delete_if { |key, _| key == "my_name" }
hash.delete_if { |key, _| key == "my_email" }
hash.delete_if { |key, _| key == "lab" }
for each line it may traverse the hash. you can just delete the key no matter the hash has the key or not, hash.delete 'SCHED_HOST' ... or you can do like this: if hash.has_key?('id') d_keys = ["SCHED_HOST", "SCHED_PORT", "my_name", "my_email", "lab"] hash.delete_if { |k| d_keys.include? k } end
ok, i got it.
Thanks, Ping
Thanks, Luan Shengde
end revise_hash(hash, load_include_yamls(@default_yamls), false) unless @default_yamls.empty? revise_hash(hash, load_include_yamls(@override_yamls), true) unless @override_yamls.empty?
-- 2.23.0
On Sat, Jan 30, 2021 at 04:34:11PM +0800, Li Ping wrote:
[why]
- load job from result's job yaml has key "my_email", like
my_email: compass-ci-robot@qq.com my_name: compass-ci-robot lab: z9 2. load job from result's job yaml has key "SCHED_HOST" which from /etc/compass-ci/defaults/*.yaml, like SCHED_HOST: 172.168.131.2 SCHED_PORT: 3000
each of these fields needs to be reset when submit job.yaml for
Why? Please list the problem situations. That info is the most valuable part.
reprodution task. however, these fields already exist in yaml file, can not to be reload, so delete these fields when submit reproduction job.
Signed-off-by: Li Ping 1477412247@qq.com
lib/job.rb | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/lib/job.rb b/lib/job.rb index 640b25a5f..867c3d193 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -258,6 +258,13 @@ class Job @overrides.merge!(hash['override']){ |_key, a, _b| a} hash.delete('override') end
Should comment the situation here. The code is detecting that situation by detecting 'id'. Such indirections should normally be well commented.
if hash.has_key?('id')
hash.delete_if { |key, _| key == "SCHED_HOST" }
Directly delete?
hash.delete 'SCHED_HOST'
hash.delete_if { |key, _| key == "SCHED_PORT" }
hash.delete_if { |key, _| key == "my_name" }
hash.delete_if { |key, _| key == "my_email" }
hash.delete_if { |key, _| key == "lab" }
end revise_hash(hash, load_include_yamls(@default_yamls), false) unless @default_yamls.empty? revise_hash(hash, load_include_yamls(@override_yamls), true) unless @override_yamls.empty?
-- 2.23.0
On Mon, Feb 01, 2021 at 11:26:44AM +0800, Wu Fengguang wrote:
On Sat, Jan 30, 2021 at 04:34:11PM +0800, Li Ping wrote:
[why]
- load job from result's job yaml has key "my_email", like
my_email: compass-ci-robot@qq.com my_name: compass-ci-robot lab: z9 2. load job from result's job yaml has key "SCHED_HOST" which from /etc/compass-ci/defaults/*.yaml, like SCHED_HOST: 172.168.131.2 SCHED_PORT: 3000
each of these fields needs to be reset when submit job.yaml for
Why? Please list the problem situations. That info is the most valuable part.
server side ==> auto_submit: my_email: compass-ci-rebot@qq.com my_token: xxxx
reproduction task: my_email: user.email my_token: user.token
==> check the field my_token fail
need to reload account_info
and server side use SCHED_HOST: 172.168.131.2 client side can not use 172.168.131.2
need reload SCHED_HOST from $LKP_SRC/include/lab/z9
reprodution task. however, these fields already exist in yaml file, can not to be reload, so delete these fields when submit reproduction job.
Signed-off-by: Li Ping 1477412247@qq.com
lib/job.rb | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/lib/job.rb b/lib/job.rb index 640b25a5f..867c3d193 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -258,6 +258,13 @@ class Job @overrides.merge!(hash['override']){ |_key, a, _b| a} hash.delete('override') end
Should comment the situation here. The code is detecting that situation by detecting 'id'. Such indirections should normally be well commented.
if hash.has_key?('id')
hash.delete_if { |key, _| key == "SCHED_HOST" }
Directly delete?
hash.delete 'SCHED_HOST'
hash.delete_if { |key, _| key == "SCHED_PORT" }
hash.delete_if { |key, _| key == "my_name" }
hash.delete_if { |key, _| key == "my_email" }
hash.delete_if { |key, _| key == "lab" }
end revise_hash(hash, load_include_yamls(@default_yamls), false) unless @default_yamls.empty? revise_hash(hash, load_include_yamls(@override_yamls), true) unless @override_yamls.empty?
-- 2.23.0