Browse code

Jenkinsfile: add cgroup2

Thanks to Stefan Scherer for setting up the Jenkins nodes.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit c23b99f4db3a1c150c346f754478d4326a949279)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Akihiro Suda authored on 2021/01/23 23:36:23
Showing 1 changed files
... ...
@@ -12,6 +12,7 @@ pipeline {
12 12
         booleanParam(name: 'validate_force', defaultValue: false, description: 'force validation steps to be run, even if no changes were detected')
13 13
         booleanParam(name: 'amd64', defaultValue: true, description: 'amd64 (x86_64) Build/Test')
14 14
         booleanParam(name: 'rootless', defaultValue: true, description: 'amd64 (x86_64) Build/Test (Rootless mode)')
15
+        booleanParam(name: 'cgroup2', defaultValue: true, description: 'amd64 (x86_64) Build/Test (cgroup v2)')
15 16
         booleanParam(name: 'arm64', defaultValue: true, description: 'ARM (arm64) Build/Test')
16 17
         booleanParam(name: 's390x', defaultValue: true, description: 'IBM Z (s390x) Build/Test')
17 18
         booleanParam(name: 'ppc64le', defaultValue: true, description: 'PowerPC (ppc64le) Build/Test')
... ...
@@ -460,6 +461,89 @@ pipeline {
460 460
                     }
461 461
                 }
462 462
 
463
+                stage('cgroup2') {
464
+                    when {
465
+                        beforeAgent true
466
+                        expression { params.cgroup2 }
467
+                    }
468
+                    agent { label 'amd64 && ubuntu-2004 && cgroup2' }
469
+                    stages {
470
+                        stage("Print info") {
471
+                            steps {
472
+                                sh 'docker version'
473
+                                sh 'docker info'
474
+                            }
475
+                        }
476
+                        stage("Build dev image") {
477
+                            steps {
478
+                                sh '''
479
+                                docker build --force-rm --build-arg APT_MIRROR --build-arg SYSTEMD=true -t docker:${GIT_COMMIT} .
480
+                                '''
481
+                            }
482
+                        }
483
+                        stage("Integration tests") {
484
+                            environment {
485
+                                DOCKER_SYSTEMD = '1' // recommended cgroup driver for v2
486
+                                TEST_SKIP_INTEGRATION_CLI = '1' // CLI tests do not support v2
487
+                            }
488
+                            steps {
489
+                                sh '''
490
+                                docker run --rm -t --privileged \
491
+                                  -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
492
+                                  --name docker-pr$BUILD_NUMBER \
493
+                                  -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
494
+                                  -e DOCKER_GRAPHDRIVER \
495
+                                  -e DOCKER_EXPERIMENTAL \
496
+                                  -e DOCKER_SYSTEMD \
497
+                                  -e TEST_SKIP_INTEGRATION_CLI \
498
+                                  -e TIMEOUT \
499
+                                  -e VALIDATE_REPO=${GIT_URL} \
500
+                                  -e VALIDATE_BRANCH=${CHANGE_TARGET} \
501
+                                  docker:${GIT_COMMIT} \
502
+                                  hack/make.sh \
503
+                                    dynbinary \
504
+                                    test-integration
505
+                                '''
506
+                            }
507
+                            post {
508
+                                always {
509
+                                    junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
510
+                                }
511
+                            }
512
+                        }
513
+                    }
514
+
515
+                    post {
516
+                        always {
517
+                            sh '''
518
+                            echo "Ensuring container killed."
519
+                            docker rm -vf docker-pr$BUILD_NUMBER || true
520
+                            '''
521
+
522
+                            sh '''
523
+                            echo "Chowning /workspace to jenkins user"
524
+                            docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
525
+                            '''
526
+
527
+                            catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
528
+                                sh '''
529
+                                bundleName=amd64-cgroup2
530
+                                echo "Creating ${bundleName}-bundles.tar.gz"
531
+                                # exclude overlay2 directories
532
+                                find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*-report.json' -o -name '*.log' -o -name '*.prof' -o -name '*-report.xml' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
533
+                                '''
534
+
535
+                                archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
536
+                            }
537
+                        }
538
+                        cleanup {
539
+                            sh 'make clean'
540
+                            deleteDir()
541
+                        }
542
+                    }
543
+                }
544
+
545
+
463 546
                 stage('s390x') {
464 547
                     when {
465 548
                         beforeAgent true