Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runners): add support to disable default labels (Linux) #3491

Merged
merged 16 commits into from
Nov 18, 2024

Conversation

jgutierrezglez
Copy link
Contributor

In case the pool of runners deployed using this module are fully available for an wide GH org (no repository restrictions) any workflow configured to run in runners that contain just default labels in the runs-on definition:

e.g.

runs-on: self-hosted
runs-on: Linux

can end-up running in this pool without knowing it. That's why I have decided to remove the default labels from our runners and just rely on unique custom labels, and I believed the best way to do it by adding a runner_enable_default_labels variable - that by default is true (so, it doesn't change the current behavior), but it can help other people to deal with similar issues like the one described above.

@jgutierrezglez jgutierrezglez force-pushed the enable_default_labels_option branch from b296740 to eb9a4e6 Compare September 21, 2023 10:30
@jgutierrezglez jgutierrezglez changed the base branch from develop to main September 21, 2023 10:32
@npalm
Copy link
Member

npalm commented Sep 21, 2023

I think I missed GitHub changes this. In the past the default labels are added by GitHub without control. When we introduced the JIT config the default labels are not added by default. But is this the same for non JIT?

@npalm npalm self-requested a review September 21, 2023 12:36
@jgutierrezglez jgutierrezglez changed the title feat: Adding runner_enable_default_labels variable feat: Adding the possibility of removing the default labels Oct 4, 2023
@jgutierrezglez
Copy link
Contributor Author

I think I missed GitHub changes this. In the past the default labels are added by GitHub without control. When we introduced the JIT config the default labels are not added by default. But is this the same for non JIT?

We're using JIT - and the default labels are added by default, that's why we have created this new variable and set it to false in the cases where we just want to use custom labels

Copy link
Member

@npalm npalm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to find some time to test.

  • Changes impacted the runner module should also reflected to the multi-runner module. See comment
  • I think this option requires that JIT config is enabled. Can you hadd this to the docs of the introduced variable.

main.tf Outdated Show resolved Hide resolved
@jgutierrezglez jgutierrezglez force-pushed the enable_default_labels_option branch from 9b858e0 to e945d21 Compare October 9, 2023 11:22
@npalm npalm self-requested a review October 14, 2023 08:42
@sdarwin
Copy link
Contributor

sdarwin commented Nov 1, 2023

For the reasons explained in the original post, this feature would be great, so you can enable runners without repository restrictions.

runs-on: self-hosted won't accidentally trigger a launch if only custom labels have been added.

Maybe I am mistaken (and I might be!) but here are a few quick comments:

  1. This appears to be the pull request adding the feature: Add --no-default-labels config option to self-hosted runners actions/runner#2443

  2. It doesn't mention JIT config. Isn't JIT completely orthogonal to default labels? Unrelated. So remove JIT from this PR.

  3. The feature uses the flag --no-default-labels. Where is the flag --no-default-labels in this PR?

Copy link
Contributor

github-actions bot commented Dec 2, 2023

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Dec 2, 2023
@npalm npalm removed the Stale label Dec 8, 2023
@npalm
Copy link
Member

npalm commented Dec 8, 2023

Sorry we had no time yet to dig in this PR. I do my best to check the PR in the coming week. Sorry for the delay.

@jgutierrezglez jgutierrezglez force-pushed the enable_default_labels_option branch 2 times, most recently from ed603ef to c0ebeb7 Compare December 11, 2023 16:55
@jgutierrezglez jgutierrezglez marked this pull request as draft December 11, 2023 16:57
@jgutierrezglez jgutierrezglez force-pushed the enable_default_labels_option branch 6 times, most recently from cd60c15 to 78a52a2 Compare December 12, 2023 14:39
@jgutierrezglez jgutierrezglez marked this pull request as ready for review December 12, 2023 14:41
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Feb 11, 2024
@npalm npalm removed the Stale label Feb 12, 2024
@jgutierrezglez jgutierrezglez force-pushed the enable_default_labels_option branch 3 times, most recently from 5d77fea to 01b73bf Compare March 11, 2024 16:53
Copy link
Member

@npalm npalm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jgutierrezglez thanks for this great PR. I have tested several cases

  • Default runner - works, requires a suggested change on defaults
  • Multi runner (linux)
  • Multi runner (linux) - with JIT
  • Multi runner (windows)

For the multi runner I needed to make the follwoing adjusments:

  1. mutli-runner module runners.tf

Pass parametr into runner module:

runner_disable_default_labels        = each.value.runner_config.runner_disable_default_labels

and avoid setting defaults if labels are disabled.

  runner_labels                        = each.value.runner_config.runner_disable_default_labels ?  sort(distinct(each.value.runner_config.runner_extra_labels)) :  sort(distinct(concat(["self-hosted", each.value.runner_config.runner_os, each.value.runner_config.runner_architecture], each.value.runner_config.runner_extra_labels)))

I would say the PR is getting close to merge. To get it faster passed you could split the PR in two parts. First the linux part adding the feature, next another PR to fix the windows part.

variables.tf Outdated Show resolved Hide resolved
variables.tf Show resolved Hide resolved
modules/runners/templates/start-runner.ps1 Outdated Show resolved Hide resolved
jgutierrezglez and others added 3 commits November 15, 2024 13:27
Co-authored-by: Niek Palm <npalm@users.noreply.github.com>
@jgutierrezglez jgutierrezglez changed the title feat: Adding the possibility of removing the default labels feat: Adding the possibility of removing the default labels (Linux) Nov 15, 2024
@jgutierrezglez
Copy link
Contributor Author

@npalm #4261 PR to address the Windows fix

@sdarwin
Copy link
Contributor

sdarwin commented Nov 15, 2024

@jgutierrezglez , this is a question rather than definitely something needs to change, but why does it say $${extra_flags} instead of ${extra_flags} in start-runner.sh? What effect does that have? isn't extra_flags a regular variable within the bash script that would have one $?

@jgutierrezglez
Copy link
Contributor Author

@jgutierrezglez , this is a question rather than definitely something needs to change, but why does it say $${extra_flags} instead of ${extra_flags} in start-runner.sh? What effect does that have? isn't extra_flags a regular variable within the bash script that would have one $?

Thanks for the catch, there is no real reason to use $${extra_flags} and I just corrected

@npalm npalm changed the title feat: Adding the possibility of removing the default labels (Linux) feat(runners): add support to disable default labels (Linux) Nov 15, 2024
Copy link
Member

@npalm npalm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made two tiny documentation suggestions. Rest looks good and tested for linux (amazon and ubuntu).

Maybe worth to add a small section in the docs to disuss the choice betwoon using default labels and disable them.

Besides those small notes good to go 🚀

variables.tf Outdated Show resolved Hide resolved
modules/multi-runner/variables.tf Outdated Show resolved Hide resolved
@jgutierrezglez jgutierrezglez force-pushed the enable_default_labels_option branch from 9e14e8b to 611fa17 Compare November 18, 2024 05:47
@jgutierrezglez
Copy link
Contributor Author

Made two tiny documentation suggestions. Rest looks good and tested for linux (amazon and ubuntu).

Maybe worth to add a small section in the docs to disuss the choice betwoon using default labels and disable them.

Besides those small notes good to go 🚀

I added a small note under "Configuration considerations" - let me know what you think about it

@npalm npalm self-requested a review November 18, 2024 12:09
Copy link
Member

@npalm npalm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and all good, one tiny change requested

main.tf Outdated Show resolved Hide resolved
jgutierrezglez and others added 2 commits November 18, 2024 17:47
Co-authored-by: Niek Palm <npalm@users.noreply.github.com>
@npalm npalm merged commit 772e1a5 into philips-labs:main Nov 18, 2024
42 checks passed
npalm pushed a commit that referenced this pull request Nov 19, 2024
@@ Description

Adding support for no default labels on Windows, see #3491
npalm pushed a commit that referenced this pull request Nov 19, 2024
🤖 I have created a release *beep* *boop*
---


##
[5.20.0](v5.19.0...v5.20.0)
(2024-11-19)


### Features

* **runners:** add support to disable default labels (Linux)
([#3491](#3491))
([772e1a5](772e1a5))
@jgutierrezglez
* **runners:** add support to disable default labels (Windows)
([#4261](#4261))
([ad9bcc4](ad9bcc4))
@jgutierrezglez


### Bug Fixes

* **lambda:** bump cross-spawn from 7.0.3 to 7.0.6 in /lambdas
([#4273](#4273))
([dcec236](dcec236))
* **lambda:** bump the aws group in /lambdas with 7 updates
([#4266](#4266))
([849549e](849549e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: forest-releaser[bot] <80285352+forest-releaser[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants