actions / actions/runner-container-hooks

ACTIONS_RUNNER_CONTAINER_HOOK_TEMPLATE doesnt tolerate octal file modes in configmap volume declaration

Open
#161 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
153
Forks
112
Avg merge
6m
Merged PRs (30d)
1

Description

Summary

I'm using the ACTIONS_RUNNER_CONTAINER_HOOK_TEMPLATE in ARC, and trying to mount a configmap with various file modes. Providing the file mode in octal results in a pipeline error during Initialize Containers part of my Job. Switching to decimal resolves the issue but is significantly more confusing.

BAD

    ---
    apiVersion: v1
    kind: PodTemplate
    metadata:
      name: runner-pod-template
      labels:
        app: github-actions-runner
        runnnerName: my-github-runner-test
      annotations:
        cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
    spec:
      imagePullPolicy: Always
      containers:
      - name: $job
        securityContext:
          privileged: true
        env:
          - name: NODE_EXTRA_CA_CERTS
            value: /usr/local/share/ca-certificates/ca.crt
          - name: AWS_CONFIG_FILE
            value: /.aws/config
          - name: AWS_PROFILE
            value: target_role
        volumeMounts:
          - name: github-server-tls-cert
            mountPath: /usr/local/share/ca-certificates/ca.crt
            subPath: ca.crt
            readOnly: true
          - mountPath: /.aws
            name: aws-dir
          - name: iam-config
            mountPath: /.aws/config
            subPath: config
            readOnly: true
          - name: iam-config
            mountPath: /.aws/eks-credential-processrole.sh
            subPath: eks-credential-processrole.sh
        resources:
          requests:
            cpu: 100m
            memory: "4Gi"
      serviceAccountName: my-github-runner-test
      securityContext:
        fsGroup: 1001  # provides access to /home/runner/_work directory in ephemeral volume
      tolerations:
      - effect: NoSchedule
        key: dedicated
        operator: Equal
        value: gitlab
      volumes:
      - name: github-server-tls-cert
        configMap:
          name: my-cacert
          items:
            - key: ca.crt
              path: ca.crt
      - name: aws-dir
        emptyDir: {}
      - name: iam-config
        configMap:
          name: iam-config
          items:
          - key: config
            path: config
            # THIS DOESNT WORKS
            mode: 0777
          - key: eks-credential-processrole.sh
            path: eks-credential-processrole.sh
            # THIS DOESNT WORK
            mode: 0555

GOOD

    ---
    apiVersion: v1
    kind: PodTemplate
    metadata:
      name: runner-pod-template
      labels:
        app: github-actions-runner
        runnnerName: my-github-runner-test
      annotations:
        cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
    spec:
      imagePullPolicy: Always
      containers:
      - name: $job
        securityContext:
          privileged: true
        env:
          - name: NODE_EXTRA_CA_CERTS
            value: /usr/local/share/ca-certificates/ca.crt
          - name: AWS_CONFIG_FILE
            value: /.aws/config
          - name: AWS_PROFILE
            value: target_role
        volumeMounts:
          - name: github-server-tls-cert
            mountPath: /usr/local/share/ca-certificates/ca.crt
            subPath: ca.crt
            readOnly: true
          - mountPath: /.aws
            name: aws-dir
          - name: iam-config
            mountPath: /.aws/config
            subPath: config
            readOnly: true
          - name: iam-config
            mountPath: /.aws/eks-credential-processrole.sh
            subPath: eks-credential-processrole.sh
        resources:
          requests:
            cpu: 100m
            memory: "4Gi"
      serviceAccountName: my-github-runner-test
      securityContext:
        fsGroup: 1001  # provides access to /home/runner/_work directory in ephemeral volume
      tolerations:
      - effect: NoSchedule
        key: dedicated
        operator: Equal
        value: gitlab
      volumes:
      - name: github-server-tls-cert
        configMap:
          name: my-cacert
          items:
            - key: ca.crt
              path: ca.crt
      - name: aws-dir
        emptyDir: {}
      - name: iam-config
        configMap:
          name: iam-config
          items:
          - key: config
            path: config
            # THIS WORKS
            mode: 292
          - key: eks-credential-processrole.sh
            path: eks-credential-processrole.sh
            # THIS WORKS
            mode: 365

Error Message

On the Initialize Containers step, i get the following error:

Error: Error: failed to create job pod: Pod "my-github-runner-test-s9klc-runner-96622-workflow" is invalid: [spec.volumes[4].configMap.items[1].mode: Invalid value: 555: must be a number between 0 and 0777 (octal), both inclusive, spec.containers[0].volumeMounts[6].name: Not found: "iam-config", spec.containers[0].volumeMounts[7].name: Not found: "iam-config"]
Error: Process completed with exit code 1.
Error: Executing the custom container implementation failed. Please contact your self hosted runner administrator.

I suspect the hook removes the 0 prefix in the octal notation causing the the actual pod yaml that the controller creates to provide an invalid value

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how ACTIONS_RUNNER_CONTAINER_HOOK_TEMPLATE parses and emits ConfigMap volume item modes, then reproduce the provided PodTemplate with octal modes 0777 and 0555. Done means the generated pod accepts those modes as values between 0 and 0777, while the existing decimal-mode behavior remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, typescript
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.