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

When changing directories in Job within Kubernetes worker, durabletask returns a nonexistent error

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Labels:
      None
    • Environment:
      Jenkins ver. 2.222.3
      Kubernetes Plugin 1.25.4
      Durable Task 1.3.4

      Jenkins running on a container in a VM
      Jenkins Workers running on Kubernetes Cluster

      LAUNCH_DIAGNOSTICS has been set to TRUE
    • Similar Issues:

      Description

      When running a job in a Kubernetes worker, with the podTemplate

      Agent ci-base-v2-t6hf0 is provisioned from template ci-base-v2
      ---
      apiVersion: "v1"
      kind: "Pod"
      metadata:
        labels:
          jenkins: "slave"
          jenkins/label: "ci-base-v2-k8s"
        name: "ci-base-v2-t6hf0"
      spec:
        containers:
        - args:
          - "cat"
          command:
          - "/bin/sh"
          - "-c"
          image: "<X>/ci-base-v2:latest"
          imagePullPolicy: "Always"
          name: "workload"
          resources:
            limits: {}
            requests: {}
          securityContext:
            privileged: false
            runAsGroup: 1000
            runAsUser: 1000
          tty: true
          volumeMounts:
          - mountPath: "/var/run/docker.sock"
            name: "volume-0"
            readOnly: false
          - mountPath: "/home/jenkins/agent"
            name: "workspace-volume"
            readOnly: false
          workingDir: "/home/jenkins/agent"
        - env:
          - name: "JENKINS_SECRET"
            value: "********"
          - name: "JENKINS_TUNNEL"
            value: "<X>"
          - name: "JENKINS_AGENT_NAME"
            value: "ci-base-v2-t6hf0"
          - name: "JENKINS_NAME"
            value: "ci-base-v2-t6hf0"
          - name: "JENKINS_AGENT_WORKDIR"
            value: "/home/jenkins/agent"
          - name: "JENKINS_URL"
            value: "https://<X>"
          image: "jenkins/jnlp-slave:4.0.1-1"
          name: "jnlp"
          resources:
            requests:
              cpu: "100m"
              memory: "256Mi"
          volumeMounts:
          - mountPath: "/var/run/docker.sock"
            name: "volume-0"
            readOnly: false
          - mountPath: "/home/jenkins/agent"
            name: "workspace-volume"
            readOnly: false
        hostNetwork: false
        nodeSelector:
          beta.kubernetes.io/os: "linux"
        restartPolicy: "Never"
        securityContext: {}
        volumes:
        - hostPath:
            path: "/var/run/docker.sock"
          name: "volume-0"
        - emptyDir:
            medium: ""
          name: "workspace-volume"
      
      Running on ci-base-v2-t6hf0 in /home/jenkins/agent/workspace/DevOps/<X>/test-check-cred
      

       

      And attempting to checkout a git repo into a different directory via `dir`

      // code placeholder
      
      ...stages {
          stage('test kubeconfig') {
              parallel {
                  stage('test1'){
            steps {
                dir ('/home/jenkins/go'){
                    checkout([
                      $class: 'GitSCM',
                      branches: [[name: 'origin/master']],
                      doGenerateSubmoduleConfigurations: false,
                      submoduleCfg: [],
                      userRemoteConfigs: [[credentialsId: 'jenkins-bot-with-token', url: "https://<X>/command-center"]]
                    ]) ...

      I got an error with with the following error:

      08:33:41  sh: 1: cannot create /home/jenkins/go@tmp/durable-a40581a0/jenkins-log.txt: Directory nonexistent
      08:33:41  sh: 1: cannot create /home/jenkins/go@tmp/durable-a40581a0/jenkins-result.txt.tmp: Directory nonexistent
      08:33:41  mv: cannot stat '/home/jenkins/go@tmp/durable-a40581a0/jenkins-result.txt.tmp': No such file or directory
      

      But when I don't change directories, the build passes.

      When running the same CI job on a Docker Host Worker, changing directories does not cause any errors.

       

        Attachments

          Activity

          Hide
          jboubechtoula Julien Boubechtoula added a comment - - edited

          Hi David Chua .

          Unfortunately, I encounter the same problem with command 'sh'.

          Do you have find a workaround ?

          Show
          jboubechtoula Julien Boubechtoula added a comment - - edited Hi David Chua . Unfortunately, I encounter the same problem with command 'sh'. Do you have find a workaround ?
          Hide
          davidchua David Chua added a comment -

          Julien Boubechtoula unfortunately no. I'm still blocked by this before I can deploy the Kubernetes Workers across my organization.

          Show
          davidchua David Chua added a comment - Julien Boubechtoula unfortunately no. I'm still blocked by this before I can deploy the Kubernetes Workers across my organization.
          Hide
          jboubechtoula Julien Boubechtoula added a comment -

          Hello David Chua

           

          The working dir doesn't work as expected.

          https://issues.jenkins-ci.org/browse/JENKINS-59160?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel

          For me, when I have removed this argument, my pipeline works.

           

          Regards,

          Show
          jboubechtoula Julien Boubechtoula added a comment - Hello David Chua   The working dir doesn't work as expected. https://issues.jenkins-ci.org/browse/JENKINS-59160?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel For me, when I have removed this argument, my pipeline works.   Regards,
          Hide
          davidchua David Chua added a comment -

          Julien Boubechtoula thanks for the link!

          When you meant by "removed this argument", did you mean you set the "HOME" env?

          Show
          davidchua David Chua added a comment - Julien Boubechtoula thanks for the link! When you meant by "removed this argument", did you mean you set the "HOME" env?
          Hide
          jboubechtoula Julien Boubechtoula added a comment - - edited

          No, just delete
          workingDir: "/home/jenkins/agent"
          from your settings.

           

          Regards,

          Show
          jboubechtoula Julien Boubechtoula added a comment - - edited No, just delete workingDir: "/home/jenkins/agent" from your settings.   Regards,

            People

            • Assignee:
              Unassigned
              Reporter:
              davidchua David Chua
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: