KubernetesSlave should override getWorkspaceFor(TopLevelItem)

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      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.

            Assignee:
            Unassigned
            Reporter:
            Jesse Glick
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: