Class: Gitlab::Seeders::Ci::Runner::RunnerFleetPipelineSeeder
- Inherits:
-
Object
- Object
- Gitlab::Seeders::Ci::Runner::RunnerFleetPipelineSeeder
- Defined in:
- lib/gitlab/seeders/ci/runner/runner_fleet_pipeline_seeder.rb
Constant Summary collapse
- DEFAULT_JOB_COUNT =
400
- MAX_QUEUE_TIME_IN_SECONDS =
5.minutes.to_i
- PIPELINE_CREATION_RANGE_MIN_IN_SECONDS =
2.hours.to_i
- PIPELINE_CREATION_RANGE_MAX_IN_SECONDS =
30.days.to_i
- PIPELINE_START_RANGE_MAX_IN_SECONDS =
5.minutes.to_i
- PIPELINE_FINISH_RANGE_MAX_IN_SECONDS =
1.hour.to_i
- PROJECT_JOB_DISTRIBUTION =
[ { allocation: 70, job_count_default: 10 }, { allocation: 15, job_count_default: 10 }, { allocation: 15, job_count_default: 100 } # remaining jobs on 4th project ].freeze
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(logger = Gitlab::AppLogger, projects_to_runners:, job_count:) ⇒ RunnerFleetPipelineSeeder
constructor
Initializes the class.
- #seed ⇒ Object
Constructor Details
#initialize(logger = Gitlab::AppLogger, projects_to_runners:, job_count:) ⇒ RunnerFleetPipelineSeeder
Initializes the class
30 31 32 33 34 35 36 |
# File 'lib/gitlab/seeders/ci/runner/runner_fleet_pipeline_seeder.rb', line 30 def initialize(logger = Gitlab::AppLogger, projects_to_runners:, job_count:) @logger = logger @projects_to_runners = projects_to_runners.map do |v| { project_id: v[:project_id], runners: ::Ci::Runner.id_in(v[:runner_ids]).to_a } end @job_count = job_count || DEFAULT_JOB_COUNT end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
23 24 25 |
# File 'lib/gitlab/seeders/ci/runner/runner_fleet_pipeline_seeder.rb', line 23 def logger @logger end |
Instance Method Details
#seed ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gitlab/seeders/ci/runner/runner_fleet_pipeline_seeder.rb', line 38 def seed logger.info(message: 'Starting seed of runner fleet pipelines', job_count: @job_count) remaining_job_count = @job_count PROJECT_JOB_DISTRIBUTION.each_with_index do |d, index| remaining_job_count = create_pipelines_and_distribute_jobs(remaining_job_count, project_index: index, **d) end while remaining_job_count > 0 remaining_job_count -= create_pipeline( job_count: remaining_job_count, **@projects_to_runners[PROJECT_JOB_DISTRIBUTION.length], status: random_pipeline_status ) end logger.info( message: 'Completed seeding of runner fleet', job_count: @job_count - remaining_job_count ) nil end |