Skip to content

Add test for permissions container in k8s

What does this MR do?

Add test for permissions container in k8s

Why was this MR needed?

In !2578 (merged) we are fixing a bug where users will be able to use the helper image when overridden. Add tests to validate that this works and to make sure we don't break it in the future.

What's the best way to test this MR?

  1. Run the test go test -v -run TestExecutor_buildLogPermissionsInitContainer ./executors/kubernetes/...

If you want to check if all of the feature is working, run the following

  1. Update config.toml to have the following

    config.toml
    [[runners]]
      name = "kubernetes"
      url = "http://gdk.test:3000/"
      token = ""
      executor = "kubernetes"
      environment = ["FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY=false"]
      [runners.kubernetes]
        bearer_token_overwrite_allowed = false
        image = "alpine:3.12"
        privileged = true
        helper_image = "public.ecr.aws/gitlab/gitlab-runner-helper:x86_64-latest"
  2. Run job like the following:

    .gitlab-ci.yml
        job:
      stage: test
      script:
        - sleep 60
  3. Check that initContainer is using the helper image override

    shell
    $ kubectl get po
    NAME                                           READY   STATUS            RESTARTS   AGE
    runner-mkp1g3gh-project-20-concurrent-0tnmrh   0/2     PodInitializing   0          2s
    
    $ kubectl get po/runner-mkp1g3gh-project-20-concurrent-0tnmrh  -o json  | jq '.spec.initContainers | keys[] as $k | "\\(.[$k] | .image)"'
    "public.ecr.aws/gitlab/gitlab-runner-helper:x86_64-latest"

What are the relevant issue numbers?

Closes #27393 (closed)

Merge request reports