Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-71956

Can't use Octal mode number when using pod template's Raw YAML to config volumes

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • kubernetes-plugin
    • None
    • jenkins: Version 2.421
      k8s: 1.25.0
      plugin version: 4029.v5712230ccb_f8
    • kubernetes-plugin:4208.v4017b_a_27a_d67

      I'm using pod template, and use Raw YAML to config my volumes.

      I have use this for a long time(at least 3 months), it always works.

      However, when i upgrade Kubernetes plugin to latest version(4029.v5712230ccb_f8) today, my pod cannot create successfully, it shows :

       

      ...
       message-pod "xxx'
      is invalid: [spec.volumes5).configMap.defaultMode: Invalid value: 755: must be a number between 0 and 0777 (octal), both
      inclusive,
      ...
      

       

       

      my pod template's row yaml is:

       

       

      apiVersion: "v1"
      kind: "Pod"
      metadata:
          namespace: build
      spec:
        shareProcessNamespace: true
        automountServiceAccountToken: false
        tolerations:
          - key: "build_node"
            operator: "Exists"
            effect: "NoSchedule"
        nodeSelector:
          build-node: node
        containers:
        - name: "k8s"
          volumeMounts:
          - mountPath: "/usr/local/bin/help_deploy.sh"
            name: "helm-volume"
            readOnly: false
            subPath: "script.sh"
        volumes:
        - configMap:
            name: "helm"
            defaultMode: 0755
            optional: false
          name: "helm-volume"
       
      

       

      this sees be a bug of new version.

       

       

       

       

          [JENKINS-71956] Can't use Octal mode number when using pod template's Raw YAML to config volumes

          Filippos added a comment - - edited

          We are having a similar issue after updating to kubernetes: 4029.v5712230ccb_f8.
          We have a similar pod spec (see below), which was working before the update.
          After the update, we notice in the console logs that the defaultMode gets rendered as 272 when set as 420. Before the update, the value was passed through.
          The permissions we want to set is 0644.

          We set 420 in decimal notation which results to 0644 in octal notation.
          272 in decimal notation is 0420 in octal notation.

          The docs mention that octal notations are not supported on podTemplate . volumes . secretVolume . defaultMode

          defaultMode : String
          The file permissions for the secret volume. Does not support Octal notation.

          The issue seems to be related to a recent change

          Pod spec:

          kubernetes {
              inheritFrom 'parent'
              label some-label
              yaml """\
                  metadata:
                    ..
                  spec:
                    containers:
                    - name: builder
                      image: some-image
                      imagePullPolicy: Always
                      env:
                      - name: AWS_ROLE_ARN
                        value: some-arn
                      - name: AWS_WEB_IDENTITY_TOKEN_FILE
                        value: /var/run/secrets/eks.amazonaws.com/serviceaccount/token
                        ..
                      resources:
                        ..
                      volumeMounts:
                      - mountPath: /var/run/secrets/eks.amazonaws.com/serviceaccount
                        name: aws-iam-token
                        readOnly: true
                    volumes:
                    - name: aws-iam-token
                      projected:
                        defaultMode: 420
                        sources:
                        - serviceAccountToken:
                            path: token
                            audience: sts.amazonaws.com
                            expirationSeconds: 1800
              """.stripIndent()
              defaultContainer 'builder'
          }
          

          Rendered manifest before the update, as seen in the logs (emphasis on defaultMode):

          apiVersion: "v1"
          kind: "Pod"
          metadata:
            ..
          spec:
            containers:
            - env:
              - name: "AWS_ROLE_ARN"
                value: "some-arn"
              - name: "AWS_WEB_IDENTITY_TOKEN_FILE"
                value: "/var/run/secrets/eks.amazonaws.com/serviceaccount/token"
              image: "some-image"
              imagePullPolicy: "Always"
              name: "builder"
              resources:
                ..
              volumeMounts:
              - mountPath: "/var/run/secrets/eks.amazonaws.com/serviceaccount"
                name: "aws-iam-token"
                readOnly: true
              ..
            ..
            volumes:
            ..
            - name: "aws-iam-token"
              projected:
                defaultMode: 420
                sources:
                - serviceAccountToken:
                    audience: "sts.amazonaws.com"
                    expirationSeconds: 1800
                    path: "token"
          

          Rendered manifest after the update, as seen in the logs:

          apiVersion: "v1"
          kind: "Pod"
          metadata:
            ..
          spec:
            containers:
            - env:
              - name: "AWS_ROLE_ARN"
                value: "some-arn"
              - name: "AWS_WEB_IDENTITY_TOKEN_FILE"
                value: "/var/run/secrets/eks.amazonaws.com/serviceaccount/token"
              image: "some-image"
              imagePullPolicy: "Always"
              name: "builder"
              resources:
                ..
              volumeMounts:
              - mountPath: "/var/run/secrets/eks.amazonaws.com/serviceaccount"
                name: "aws-iam-token"
                readOnly: true
              ..
            ..
            volumes:
            ..
            - name: "aws-iam-token"
              projected:
                defaultMode: 272
                sources:
                - serviceAccountToken:
                    audience: "sts.amazonaws.com"
                    expirationSeconds: 1800
                    path: "token"
          

          Filippos added a comment - - edited We are having a similar issue after updating to kubernetes: 4029.v5712230ccb_f8 . We have a similar pod spec (see below), which was working before the update. After the update, we notice in the console logs that the defaultMode gets rendered as 272 when set as 420. Before the update, the value was passed through. The permissions we want to set is 0644. We set 420 in decimal notation which results to 0644 in octal notation. 272 in decimal notation is 0420 in octal notation. The docs mention that octal notations are not supported on podTemplate . volumes . secretVolume . defaultMode defaultMode : String The file permissions for the secret volume. Does not support Octal notation. The issue seems to be related to a recent change Pod spec: kubernetes { inheritFrom 'parent' label some-label yaml """\ metadata: .. spec: containers: - name: builder image: some-image imagePullPolicy: Always env: - name: AWS_ROLE_ARN value: some-arn - name: AWS_WEB_IDENTITY_TOKEN_FILE value: / var /run/secrets/eks.amazonaws.com/serviceaccount/token .. resources: .. volumeMounts: - mountPath: / var /run/secrets/eks.amazonaws.com/serviceaccount name: aws-iam-token readOnly: true volumes: - name: aws-iam-token projected: defaultMode: 420 sources: - serviceAccountToken: path: token audience: sts.amazonaws.com expirationSeconds: 1800 """.stripIndent() defaultContainer 'builder' } Rendered manifest before the update, as seen in the logs (emphasis on defaultMode): apiVersion: "v1" kind: "Pod" metadata: .. spec: containers: - env: - name: "AWS_ROLE_ARN" value: "some-arn" - name: "AWS_WEB_IDENTITY_TOKEN_FILE" value: "/ var /run/secrets/eks.amazonaws.com/serviceaccount/token" image: "some-image" imagePullPolicy: "Always" name: "builder" resources: .. volumeMounts: - mountPath: "/ var /run/secrets/eks.amazonaws.com/serviceaccount" name: "aws-iam-token" readOnly: true .. .. volumes: .. - name: "aws-iam-token" projected: defaultMode: 420 sources: - serviceAccountToken: audience: "sts.amazonaws.com" expirationSeconds: 1800 path: "token" Rendered manifest after the update, as seen in the logs: apiVersion: "v1" kind: "Pod" metadata: .. spec: containers: - env: - name: "AWS_ROLE_ARN" value: "some-arn" - name: "AWS_WEB_IDENTITY_TOKEN_FILE" value: "/ var /run/secrets/eks.amazonaws.com/serviceaccount/token" image: "some-image" imagePullPolicy: "Always" name: "builder" resources: .. volumeMounts: - mountPath: "/ var /run/secrets/eks.amazonaws.com/serviceaccount" name: "aws-iam-token" readOnly: true .. .. volumes: .. - name: "aws-iam-token" projected: defaultMode: 272 sources: - serviceAccountToken: audience: "sts.amazonaws.com" expirationSeconds: 1800 path: "token"

          Viktor added a comment -

          We're also hit by this, would appreciate any tips on how to move forward here.

          Viktor added a comment - We're also hit by this, would appreciate any tips on how to move forward here.

          Philippe added a comment -

          Same issue here. I actually rollbacked the plugin to fix this issue

          Philippe added a comment - Same issue here. I actually rollbacked the plugin to fix this issue

          yordan added a comment -

          Still affected.
          Version: 4186.v1d804571d5d4
           

           

          yordan added a comment - Still affected. Version: 4186.v1d804571d5d4    

          I had been avoiding this issue by using "defaultMode: 256" to grant read and write permission to only the user. Yesterday, I upgraded the kubernetes plugin to 4186.v1d804571d5d4, which broke permissions by changing "defaultMode: 256" to "defaultMode: 174" in the YAML sent to Kubernetes. It seems that defaultMode values are now always interpreted as octal whether they start with "0" or not, though YAML in the log still displays decimal. This is very surprising behavior.

          The good news is that I fixed my problem by replacing "defaultMode: 256" with "defaultMode: 0400". However, it should be possible to enable use of octal literals without breaking decimals.

          Jonathan Rogers added a comment - I had been avoiding this issue by using "defaultMode: 256" to grant read and write permission to only the user. Yesterday, I upgraded the kubernetes plugin to 4186.v1d804571d5d4, which broke permissions by changing "defaultMode: 256" to "defaultMode: 174" in the YAML sent to Kubernetes. It seems that defaultMode values are now always interpreted as octal whether they start with "0" or not, though YAML in the log still displays decimal. This is very surprising behavior. The good news is that I fixed my problem by replacing "defaultMode: 256" with "defaultMode: 0400". However, it should be possible to enable use of octal literals without breaking decimals.

          Proposed to use Jackson in the meantime: https://github.com/jenkinsci/kubernetes-plugin/pull/1537

          Allan BURDAJEWICZ added a comment - Proposed to use Jackson in the meantime: https://github.com/jenkinsci/kubernetes-plugin/pull/1537

            allan_burdajewicz Allan BURDAJEWICZ
            xia_mu_jin_su Jiang
            Votes:
            3 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: