Jenkins从属JNLP4-连接超时

时间:2018-11-16 15:00:40

标签: jenkins jnlp

我在Jenkins的某些工作中看到了此错误

Cannot contact jenkins-slave-l65p0-0f7m0: hudson.remoting.ChannelClosedException: Channel "unknown": Remote call on JNLP4-connect connection from 100.99.111.187/100.99.111.187:46776 failed. The channel is closing down or has closed down

我有一个詹金斯大师-奴隶设置。

在从属服务器上找到以下日志

java.nio.channels.ClosedChannelException
    at org.jenkinsci.remoting.protocol.NetworkLayer.onRecvClosed(NetworkLayer.java:154)
    at org.jenkinsci.remoting.protocol.impl.NIONetworkLayer.ready(NIONetworkLayer.java:142)
    at org.jenkinsci.remoting.protocol.IOHub$OnReady.run(IOHub.java:795)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Jenkins位于kubernetes集群上。

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  namespace: default
  name: jenkins-deployment
spec:
  serviceName: "jenkins-pod"
  replicas: 1
  template:
    metadata:
      labels:
        app: jenkins-pod
    spec:
      initContainers:
      - name: volume-mount-hack
        image: busybox
        command: ["sh", "-c", "chmod -R 777 /usr/mnt"]
        volumeMounts:
        - name: jenkinsdir
          mountPath: /usr/mnt
      containers:
      - name: jenkins-container
         imagePullPolicy: Always
        readinessProbe:
          exec:
            command:
              - curl
              - http://localhost:8080/login
              - -o
              - /dev/null
        livenessProbe:
          httpGet:
            path: /login
            port: 8080
          initialDelaySeconds: 120
          periodSeconds: 10
        env:
         - name: JAVA_OPTS
           value: "-Dhudson.slaves.NodeProvisioner.initialDelay=0 -Dhudson.slaves.NodeProvisioner.MARGIN=50 -Dhudson.slaves.NodeProvisioner.MARGIN0=0.85"
        resources:
          requests:
            memory: "7100Mi"
            cpu: "2000m"
        ports:
        - name: http-port
          containerPort: 8080
        - name: jnlp-port
          containerPort: 50000
        volumeMounts:
          - mountPath: /var/run
            name: docker-sock
          - mountPath: /var/jenkins_home
            name: jenkinsdir
      volumes:
        - name: jenkinsdir
          persistentVolumeClaim:
            claimName: "jenkins-persistence"
        - name: docker-sock
          hostPath:
            path: /var/run
---
apiVersion: v1
kind: Service
metadata:
  namespace: default
  name: jenkins
  labels:
    app: jenkins
spec:
  type: NodePort
  ports:
  - name: http
    port: 8080
    targetPort: 8080
    nodePort: 30099
    protocol: TCP
  selector:
    app: jenkins-pod
---
apiVersion: v1
kind: Service
metadata:
  namespace: default
  name: jenkins-external
  annotations:
        service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
  labels:
    app: jenkins
spec:
  type: LoadBalancer
  ports:
  - name: http
    port: 8080
    targetPort: 8080
    protocol: TCP
  selector:
    app: jenkins-pod
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  name: jenkins-master-pdb
  namespace: default
spec:
  maxUnavailable: 0
  selector:
    matchLabels:
      app: jenkins-pod
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  name: jenkins-slave-pdb
  namespace: default
spec:
  maxUnavailable: 0
  selector:
    matchLabels:
      jenkins: slave
---
kind: Service
apiVersion: v1
metadata:
  name: jenkins-discovery
  namespace: default
  labels:
    app: jenkins
spec:
  selector:
    app: jenkins-pod
  ports:
    - protocol: TCP
      port: 50000
      targetPort: 50000
      name: slaves

我怀疑这与kubernetes有什么关系,但仍然没有解决。

3 个答案:

答案 0 :(得分:1)

我假设您正在使用Jenkins Kubernetes Plugin

您可以在Timeout in seconds for Jenkins connection下增加Kubernetes Pod template。它可以解决您的问题。

Timeout in seconds for Jenkins connection的描述:

  

以秒为单位指定Jenkins应该等待JNLP的时间   代理建立连接。值应为正整数,   默认值为100。

答案 1 :(得分:0)

您是否在Jenkins本身中配置了JNLP端口?它位于“管理Jenkins”>“配置全局安全性”>“代理”中。单击“固定”单选按钮(因为您已经分配了TCP端口)。将“ JNLP代理的TCP端口”设置为50000。

答案 2 :(得分:0)