Add feature flags in config.toml
What does this MR do?
- refactor(ff): change default type to bool
- Allow user to set a feature flag inside of the config.toml with
[runners.feature_flags]
which aren't overridable able by an job variables.
Why was this MR needed?
-
refactor(ff): change default type to bool
Having a bool as a string makes it hard when you want to check if pragmatically. It's easier to transform a bool into a string than vice versa.
-
feat(ff): set feature flag in config.toml
In !2805 (merged) we want to change how
docker+machine
executor creates machines and we want to roll this out behind a feature flag. At the moment users can only specify a feature flag as a job variable, which won't work in this case because a machine is created before a job exists so there is no way we can set this.
What's the best way to test this MR?
config.toml
Feature flag defined in -
Start a
docker
executor with the followingconfig.toml
[[runners]] name = "docker" url = "http://gdk.test:3000/" token = "" executor = "docker" limit = 2 [runners.feature_flags] "FF_NETWORK_PER_BUILD" = true [runners.docker] image = "alpine:3.12" privileged = true
-
Start a job
.gitlab-ci.yml
variables: SLEEP: 60 job: stage: test script: - sleep ${SLEEP}
-
Whilst the job is running make sure that a network is created for the build
docker network ls
$ docker network ls NETWORK ID NAME DRIVER SCOPE 9f60f6e85862 bridge bridge local a8d215125ce7 host host local d071437ccf78 minikube bridge local 44a1a7d5bd1a none null local 7897d6060eb2 runner-4b72igtx-project-20-concurrent-0-job-2195-network bridge local b478d99ffde3 spamcheck_default bridge local
config.toml
but turned on inside of envionrments
Feature flag turned off in -
Start a
docker
executor with the followingconfig.toml
config.toml
[[runners]] name = "docker" url = "http://gdk.test:3000/" token = "" executor = "docker" environment = ["FF_NETWORK_PER_BUILD=true"] [runners.feature_flags] "FF_NETWORK_PER_BUILD" = false [runners.docker] image = "alpine:3.12" privileged = true
-
Start a job
.gitlab-ci.yml
variables: SLEEP: 60 job: stage: test script: - sleep ${SLEEP}
-
Whilst running the job make sure that a network wasn't created since we disable it in
[runners.feature_flags]
docker network ls
# No network created for the build! $ docker network ls NETWORK ID NAME DRIVER SCOPE 9f60f6e85862 bridge bridge local a8d215125ce7 host host local d071437ccf78 minikube bridge local 44a1a7d5bd1a none null local b478d99ffde3 spamcheck_default bridge local
config.toml
but turned on inside of job variables
Feature flag turned off in -
Start a
docker
executor with the followingconfig.toml
config.toml
[[runners]] name = "docker" url = "http://gdk.test:3000/" token = "" executor = "docker" [runners.feature_flags] "FF_NETWORK_PER_BUILD" = false [runners.docker] image = "alpine:3.12" privileged = true
-
Start a job
.gitlab-ci.yml
variables: SLEEP: 60 FF_NETWORK_PER_BUILD: "true" job: stage: test script: - sleep ${SLEEP}
-
Whilst running the job make sure that a network wasn't created since we disable it in
[runners.feature_flags]
docker network ls
# No network created for the build! $ docker network ls NETWORK ID NAME DRIVER SCOPE 9f60f6e85862 bridge bridge local a8d215125ce7 host host local d071437ccf78 minikube bridge local 44a1a7d5bd1a none null local b478d99ffde3 spamcheck_default bridge local
What are the relevant issue numbers?
To safely roll out #27613 (closed)