Don't return error when checking feature flag
What does this MR do?
Don't return error when checking feature flag
Why was this MR needed?
When the value of the feature flag can't be parsed an error is return. This error is being ignored for most cases because there isn't any value in handling that error.
The only time the error is handled is for logging. Instead of logging it
in 1 place move the log inside of the featureflag
pkg where the caller
passes the logger.
With this we get the added benefit of using the logger that is already initialized, not that there was anything preventing us from doing so in the past. For example when we fail to parse the value of a specific job
Before:
ERROR: Error while parsing the value of feature flag error=strconv.ParseBool: parsing "asdf": invalid syntax name=FF_RESET_HELPER_IMAGE_ENTRYPOINT value=asdf
After:
ERROR: Error while parsing the value of feature flag error=strconv.ParseBool: parsing "asdf": invalid syntax job=2187 name=FF_RESET_HELPER_IMAGE_ENTRYPOINT project=20 runner=4B72igtx value=asdf
What's the best way to test this MR?
FF_USE_FAST_ZIP
(feature flag depending on the environment variables)
-
Until #27669 gets fixed we have to apply the diff below you double-check the feature flag for
USE_FAST_ZIP
since there is no coveragegit diff
diff --git a/commands/helpers/archiver.go b/commands/helpers/archiver.go index 8611cefca..1283430bc 100644 --- a/commands/helpers/archiver.go +++ b/commands/helpers/archiver.go @@ -19,6 +19,7 @@ func init() { // enable fastzip archiver/extractor logger := logrus.WithField("name", featureflags.UseFastzip) if on := featureflags.IsOn(logger, os.Getenv(featureflags.UseFastzip)); on { + println("using fast zip") archive.Register(archive.Zip, fastzip.NewArchiver, fastzip.NewExtractor) } }
-
Start a
shell
executor -
Run the following
.gitlab-ci.yml
file.gitlab-ci.yml
variables: RANDOM_MB: 300 FF_USE_FASTZIP: "true" cache: key: ${CI_COMMIT_REF_SLUG} paths: - cache job: stage: test script: - mkdir -p cache - touch cache/tada - echo "hello" > cache/hello.txt - dd bs=${RANDOM_MB} count=1048576 </dev/urandom > cache/blob - ls -la - ls -la cache
-
You should see the following in the job log
FF_NETWORK_PER_BUILD
(feature flag depending on job variable)
-
Start a
docker
executor -
Run the following
.gitlab-ci.yml
.gitlab-ci.yml
job: image: alpine:3.11 variables: SLEEP: 60 POSTGRES_HOST_AUTH_METHOD: "trust" FF_NETWORK_PER_BUILD: "true" services: - name: postgres:12.2-alpine alias: db before_script: - echo $FF_NETWORK_PER_BUILD - apk add --no-cache postgresql-client script: #- pg_isready -h 127.0.0.1 - pg_isready -h db - pg_isready -h postgres - sleep ${SLEEP}
-
While the job is running make sure a network is created for the build by running
docker network ls
docker network ls
``shell ~ docker network ls NETWORK ID NAME DRIVER SCOPE d2934ad93384 bridge bridge local a8d215125ce7 host host local d071437ccf78 minikube bridge local 44a1a7d5bd1a none null local 8c270e3e9c4a runner-4b72igtx-project-20-concurrent-0-job-2193-network bridge local <-------- Network for build
</details>
What are the relevant issue numbers?
Refactor to work on #27613 (closed)