Kubernetes Plugin

56 views
Skip to first unread message

Pedro Januário

unread,
Aug 24, 2017, 12:37:54 PM8/24/17
to Jenkins Users
Hi,

I am using Jenkins Pipeline with Kubernetes Plugin and doing something really simple just to build a container and run the container to execute the tests on it.

While doing it I got a error that shows exit -2 without another information, currently I am just doing a echo.

Example (just part of it):

def containersForUnitTest = [
  containerTemplate(name: 'mongotest',
                  image: 'mongo:3.2.4',
                  ttyEnabled: true, command: 'mongod --smallfiles',
                  resourceLimitCpu: '150m',
                  resourceRequestCpu: '100m',
                  resourceRequestMemory: '512Mi',
                  resourceLimitMemory: '512Mi',
                  alwaysPullImage: false),
  containerTemplate(name: 'microservice',
                  image: "..myimage...",
                  ttyEnabled: true, command: 'cat',
                  resourceLimitCpu: '150m',
                  resourceRequestCpu: '100m',
                  resourceRequestMemory: '512Mi',
                  resourceLimitMemory: '512Mi')
]

podTemplate(name: "test", inheritFrom: 'jnlp', label: test", containers: containersForUnitTest) {
  node("some") {
    stage('Test') {
      try {
        container('microservice') {
          sh """
           echo "this is my echo thing"
          """
        }
      }
      catch (Exception e) {
        echo "microservice error: ${e}"
        throw e
      }
    }
  }
}

If I add the following line to my dockerfile it will run successfully, this seems a awkward behaviour that seems to be related with permissions on the container execution. Don't see any other way to workaround this but it seems undesired.

RUN chown node:node $APP_DIR \
  && echo http://dl-cdn.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories \
  && apk --no-cache add shadow && usermod -u 10000 node

Any clue? Is there anything that can cause this?

Carlos Sanchez

unread,
Aug 24, 2017, 12:43:19 PM8/24/17
to Jenkins Users
I've seen it reported before.
Check your pod logs, events and exit codes

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b921176c-33ca-48c2-a06e-a673aa6f6e72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bob

unread,
Nov 5, 2017, 8:36:19 PM11/5/17
to Jenkins Users
I'm seeing this same issue as well: "ERROR: script returned exit code -2". I've looked for more info in the pod logs as Carlos suggested but wasn't able to find anything helpful.

If I remove the container element and nest sh under node it works. Do I need to make sure the jenkins user (10000) is available in all the containers for the pod?  I have been pretty stuck here so appreciate any help.


def label = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_').replace('/', '_')

podTemplate(label: label, cloud: 'kubernetes', containers: [
    containerTemplate(
      name: 'jnlp',
      image: <internal_registry>/'jenkinsci/jnlp-slave:3.10-1-alpine',
      args: '${computer.jnlpmac} ${computer.name}',
      ttyEnabled: true),
    containerTemplate(
      name: 'maven', 
      image: '<internal_registry>/maven:3.5.0-jdk-8-alpine', 
      ttyEnabled: true, command: 'cat',
      resourceRequestCpu: '100m',
      resourceLimitMemory: '1200Mi')
    ]) {

    node(label) {
      container('maven') {
          sh 'date'
      }
    }
  }
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages