Skip to content

Commit

Permalink
Remove the ID generator from AutoHCK
Browse files Browse the repository at this point in the history
AutoHCK is a CI runner, not a manager, and should not
control resources between different runs.

Add command line argument to have the ability to specify
an ID that is received from external tools.

Signed-off-by: Kostiantyn Kostiuk <[email protected]>
  • Loading branch information
kostyanf14 authored and YanVugenfirer committed Apr 15, 2024
1 parent 94426d3 commit c2d6bdd
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1,787 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ gem 'rtoolsHCK', git: 'https://github.com/HCK-CI/rtoolsHCK.git', tag: 'v0.4.0'
gem 'rubyzip'
gem 'sentry-ruby'
gem 'sorbet-runtime'
gem 'sqlite3'

group :development, :test do
gem 'sorbet', require: false
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ GEM
sorbet-static-and-runtime (>= 0.5.10187)
syntax_tree (>= 6.1.1)
thor (>= 0.19.2)
sqlite3 (1.6.6-x86_64-linux)
stringio (3.0.8)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
Expand Down Expand Up @@ -208,7 +207,6 @@ DEPENDENCIES
sentry-ruby
sorbet
sorbet-runtime
sqlite3
tapioca

RUBY VERSION
Expand Down
90 changes: 0 additions & 90 deletions lib/auxiliary/id_gen.rb

This file was deleted.

11 changes: 10 additions & 1 deletion lib/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize

# class CommonOptions
class CommonOptions
attr_accessor :debug, :config, :client_world_net
attr_accessor :debug, :config, :client_world_net, :id

def create_parser(sub_parser)
OptionParser.new do |parser|
Expand All @@ -46,9 +46,11 @@ def define_options(parser)
@debug = false
@config = nil
@client_world_net = false
@id = 2
debug_option(parser)
config_option(parser)
client_world_net_option(parser)
id_option(parser)
version_option(parser)
end

Expand All @@ -73,6 +75,13 @@ def client_world_net_option(parser)
end
end

def id_option(parser)
parser.on('--id <id>', Integer,
'Set ID for AutoHCK run') do |id|
@id = id
end
end

def version_option(parser)
parser.on('-v', '--version',
'Display version information and exit') do
Expand Down
21 changes: 1 addition & 20 deletions lib/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
require './lib/auxiliary/multi_logger'
require './lib/auxiliary/diff_checker'
require './lib/auxiliary/json_helper'
require './lib/auxiliary/id_gen'
require './lib/auxiliary/extra_software/manager'
require './lib/auxiliary/time_helper'

Expand All @@ -33,7 +32,7 @@ def initialize(scope, options)
init_multilog(options.common.debug)
init_class_variables
init_workspace
@id = assign_id
@id = options.common.id
scope << self
end

Expand Down Expand Up @@ -119,23 +118,6 @@ def init_class_variables
@run_terminated = false
end

def assign_id
@id_gen = Idgen.new(@scope, @config['id_range'], @config['time_out'])
id = @id_gen.allocate
while id.negative?
@logger.info('No available ID')
sleep 20
id = @id_gen.allocate
end
@logger.info("Assigned ID: #{id}")
id.to_s
end

def release_id
@logger.info("Releasing ID: #{@id}")
@id_gen.release(@id)
end

def configure_result_uploader
@logger.info('Initializing result uploaders')
@result_uploader = ResultUploader.new(@scope, self)
Expand Down Expand Up @@ -216,7 +198,6 @@ def handle_error
def close
@logger.debug('Closing AutoHCK project')
@result_uploader&.upload_file(@logfile_path, 'AutoHCK.log')
release_id
end
end
end
Loading

0 comments on commit c2d6bdd

Please sign in to comment.