Usage: delete_task task_id[|task_ids file]
case A (delete task_ids) - helper/redis_op_gc/consistency.rb -o : output manually delete task to man_del.id, and live too long task to too_long.id - then use delete_task man_del.id too_long.id : delete all this task
case B (delete a signle task) - helper/1_showjob.sh task_id : show the job content in es. - delete_task task_id : delete this task
Signed-off-by: Tong Qunfeng taxcom@tom.com --- user-client/helper/redis_op_gc/delete_task.rb | 36 ++++++++++++++++ .../helper/redis_op_gc/force_delete.rb | 41 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100755 user-client/helper/redis_op_gc/delete_task.rb create mode 100644 user-client/helper/redis_op_gc/force_delete.rb
diff --git a/user-client/helper/redis_op_gc/delete_task.rb b/user-client/helper/redis_op_gc/delete_task.rb new file mode 100755 index 0000000..4a67a2b --- /dev/null +++ b/user-client/helper/redis_op_gc/delete_task.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby + +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require_relative './force_delete' + +if ARGV.size < 1 + puts "Usage: #{__FILE__} task_id[|task_ids]" + puts " delete special task with [task_id]" + puts " or delete special task form a [task_ids] file" + exit +end + +ARGV.each do |id| + flag = FileTest::exists?(id) + if flag == true + task_ids = IO.readlines(id) + else + task_ids = [id] + end + + i = 0 + task_num = task_ids.size + while i < task_num + task_id = task_ids[i] + fd = ForceDelete.new(task_id) + fd.run + + i += 1 + set_progress(i, task_num) + end + + puts "" +end diff --git a/user-client/helper/redis_op_gc/force_delete.rb b/user-client/helper/redis_op_gc/force_delete.rb new file mode 100644 index 0000000..d8e973a --- /dev/null +++ b/user-client/helper/redis_op_gc/force_delete.rb @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true + +require 'json' +require_relative './basic_env' + +# force delete for job (with job_id) +# - taskqueue hash key: "queues/sched/*/reday?in_process?idle?uuid..." +# - taskqueue hash key: "queues/id2content" +# - scheduler hash key: "sched/id2job" +class ForceDelete + def initialize(id) + @task_id = id + end + + def run + fd4jobqueue + gc4taskqueue + gc4scheduler + end + + def fd4jobqueue + task_content = get_taskqueue_content4id(nil, @task_id) + if task_content + queue_name = task_content["queue"] + cmd = "#{CMD_BASE} queues/#{queue_name} , zrem #{@task_id}" + `#{cmd}`.chomp + end + end + + def gc4taskqueue + cmd = "#{CMD_BASE} queues/id2content , hdel #{@task_id}" + `#{cmd}`.chomp + end + + def gc4scheduler + cmd = "#{CMD_BASE} sched/id2job , hdel #{@task_id}" + `#{cmd}`.chomp + end +end
On Mon, Sep 28, 2020 at 04:34:24PM +0800, Tong Qunfeng wrote:
Usage: delete_task task_id[|task_ids file]
case A (delete task_ids)
- helper/redis_op_gc/consistency.rb -o : output manually delete task to man_del.id, and live too long task to too_long.id
- then use delete_task man_del.id too_long.id : delete all this task
case B (delete a signle task)
- helper/1_showjob.sh task_id : show the job content in es.
- delete_task task_id : delete this task
Signed-off-by: Tong Qunfeng taxcom@tom.com
user-client/helper/redis_op_gc/delete_task.rb | 36 ++++++++++++++++ .../helper/redis_op_gc/force_delete.rb | 41 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100755 user-client/helper/redis_op_gc/delete_task.rb create mode 100644 user-client/helper/redis_op_gc/force_delete.rb
diff --git a/user-client/helper/redis_op_gc/delete_task.rb b/user-client/helper/redis_op_gc/delete_task.rb new file mode 100755 index 0000000..4a67a2b --- /dev/null +++ b/user-client/helper/redis_op_gc/delete_task.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby
+# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true
+require_relative './force_delete'
+if ARGV.size < 1
you can use: if ARGV[0] or if ARGV.none? or if ARGV.size.positive instead
Thanks Luan Shengde
- puts "Usage: #{__FILE__} task_id[|task_ids]"
- puts " delete special task with [task_id]"
- puts " or delete special task form a [task_ids] file"
- exit
+end
+ARGV.each do |id|
- flag = FileTest::exists?(id)
- if flag == true
- task_ids = IO.readlines(id)
- else
- task_ids = [id]
- end
- i = 0
- task_num = task_ids.size
- while i < task_num
- task_id = task_ids[i]
- fd = ForceDelete.new(task_id)
- fd.run
- i += 1
- set_progress(i, task_num)
- end
- puts ""
+end diff --git a/user-client/helper/redis_op_gc/force_delete.rb b/user-client/helper/redis_op_gc/force_delete.rb new file mode 100644 index 0000000..d8e973a --- /dev/null +++ b/user-client/helper/redis_op_gc/force_delete.rb @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true
+require 'json' +require_relative './basic_env'
+# force delete for job (with job_id) +# - taskqueue hash key: "queues/sched/*/reday?in_process?idle?uuid..." +# - taskqueue hash key: "queues/id2content" +# - scheduler hash key: "sched/id2job" +class ForceDelete
- def initialize(id)
- @task_id = id
- end
- def run
fd4jobqueue
gc4taskqueue
gc4scheduler
- end
- def fd4jobqueue
- task_content = get_taskqueue_content4id(nil, @task_id)
- if task_content
queue_name = task_content["queue"]
cmd = "#{CMD_BASE} queues/#{queue_name} , zrem #{@task_id}"
`#{cmd}`.chomp
- end
- end
- def gc4taskqueue
- cmd = "#{CMD_BASE} queues/id2content , hdel #{@task_id}"
- `#{cmd}`.chomp
- end
- def gc4scheduler
- cmd = "#{CMD_BASE} sched/id2job , hdel #{@task_id}"
- `#{cmd}`.chomp
- end
+end
2.23.0
On Mon, Sep 28, 2020 at 07:10:34PM +0800, Luan Shengde wrote:
On Mon, Sep 28, 2020 at 04:34:24PM +0800, Tong Qunfeng wrote:
Usage: delete_task task_id[|task_ids file]
+if ARGV.size < 1
you can use: if ARGV[0] or if ARGV.none? or if ARGV.size.positive instead
Thanks Luan Shengde
got. use "ARGV.empty?" and fix other rubocop warning.