From 45d9ba5237c871cbd781748014c8c089167d324b Mon Sep 17 00:00:00 2001 From: Rinku Kothiya Date: Sat, 16 Jul 2022 20:01:52 +0530 Subject: [PATCH] CORTX-32897: Support default parameters for pre-merge job Since Motr-Hare-Single-Node-Cluster-Deployment-On-Rocky-Linux will be used as a pre merge job we need to remove the parameters that it accepts and run the job on dedicated machines. Signed-off-by: Rinku Kothiya --- .../usr/libexec/cortx-motr/motr-cleanup | 4 +- .../jenkins/motr-hare-1node-cluster.groovy | 100 +++++++++++++----- 2 files changed, 76 insertions(+), 28 deletions(-) diff --git a/scripts/install/usr/libexec/cortx-motr/motr-cleanup b/scripts/install/usr/libexec/cortx-motr/motr-cleanup index 268f17faeca..3f29ed4b16f 100755 --- a/scripts/install/usr/libexec/cortx-motr/motr-cleanup +++ b/scripts/install/usr/libexec/cortx-motr/motr-cleanup @@ -43,7 +43,7 @@ for s in m0d@* m0t1fs@* motr-client motr-kernel motr-mkfs motr-mkfs@* motr-serve motr_services="$motr_services $s.service" done -systemctl list-units --all $motr_services +systemctl list-units --all $motr_services | tee m0_log 'Stopping motr-kernel with all dependencies ...' systemctl stop motr-kernel || m0_exit 'Failed to stop motr-kernel.' @@ -51,7 +51,7 @@ systemctl stop motr-kernel || m0_exit 'Failed to stop motr-kernel.' m0_log 'Stopping all Motr services ...' systemctl stop $motr_services || m0_exit 'Failed to stop Motr services.' -systemctl list-units --all $motr_services +systemctl list-units --all $motr_services | tee for s in $(systemctl list-units --failed $motr_services | awk '/failed/ {if ($4 == "failed") print $2}'); do m0_log "Resetting failed state for $s." diff --git a/scripts/jenkins/motr-hare-1node-cluster.groovy b/scripts/jenkins/motr-hare-1node-cluster.groovy index 85165daa603..a110dfac821 100644 --- a/scripts/jenkins/motr-hare-1node-cluster.groovy +++ b/scripts/jenkins/motr-hare-1node-cluster.groovy @@ -1,57 +1,105 @@ #!/usr/bin/env groovy -pipeline { +pipeline { agent { node { - label 'ssc-vm-g3-rhev4-1327' + label 'sncr' } } - - parameters { - string(name: 'NODE_HOST', defaultValue: '', description: 'Node 1 Host FQDN', trim: true) - string(name: 'NODE_USER', defaultValue: '', description: 'Host machine root user', trim: true) - string(name: 'NODE_PASS', defaultValue: '', description: 'Host machine root user password', trim: true) - } options { timeout(time: 180, unit: 'MINUTES') timestamps() - ansiColor('xterm') + ansiColor('xterm') buildDiscarder(logRotator(numToKeepStr: "30")) } + parameters { + string(name: 'MOTR_REPO', defaultValue: 'https://github.com/Seagate/cortx-motr', description: 'Repo to be used for Motr build.') + string(name: 'MOTR_BRANCH', defaultValue: 'main', description: 'Branch to be used for Motr build.') + } + environment { - NODE_PASS = "${NODE_PASS.isEmpty() ? NODE_DEFAULT_SSH_CRED_PSW : NODE_PASS}" + release_tag = "last_successful_prod" + REPO_NAME = 'cortx-motr' + GITHUB_TOKEN = credentials('cortx-admin-github') // To clone cortx-motr repo + GPR_REPO = "https://github.com/${ghprbGhRepository}" + MOTR_REPO = "${ghprbGhRepository != null ? GPR_REPO : MOTR_REPO}" + MOTR_BRANCH = "${sha1 != null ? sha1 : MOTR_BRANCH}" + MOTR_GPR_REFSPEC = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" + MOTR_BRANCH_REFSPEC = "+refs/heads/*:refs/remotes/origin/*" + MOTR_PR_REFSPEC = "${ghprbPullId != null ? MOTR_GPR_REFSPEC : MOTR_BRANCH_REFSPEC}" + repoURL = "${MOTR_REPO}".replace("github.com", "$GITHUB_TOKEN@github.com") } stages { - stage('Checkout') { + stage ('Cleanup VM') { steps { - checkout([$class: 'GitSCM', branches: [[name: "main"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PathRestriction', excludedRegions: '', includedRegions: 'scripts/third-party-rpm/.*']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'cortx-admin-github', url: "https://github.com/Seagate/cortx-motr"]]]) + checkout([$class: 'GitSCM', branches: [[name: "${MOTR_BRANCH}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false, timeout: 5], [$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: false, reference: '', trackingSubmodules: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'cortx-admin-github', url: "${MOTR_REPO}", name: 'origin', refspec: "${MOTR_PR_REFSPEC}"]]]) + script { + sh label: 'Clean up VM before use', script: ''' + hostname + pwd + cd "$WORKSPACE" + #ln -s "$WORKSPACE" "$WORKSPACE/../cortx-motr" + ./scripts/install/usr/libexec/cortx-motr/motr-cleanup || true + losetup -D + make uninstall || true + cd "$WORKSPACE/../cortx-hare" || true + make uninstall || true + cd "$WORKSPACE/.." + rm -rf cortx-hare cortx-motr + yum remove cortx-hare cortx-motr{,-devel} cortx-py-utils consul -y + rm -rf /var/crash/* /var/log/seagate/* /var/log/hare/* /var/log/motr/* /var/lib/hare/* /var/motr/* /etc/motr/* + rm -rf /root/.cache/dhall* /root/rpmbuild + rm -rf /etc/yum.repos.d/motr_last_successful.repo /etc/yum.repos.d/motr_uploads.repo /etc/yum.repos.d/lustre_release.repo + ''' + } } } - stage ('Build rpm packages') { + + stage ('Create Single node cluster') { steps { - script { build_stage = env.STAGE_NAME } - sh label: 'to build motr and hare rpm', script: ''' - sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} hostname - sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} git clone https://github.com/Seagate/cortx-motr - sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; /root/cortx-motr/scripts/build-prep-1node.sh -dev" - sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "hctl bootstrap --mkfs singlenode.yaml" - sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "dd if=/dev/urandom of=/tmp/128M bs=1M count=128" - sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "/opt/seagate/cortx/hare/libexec/m0crate-io-conf > /root/crate.yaml" - sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "/root/cortx-motr/utils/m0crate -S /root/crate.yaml" - ''' + script { + sh label: 'Download code and install single node cluster', script: ''' + rm -rf $REPO_NAME + echo "MOTR_REPO: ${MOTR_REPO}" + git clone "$repoURL" "$REPO_NAME" + cd "${REPO_NAME}" + git fetch origin "${MOTR_PR_REFSPEC}" + git checkout "${MOTR_BRANCH}" + git log -1 + ls -la + ./scripts/build-prep-1node.sh -dev + hctl bootstrap --mkfs ../singlenode.yaml + sleep 60 + hctl status -d + dd if=/dev/urandom of=/tmp/128M bs=1M count=128 + /opt/seagate/cortx/hare/libexec/m0crate-io-conf > ./crate.yaml + ./utils/m0crate -S ./crate.yaml + ''' + } } } } - + post { always { script { - sh label: 'download_log_files', returnStdout: true, script: """ - sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} rm -rf /root/cortx-motr + sh label: 'Clean up work space', returnStdout: true, script: """ + pwd + cd "$WORKSPACE" + ./scripts/install/usr/libexec/cortx-motr/motr-cleanup || true + losetup -D + make uninstall || true + cd "$WORKSPACE/../cortx-hare" || true + make uninstall || true + cd "$WORKSPACE/.." + rm -rf cortx-hare cortx-motr + echo Done """ + cleanWs() } } } } +