Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-60517] Add null check for containerWorkingDirFilePath #671

Merged
merged 3 commits into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ public Proc launch(ProcStarter starter) throws IOException {
containerWorkingDirStr = containerWorkingDir.get();
}

if (containerWorkingDir.isPresent() && ! containerWorkingDirFilePath.getRemote().startsWith(containerWorkingDirStr)) {
if (containerWorkingDir.isPresent() &&
containerWorkingDirFilePath != null &&
! containerWorkingDirFilePath.getRemote().startsWith(containerWorkingDirStr)) {
// Container has a custom workingDir, updated the pwd to match container working dir
containerWorkingDirFilePathStr = containerWorkingDirFilePath.getRemote().replaceFirst(
ContainerTemplate.DEFAULT_WORKING_DIR, containerWorkingDirStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,23 @@ public void jnlpWorkingDir() throws Exception {
r.assertBuildStatusSuccess(r.waitForCompletion(b));
}

@Issue("JENKINS-60517")
@Test
public void runInDynamicallyCreatedContainer() throws Exception {
List<PodTemplate> templates = cloud.getTemplates();
while (templates.isEmpty()) {
LOGGER.log(Level.INFO, "Waiting for template to be created");
templates = cloud.getTemplates();
Thread.sleep(1000);
}
assertFalse(templates.isEmpty());
PodTemplate template = templates.get(0);
assertEquals(Integer.MAX_VALUE, template.getInstanceCap());
r.assertBuildStatusSuccess(r.waitForCompletion(b));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently failing for me locally in Microk8s (noticed while testing #1083); the build fails in docker run with

docker: Error response from daemon: cgroups: cgroup mountpoint does not exist: unknown.

Perhaps because Microk8s is now using cgroup v2, and docker:19-dind is assuming v1? Need to figure out how to Assume that the environment is capable of running DinD pods, at least with the specified image version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also failing locally when I run tests in #1275, but apparently not in CI.

r.assertLogContains("whoami", b);
r.assertLogContains("root", b);
}

@Issue("JENKINS-57256")
@Test
public void basicWindows() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
timeout ([time: 10, unit: 'MINUTES']) {
def label = "jenkins-slave-${UUID.randomUUID().toString()}"
podTemplate(
label: label,
yaml: '''
spec:
containers:
- name: jnlp
''',
containers: [
containerTemplate(name: 'jnlp',
image: 'jenkins/jnlp-slave:latest',
alwaysPullImage: true,
args: '${computer.jnlpmac} ${computer.name}',
),
containerTemplate(
name: 'docker-dind',
image: 'docker:19-dind',
alwaysPullImage: true,
privileged: true,
envVars: [
envVar(key: 'DOCKER_TLS_CERTDIR', value: '')
],
),
containerTemplate(
name: 'docker',
image: 'docker:19',
alwaysPullImage: true,
ttyEnabled: true,
command: 'cat',
envVars: [
envVar(key: 'DOCKER_HOST', value: 'tcp://localhost:2375')
],
),
]
) {
node(label) {
stage('build') {
container('docker') {
sh 'echo "FROM ubuntu:bionic" > Dockerfile'

def tag = "test:${env.BUILD_ID}".toLowerCase()
devTools = docker.build(tag, "--pull -f Dockerfile .")

devTools.inside() {
sh 'whoami'
}
}
}
}
}
}