Class: Gitlab::Seeders::Ci::Runner::RunnerFleetSeeder

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/seeders/ci/runner/runner_fleet_seeder.rb

Constant Summary collapse

DEFAULT_USERNAME =
'root'
DEFAULT_PREFIX =
'rf-'
DEFAULT_RUNNER_COUNT =
40
DEFAULT_JOB_COUNT =
DEFAULT_RUNNER_COUNT * 10
TAG_LIST =

rubocop:disable Layout/LineLength

%w[gitlab-org docker ruby 2gb mysql linux shared shell deploy hhvm windows build postgres ios stage android stz front back review-apps pc java scraper test kubernetes staging no-priority osx php nodejs production nvm x86_64 gcc nginx dev unity odoo node sbt amazon xamarin debian gcloud e2e clang composer npm energiency dind flake8 cordova x64 private aws solution ruby2.2 python xcode kube compute mongo runner docker-compose phpunit t-matix docker-machine win server docker-in-docker redis go dotnet win7 area51-1 testing chefdk light osx_10-11 ubuntu gulp jertis gitlab-runner frontendv2 capifony centos7 mac gradle golang docker-builder runrepeat maven centos6 msvc14 amd64 xcode_8-2 macos VS2015 mono osx_10-12 azure-contend-docker msbuild git deployer local development python2.7 eezeeit release ios_9-3 fastlane selenium integration tests review cabinet-dev vs2015 ios_10-2 latex odoo_test quantum-ci prod sqlite heavy icc html-test labs feature alugha ps appivo-server fast web ios_9-2 c# python3 home js xcode_7-3 drupal 7 arm headless php70 gce x86 msvc builder Windows bower mssql pagetest wpf ssh inmobiliabeta.com xcode_7-2 repo laravel testonly gcp online-auth powershell ila-preprod ios_10-1 lossless sharesies backbone javascript fusonic-review autoscale ci ubuntu1604 rails windows10 xcode_8-1 php56 drupal embedded readyselect xamarin.ios XCode-8.1 iOS-10.1 macOS-10.12.1 develop taggun koumoul-internal docker-build iOS angular2 deployment xcode8 lcov test-cluster priv api bundler freebsd x86-64 BOB xcode_8 nuget vinome-backend cq_check fusonic-perf django php7 dy-manager-shell DEV mongodb neadev meteor ANSIBLE ftp master exerica-build server01 exerica-test mother-of-god nodejs-app ansible Golang mpi exploragen shootr Android macos_10-12 win64 ngsrunner @docker images script-maven ayk makepkg Linux ecolint wix xcode_8-0 coverage dreamhost multi ubuntu1404 eyeka jow3an-site repository politibot qt haskellstack arch priviti backend Sisyphus gm-dev dotNet internal support rpi .net buildbot-01 quay.io BOB2 codebnb vs2013 no-reset live 192.168.100.209 failfast-ci ios_10 crm_master_builds Qt packer selenium hub ci-shell rust dyscount-ci-manager-shell kubespray vagrant deployAutomobileBuild 1md k8s behat vinome-frontend development-nanlabs build-backend libvirt build-frontend contend-server windows-x64 chimpAPI ec2-runner kubectl linux-x64 epitech portals kvm ucaya-docker scala desktop buildmacbinaries ghc buildwinbinaries sonarqube deploySteelDistributorsBuild macOS r cpran rubocop binarylane r-packages alpha SIGAC tester area51-2 customer Build qa acegames_central mTaxNativeShell c++ cloveapp-ios smallville portal root lemmy nightly buildlinuxbinaries rundeck taxonic ios_10-0 n0004 data fedora rr-test seedai_master_builds geofence_master_builds].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger = Gitlab::AppLogger, **options) ⇒ Array<Hash>

Initializes the class

Parameters:

  • logger (Gitlab::Logger) (defaults to: Gitlab::AppLogger)
  • options (Hash)

Options Hash (**options):

  • :username (String)

    username of the user that will create the fleet

  • :registration_prefix (String)

    string to use as prefix in group, project, and runner names

  • :runner_count (Integer)

    number of runners to create across the groups and projects



25
26
27
28
29
30
31
32
33
34
# File 'lib/gitlab/seeders/ci/runner/runner_fleet_seeder.rb', line 25

def initialize(logger = Gitlab::AppLogger, **options)
  username = options[:username] || DEFAULT_USERNAME

  @logger = logger
  @user = User.find_by_username(username)
  @registration_prefix = options[:registration_prefix] || DEFAULT_PREFIX
  @runner_count = options[:runner_count] || DEFAULT_RUNNER_COUNT
  @groups = {}
  @projects = {}
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



15
16
17
# File 'lib/gitlab/seeders/ci/runner/runner_fleet_seeder.rb', line 15

def logger
  @logger
end

Instance Method Details

#seedObject

seed returns an array of hashes of projects to its assigned runners



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/gitlab/seeders/ci/runner/runner_fleet_seeder.rb', line 37

def seed
  return unless within_plan_limits?

  logger.info(
    message: 'Starting seed of runner fleet',
    user_id: @user.id,
    registration_prefix: @registration_prefix,
    runner_count: @runner_count
  )

  groups_and_projects = create_groups_and_projects
  runner_ids = create_runners(groups_and_projects)

  logger.info(
    message: 'Completed seeding of runner fleet',
    registration_prefix: @registration_prefix,
    groups: @groups.count,
    projects: @projects.count,
    runner_count: @runner_count
  )

  %i[project_1_1_1_1 project_1_1_2_1 project_2_1_1].map do |project_key|
    { project_id: groups_and_projects[project_key].id, runner_ids: runner_ids[project_key] }
  end
end