Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
CORTX-32897: Support default parameters for pre-merge job
Browse files Browse the repository at this point in the history
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 <rinku.kothiya@seagate.com>
  • Loading branch information
rkothiya committed Jul 28, 2022
1 parent 65bcdcb commit 2ca0480
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 28 deletions.
4 changes: 2 additions & 2 deletions scripts/install/usr/libexec/cortx-motr/motr-cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ 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.'

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."
Expand Down
100 changes: 74 additions & 26 deletions scripts/jenkins/motr-hare-1node-cluster.groovy
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
}

0 comments on commit 2ca0480

Please sign in to comment.