jenkinsci / docker-plugin

Jenkins cloud plugin that uses Docker
https://plugins.jenkins.io/docker-plugin/
MIT License
490 stars 318 forks source link

Duplicated slaves spawned #1083

Open kamilpi opened 3 months ago

kamilpi commented 3 months ago

Jenkins and plugins versions report

Jenkins: 2.440.2 OS: Linux - 5.15.0-112-generic Java: 17.0.10 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)

ace-editor:1.1 allure-jenkins-plugin:2.31.1 analysis-model-api:12.1.0 anchore-container-scanner:3.0.0 ansicolor:1.0.4 ant:497.v94e7d9fffa_b_9 antisamy-markup-formatter:162.v0e6ec0fcfcf6 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 apache-httpcomponents-client-5-api:5.3.1-1.0 appcenter:0.11.1 artifactory:4.0.6 asm-api:9.7-33.v4d23ef79fcc8 atlassian-bitbucket-server-integration:4.0.0 authentication-tokens:1.53.v1c90fd9191ab authorize-project:1.7.1 bitbucket-approve:1.0.3 bitbucket-build-status-notifier:1.4.2 bitbucket-push-and-pull-request:3.0.2 blueocean:1.27.11 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.27.13 blueocean-commons:1.27.13 blueocean-config:1.27.11 blueocean-core-js:1.27.13 blueocean-dashboard:1.27.11 blueocean-display-url:2.4.2 blueocean-events:1.27.11 blueocean-git-pipeline:1.27.11 blueocean-github-pipeline:1.27.11 blueocean-i18n:1.27.11 blueocean-jira:1.27.11 blueocean-jwt:1.27.13 blueocean-personalization:1.27.11 blueocean-pipeline-api-impl:1.27.13 blueocean-pipeline-editor:1.27.11 blueocean-pipeline-scm-api:1.27.13 blueocean-rest:1.27.13 blueocean-rest-impl:1.27.13 blueocean-web:1.27.13 bootstrap5-api:5.3.3-1 bouncycastle-api:2.30.1.78.1-233.vfdcdeb_0a_08aa branch-api:2.1152.v6f101e97dd77 build-user-vars-plugin:1.9 caffeine-api:3.1.8-133.v17b1ff2e0599 checks-api:2.2.0 cloud-stats:336.v788e4055508b cloudbees-bitbucket-branch-source:883.v041fa_695e9c2 cloudbees-disk-usage-simple:203.v3f46a_7462b1a cloudbees-folder:6.901.vb_4c7a_da_75da_3 command-launcher:107.v773860566e2e commons-lang3-api:3.13.0-62.v7d18e55f51e2 commons-text-api:1.11.0-95.v22a_d30ee5d36 config-file-provider:968.ve1ca_eb_913f8c configuration-as-code:1775.v810dc950b_514 credentials:1337.v60b_d7b_c7b_c9f credentials-binding:657.v2b_19db_7d6e6d data-tables-api:2.0.3-1 delivery-pipeline-plugin:1.4.2 dependency-check-jenkins-plugin:5.5.0 display-url-api:2.200.vb_9327d658781 docker-commons:439.va_3cb_0a_6a_fb_29 docker-java-api:3.3.6-90.ve7c5c7535ddd docker-plugin:1.6.2 docker-swarm:1.11 docker-workflow:572.v950f58993843 durable-task:555.v6802fe0f0b_82 echarts-api:5.5.0-1 eddsa-api:0.3.0-4.v84c6f0f4969e email-ext:2.105 emailext-template:1.5 environment-script:100.v3a_f1a_6a_b_7549 extended-read-permission:53.v6499940139e5 favorite:2.208.v91d65b_7792a_c file-parameters:316.va_83a_1221db_a_7 font-awesome-api:6.5.1-3 forensics-api:2.4.0 gatling:1.2.8 git:5.2.1 git-client:4.7.0 github:1.38.0 github-api:1.318-461.v7a_c09c9fa_d63 github-branch-source:1785.v99802b_69816c gradle:2.10 gson-api:2.10.1-15.v0d99f670e0a_7 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-30.v7e777411b_148 htmlpublisher:1.33 http_request:1.18 instance-identity:185.v303dc7c645f9 ionicons-api:74.v93d5eb_813d5f ivy:2.5 jackson2-api:2.17.0-379.v02de8ec9f64c jacoco:3.3.5 jakarta-activation-api:2.1.3-1 jakarta-mail-api:2.1.3-1 javadoc:243.vb_b_503b_b_45537 javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.9-1 jdk-tool:73.vddf737284550 jenkins-design-language:1.27.13 jersey2-api:2.42-147.va_28a_44603b_d5 jgiven:0.15.1 jira:3.13 jira-steps:2.0.165.v8846cf59f3db jjwt-api:0.11.5-112.ve82dfb_224b_a_d jmh-report:0.9.0 job-dsl:1.87 joda-time-api:2.12.7-29.v5a_b_e3a82269a jquery:1.12.4-1 jquery-detached:1.2.1 jquery3-api:3.7.1-2 jsch:0.2.16-86.v42e010d9484b_ json-api:20240303-41.v94e11e6de726 json-path-api:2.9.0-58.v62e3e85b_a_655 junit:1265.v65b_14fa_f12f0 ldap:719.vcb_d039b_77d0d lockable-resources:1246.v28b_e4cc6fa_16 mailer:472.vf7c289a_4b_420 matrix-auth:3.2.2 matrix-project:822.824.v14451b_c0fd42 maven-plugin:3.23 mercurial:1260.vdfb_723cdcc81 metrics:4.2.21-449.v6960d7c54c69 mina-sshd-api-common:2.12.1-101.v85b_e08b_780dd mina-sshd-api-core:2.12.1-101.v85b_e08b_780dd momentjs:1.1.1 multi-branch-project-plugin:0.7 multiple-scms:0.8 okhttp-api:4.11.0-172.vda_da_1feeb_c6e parameterized-scheduler:262.v00f3d90585cc parameterized-trigger:787.v665fcf2a830b pipeline-build-step:540.vb_e8849e1a_b_d8 pipeline-graph-analysis:216.vfd8bece330ca pipeline-groovy-lib:704.vc58b_8890a_384 pipeline-input-step:491.vb_07d21da_1afb pipeline-milestone-step:119.vdfdc43fc3b9a pipeline-model-api:2.2198.v41dd8ef6dd56 pipeline-model-declarative-agent:1.1.1 pipeline-model-definition:2.2198.v41dd8ef6dd56 pipeline-model-extensions:2.2198.v41dd8ef6dd56 pipeline-rest-api:2.34 pipeline-stage-step:312.v8cd10304c27a_ pipeline-stage-tags-metadata:2.2198.v41dd8ef6dd56 pipeline-stage-view:2.34 pipeline-utility-steps:2.16.2 plain-credentials:179.vc5cb_98f6db_38 plugin-util-api:4.1.0 popper2-api:2.11.6-4 prism-api:1.29.0-13 prometheus:2.5.3 pubsub-light:1.18 rebuild:332.va_1ee476d8f6d resource-disposer:0.23 role-strategy:713.vb_3837801b_8cc saml:4.464.vea_cb_75d7f5e0 scm-api:689.v237b_6d3a_ef7f script-security:1326.vdb_c154de8669 snakeyaml-api:2.2-111.vc6598e30cc65 sonar:2.17.2 sse-gateway:1.26 ssh-agent:346.vda_a_c4f2c8e50 ssh-credentials:337.v395d2403ccd4 ssh-slaves:2.973.v0fa_8c0dea_f9f sshd:3.322.v159e91f6a_550 stash-pullrequest-builder:1.17 stashNotifier:1.464.va_9203f84a_417 structs:337.v1b_04ea_4df7c8 swarm:3.44 timestamper:1.26 token-macro:400.v35420b922dcb trilead-api:2.147.vb_73cc728a_32e variant:60.v7290fc0eb_b_cd warnings-ng:11.2.2 windows-slaves:1.8.1 workflow-api:1316.v33eb_726c50ba workflow-basic-steps:1049.v257a_e6b_30fb_d workflow-cps:3894.vd0f0248b_a_fc4 workflow-durable-task-step:1336.v768003e07199 workflow-job:1400.v7fd111b_ec82f workflow-multibranch:773.vc4fe1378f1d5 workflow-scm-step:427.v4ca_6512e7df1 workflow-step-api:657.v03be8115821b workflow-support:907.v6713a_ed8a_573 ws-cleanup:0.45 zap:1.1.0 zapper:1.0.7

What Operating System are you using (both controller, and any agents involved in the problem)?

Ubuntu 22

Reproduction steps

  1. Run this pipeline

    
    #!/usr/bin/env groovy
    pipeline {
    agent none
    environment {
        CUSTOM_WS = "/home/jenkins/workspace/check${new Date().format('yyyyMMdd')}-${System.currentTimeMillis()}"
    }
    options {
        buildDiscarder logRotator(numToKeepStr: '30')
    }
    stages {
        stage('Check') {
            agent {
                node {
                    label "cc"
                    customWorkspace CUSTOM_WS
                }
            }
            steps {
                sh "printenv"
    
            }
            post {
                cleanup {
                    cleanWs disableDeferredWipeout: true, notFailBuild: true, deleteDirs: true
                }
            }
        }
    }
    }

The label is in my Cloud config templates.

### Expected Results

One slave is provisioned.

### Actual Results

Two slaves are provisioned for ~10 seconds, then one of them is used and the second one is destroyed.

### Anything else?

Cloud config:

jenkins: agentProtocols:

Logs:

Are you interested in contributing a fix?

No response