veertuinc / gitlab-runner

MIT License
16 stars 3 forks source link

CLOUD-781 : [Feature Request] Provide the controller with job information as custom columns #10

Closed tejassharma96 closed 3 years ago

tejassharma96 commented 3 years ago

It would be great to match specific instances in the controller to which job they're running on gitlab. The controller has custom fields for "Name" and "External ID", could they be set up to pull from our gitlab ci files? e.g for my use case I might use $CI_PROJECT_NAME and CI_JOB_ID)

tejassharma96 commented 3 years ago

Looks like you have the architecture for this since you have a StartVMRequest struct. You'd need to perform some minor refactoring by adding external_id, updating name so it translates to name rather than name_template, and adding name_template as its own property.

You would then just need to update the instantiation of the StartVMRequest to populate those variables.

I'd love to make a pr for this but am unfamiliar with the code base and the programming language, so I wouldn't know, eg, what sort of tests need to be updated. If someone could point me to any tests relevant to making these changes, I'd be happy to update those tests and make the change myself.

NorseGaud commented 3 years ago
Screen Shot 2021-05-03 at 5 59 22 PM

The top instance example from the image above is the defaults. The bottom is using the following for the registration:

./out/binaries/anka-gitlab-runner-darwin-amd64 register --non-interactive \
. . .
--name "localhost shared runner" \
. . .
--executor anka \
--anka-instance-name "triggered by shared runner" \
--anka-external-id "http://test123.com" \
. . .

The code looks to be done so I'm working on the CI tests now. This will be released as 1.4.0 once they pass.

tejassharma96 commented 3 years ago

Will those also be configurable from within the gitlab-ci yml file? Or just when registering the runner. It'd be great to have them configurable from the yml file too :)

NorseGaud commented 3 years ago

@tejassharma96, just to confirm: You mean set an ENV under variables?

tejassharma96 commented 3 years ago

Yep, exactly, and then they can be read from there the same way we can currently set ANKA_TEMPLATE_UUID etc (https://github.com/veertuinc/gitlab-runner/blob/aa0a550808278288fbf71b016ffd00166f69ee9a/executors/anka/executor_anka.go#L61)