Kubernetes Plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Kubernetes Plugin

Pedro Januário
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?

--
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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: Kubernetes Plugin

Carlos Sanchez
I've seen it reported before.
Check your pod logs, events and exit codes

On Thu, Aug 24, 2017 at 6:35 PM, Pedro Januário <[hidden email]> wrote:
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?

--
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 [hidden email].
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.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6MuQuzz7N4FSdrhvCEXjoOx5C%3DU3s57%2BmdCM40HNbonag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Kubernetes Plugin

Bob-5
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'
      }
    }
  }


On Thursday, August 24, 2017 at 9:43:19 AM UTC-7, Carlos Sanchez wrote:
I've seen it reported before.
Check your pod logs, events and exit codes

On Thu, Aug 24, 2017 at 6:35 PM, Pedro Januário <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ypNM1PdtAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ped...@...> wrote:
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 <a href="http://dl-cdn.alpinelinux.org/alpine/edge/community/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdl-cdn.alpinelinux.org%2Falpine%2Fedge%2Fcommunity%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFrhN9ve3BsAuQDFqkq0izkl2m4_Q&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdl-cdn.alpinelinux.org%2Falpine%2Fedge%2Fcommunity%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFrhN9ve3BsAuQDFqkq0izkl2m4_Q&#39;;return true;">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?

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ypNM1PdtAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/b921176c-33ca-48c2-a06e-a673aa6f6e72%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/b921176c-33ca-48c2-a06e-a673aa6f6e72%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/b921176c-33ca-48c2-a06e-a673aa6f6e72%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/b921176c-33ca-48c2-a06e-a673aa6f6e72%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1aba8dbe-40ee-4a31-a8ba-5dddd1fbf135%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.