Skip to content

Fix incorrect Kubernetes Windows paths for artifacts and caches

What does this MR do?

Kubernetes executor uses a absolute linux path for the runner helper binary. This changes it to use gitlab-runner-helper, and assume the binary is within the PATH (this is how the docker-windows executor works also) when Windows pods are detected.

In addition, it removes the use of filepath.* from the abstract shell, which makes incorrect assumptions about the full pathname of the target system jobs are being deployed to. Leaving this as just a forward/slash/path is a saner option, as it is consistent and the underlying shell can handle the path natively. This is placed behind the UsePowershellPathResolver feature flag for extra safety.

Why was this MR needed?

  • Windows cannot use the default hard-coded gitlab-runner-helper path.
  • filepath.Abs does not work when the executor is on Linux, targetting Windows nodes.

What's the best way to test this MR?

Manual QA:

  • Setup a Windows k8s cluster on GCP.
  • Authenticate locally with gcloud container clusters get-credentials <cluster name>
  • Configure runner's config.toml
    [[runners]]
    ...
    executor = "kubernetes"
    shell = "pwsh"
    
    [runners.feature_flags]
      # If deploying the Runner to Linux, but targetting Windows, this FF needs to be enabled for now
      FF_USE_POWERSHELL_PATH_RESOLVER = true
    
      # Our newer execution strategy doesn't yet support Windows pods
      FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY = true
    [runners.kubernetes]
      image = "mcr.microsoft.com/powershell:lts-nanoserver-1809"
      [runners.kubernetes.node_selector]
        "kubernetes.io/arch" = "amd64"
        "kubernetes.io/os" = "windows"
        "node.kubernetes.io/windows-build" = "10.0.17763"
  • Run a job that defines artifacts and caches:
    job:
      script:
        - echo "hello world"
        - new-item -type file hi
      cache:
        key: my-cache
        paths:
          - hi
      artifacts:
        paths:
          - hi

What are the relevant issue numbers?

Closes #28035 (closed)

Edited by Arran Walker

Merge request reports