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

KubernetesSlave should override getWorkspaceFor(TopLevelItem)

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • kubernetes-plugin
    • None

      olamy noticed some problems running tests in a multibranch project using K8S due to the tests using Unix sockets, which imposes a very low limit (PATH_MAX IIRC) on the length of the workspace directory name plus whatever subdirectory your stuff runs in. JENKINS-34564 means that the default branch project workspace path is fairly long in most cases, which caused problems for example with socket-based sshagent before JENKINS-36997 switched to a CLI implementation.

      At any rate, the entire reason for selecting a workspace path which is unique among all possible branch projects in the Jenkins instance—to avoid clashes between projects—is moot when using a K8S agent, since these are allocated dynamically within the scope of the build. So while the Slave.workspaceRoot is by default /home/jenkins/workspace, which is fine, the workspace for the build is /home/jenkins/workspace/project-PR-5-ABC123SOMETHINGVERYVERYLONG, which is pointless. Assuming the KubernetesSlave is normally used for a single build, it should just

      @Override
      public FilePath getWorkspaceFor(TopLevelItem item) {
          if (item.equals(howeverYouDetermineTheOwningBuild().getParent())) {
              return getWorkspaceRoot().child("main");
          } else {
              return super.getWorkspaceFor(item);
          }
      }
      

      so that the build will run inside /home/jenkins/workspace/main—a nice short, predictable name.

            Unassigned Unassigned
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: