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 | 31 ++++++++++++++ .../helper/redis_op_gc/force_delete.rb | 41 +++++++++++++++++++ 2 files changed, 72 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..643d2b3 --- /dev/null +++ b/user-client/helper/redis_op_gc/delete_task.rb @@ -0,0 +1,31 @@ +#!/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.empty? + 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 + +task_ids = [] +ARGV.each do |id| + task_ids += IO.readlines(id) if File.exist?(id) + task_ids << [id] unless File.exist?(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 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..f5e52d2 --- /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.chomp + end + + def run + fd4jobqueue + gc4taskqueue + gc4scheduler + end + + def fd4jobqueue + task_content = get_taskqueue_content4id(nil, @task_id) + return unless task_content + + queue_name = task_content['queue'] + cmd = "#{CMD_BASE} queues/#{queue_name} , zrem #{@task_id}" + `#{cmd}`.chomp + 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