uber-archive / makisu

Fast and flexible Docker image building tool, works in unprivileged containerized environments like Mesos and Kubernetes.
Apache License 2.0
2.41k stars 156 forks source link

Makisu builds on Jenkins Kubernetes hanging #342

Closed jeffj254 closed 3 years ago

jeffj254 commented 3 years ago

Describe the bug I'm trying to build a dockerfile using Makisu on a Jenkins instance running on Kubernetes with a declarative pipeline. The build and image push are successful, but the job then hangs and doesn't complete successfully. Eventually Jenkins will terminate the job with a message

(JENKINS-48300: if on an extremely laggy filesystem, consider -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.HEARTBEAT_CHECK_INTERVAL=86400)

To Reproduce Run a Jenkins pipeline job on Kubernetes with this declarative pipeline example:

pipeline {
  agent {
    kubernetes {
      //cloud 'kubernetes'
      defaultContainer 'makisu'
      yaml """
kind: Pod
spec:
  containers:
  - name: makisu
    image: gcr.io/uber-container-tools/makisu-alpine:v0.2.0
    imagePullPolicy: Always
    tty: true
    command:
      - cat
    volumeMounts:
      - name: registry-config
        mountPath: /registry-config
  volumes:
  - name: registry-config
    secret:
      secretName: makisu-test
"""
    }
  }
  stages {
    stage('Build with Makisu') {
      steps {
        git credentialsId: 'github', url: 'https://<dockerfile repo>', branch: 'jefftest'
        sh '/makisu-internal/makisu build --push=<private registry> --modifyfs=true -t=jeffmaktest:0.2 --registry-config=/registry-config/creds.yaml --file simple-test/dockerfile .'
      }
    }
  }
}

The dockerfile I am building is:

FROM amazonlinux:2

RUN mkdir test2
RUN yum install -y vim

Expected behavior Image is built, pushed to private registry, and Jenkins job returns as successful

Environments Kubernetes, specifically EKS v1.16 Jenkins v2.235.3 Jenkins Kubernetes plugin 1.25.7 Makisu-alpine image tag v0.2.0

Additional context I have tried to kubectl exec into the running container while it is stalled, but I always get an error that my command is not in the PATH. Makisu-alpine has a shell in it, and I can "docker run" the image just fine, but for some reason doing a kubectl exec /bin/sh does not work.

jfrabaute commented 3 years ago

Try to add --preserve-root flag in your cli command. (Related PR: https://github.com/uber/makisu/pull/219)

jeffj254 commented 3 years ago

That worked! Thanks!