From 685f669a1b8e3c7deab277a30e12e171cf6b802a Mon Sep 17 00:00:00 2001 From: rahulguptajss Date: Mon, 4 Nov 2024 11:36:22 +0530 Subject: [PATCH 1/3] ci: add docker login for smoke tests --- integration/Jenkinsfile | 12 +++++++++++- jenkins/artifacts/jenkinsfile | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/integration/Jenkinsfile b/integration/Jenkinsfile index d9814085f..70c6bb78f 100644 --- a/integration/Jenkinsfile +++ b/integration/Jenkinsfile @@ -53,6 +53,7 @@ pipeline { cleanWs() stopAndRemoveDockers() setupWorkspace() + dockerLogin() } } stage('Install NATIVE pkg') { @@ -111,6 +112,7 @@ pipeline { cleanWs() stopAndRemoveDockers() setupWorkspace() + dockerLogin() } } stage('Install RPM pkg') { @@ -166,6 +168,7 @@ pipeline { cleanWs() stopAndRemoveDockers() setupWorkspace() + dockerLogin() } } stage('Install Docker') { @@ -226,6 +229,7 @@ pipeline { cleanWs() stopAndRemoveDockers() setupWorkspace() + dockerLogin() } } stage('Install Docker FIPS') { @@ -284,7 +288,7 @@ def void stopAndRemoveDockers() { sh ''' for container_id in $(docker ps -a -q);do docker stop $container_id;done for container_id in $(docker ps -a -q);do docker rm $container_id;done - docker system prune --force --volumes + docker system prune --all --force --volumes volumes=$(docker volume ls -qf dangling=true) if [ "$volumes" ]; then docker volume rm $volumes @@ -308,4 +312,10 @@ def void printNodeInfo() { socket.connect(InetAddress.getByName("8.8.8.8"), 10002); nodeIp = socket.getLocalAddress().getHostAddress(); println("The Node IP Address is: ${nodeIp}") +} + +def void dockerLogin() { + withDockerRegistry([credentialsId: "DockerHub", url: ""]) { + sh 'docker login' + } } \ No newline at end of file diff --git a/jenkins/artifacts/jenkinsfile b/jenkins/artifacts/jenkinsfile index 325cdb258..f906566bc 100644 --- a/jenkins/artifacts/jenkinsfile +++ b/jenkins/artifacts/jenkinsfile @@ -384,7 +384,7 @@ def void stopAndRemoveDockers() { rm -rf /opt/home/nightly/ mkdir -p /opt/home/nightly/ for container_id in $(docker ps -a -q);do docker stop $container_id;done - docker system prune --force --volumes + docker system prune --all --force --volumes volumes=$(docker volume ls -qf dangling=true) if [ "$volumes" ]; then docker volume rm $volumes From ee5b4e93ec8007ee3e88cd2dc17fbb59f5e47247 Mon Sep 17 00:00:00 2001 From: rahulguptajss Date: Mon, 4 Nov 2024 12:32:45 +0530 Subject: [PATCH 2/3] ci: add docker login for smoke tests --- integration/Jenkinsfile | 42 ++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/integration/Jenkinsfile b/integration/Jenkinsfile index 70c6bb78f..e10d57f1d 100644 --- a/integration/Jenkinsfile +++ b/integration/Jenkinsfile @@ -1,12 +1,14 @@ +import java.util.Random + pipeline { agent none options { buildDiscarder logRotator( - daysToKeepStr: '16', - numToKeepStr: '10' - ) + daysToKeepStr: '16', + numToKeepStr: '10' + ) } parameters { string(name: 'VERSION', defaultValue: '', description: 'Version') @@ -53,7 +55,9 @@ pipeline { cleanWs() stopAndRemoveDockers() setupWorkspace() - dockerLogin() + retryWithBackoff(3) { + dockerLogin() + } } } stage('Install NATIVE pkg') { @@ -112,7 +116,9 @@ pipeline { cleanWs() stopAndRemoveDockers() setupWorkspace() - dockerLogin() + retryWithBackoff(3) { + dockerLogin() + } } } stage('Install RPM pkg') { @@ -168,7 +174,9 @@ pipeline { cleanWs() stopAndRemoveDockers() setupWorkspace() - dockerLogin() + retryWithBackoff(3) { + dockerLogin() + } } } stage('Install Docker') { @@ -229,7 +237,9 @@ pipeline { cleanWs() stopAndRemoveDockers() setupWorkspace() - dockerLogin() + retryWithBackoff(3) { + dockerLogin() + } } } stage('Install Docker FIPS') { @@ -318,4 +328,22 @@ def void dockerLogin() { withDockerRegistry([credentialsId: "DockerHub", url: ""]) { sh 'docker login' } +} + +def void retryWithBackoff(int retries, Closure body) { + int attempt = 0 + Random random = new Random() + while (attempt < retries) { + try { + body.call() + return + } catch (Exception e) { + attempt++ + if (attempt >= retries) { + throw e + } + int randomDelay = random.nextInt(10000) // Random delay between 0 and 15000 milliseconds (0 to 10 seconds) + sleep((30 * 1000 * attempt) + randomDelay) // Exponential backoff with random delay + } + } } \ No newline at end of file From 11bd1a4ee3329746b96b53199f58db0e20f2d8b8 Mon Sep 17 00:00:00 2001 From: rahulguptajss Date: Mon, 4 Nov 2024 13:04:12 +0530 Subject: [PATCH 3/3] ci: add docker login for smoke tests --- integration/Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/integration/Jenkinsfile b/integration/Jenkinsfile index e10d57f1d..7f64641c0 100644 --- a/integration/Jenkinsfile +++ b/integration/Jenkinsfile @@ -342,8 +342,10 @@ def void retryWithBackoff(int retries, Closure body) { if (attempt >= retries) { throw e } - int randomDelay = random.nextInt(10000) // Random delay between 0 and 15000 milliseconds (0 to 10 seconds) - sleep((30 * 1000 * attempt) + randomDelay) // Exponential backoff with random delay + int randomDelay = random.nextInt(15) // Random delay between 0 and 15 seconds + int backoffTime = 30 + randomDelay // Base backoff of 30 seconds plus random delay + println("Retry attempt ${attempt}, sleeping for ${backoffTime} seconds") + sleep time: backoffTime, unit: 'SECONDS' } } } \ No newline at end of file