Merge "Improved printing of heat stacks related jobs"
diff --git a/cicd-lab-pipeline.groovy b/cicd-lab-pipeline.groovy
index b68fc4e..d89373c 100644
--- a/cicd-lab-pipeline.groovy
+++ b/cicd-lab-pipeline.groovy
@@ -126,6 +126,11 @@
}
sleep(5)
salt.enforceState(saltMaster, 'I@glusterfs:client', 'glusterfs.client', true)
+
+ timeout(5) {
+ println "Waiting for GlusterFS volumes to get mounted.."
+ salt.cmdRun(saltMaster, 'I@glusterfs:client', 'while true; do systemctl -a|grep "GlusterFS File System"|grep -v mounted >/dev/null || break; done')
+ }
print common.prettyPrint(salt.cmdRun(saltMaster, 'I@glusterfs:client', 'mount|grep fuse.glusterfs || echo "Command failed"'))
}
@@ -148,7 +153,10 @@
}
stage("Deploy Docker services") {
- salt.enforceState(saltMaster, 'I@docker:swarm:role:master', 'docker.client')
+ retry(3) {
+ sleep(5)
+ salt.enforceState(saltMaster, 'I@docker:swarm:role:master', 'docker.client')
+ }
}
stage("Configure CI/CD services") {
diff --git a/gating-pipeline.groovy b/gating-pipeline.groovy
index c056f38..89ac78f 100644
--- a/gating-pipeline.groovy
+++ b/gating-pipeline.groovy
@@ -20,8 +20,9 @@
def gerritProjectArray = GERRIT_PROJECT.tokenize("/")
def gerritProject = gerritProjectArray[gerritProjectArray.size() - 1]
def jobsNamespace = JOBS_NAMESPACE
+ def plural_namespaces = ['salt-formulas', 'salt-models']
// remove plural s on the end of job namespace
- if (JOBS_NAMESPACE[JOBS_NAMESPACE.length() - 1].equals("s")){
+ if (JOBS_NAMESPACE in plural_namespaces){
jobsNamespace = JOBS_NAMESPACE.substring(0, JOBS_NAMESPACE.length() - 1)
}
def testJob = String.format("test-%s-%s", jobsNamespace, gerritProject)
@@ -57,4 +58,4 @@
@NonCPS
def _jobExists(jobName){
return Jenkins.instance.items.find{it -> it.name.equals(jobName)}
-}
\ No newline at end of file
+}
diff --git a/generate-cookiecutter-products.groovy b/generate-cookiecutter-products.groovy
index 0986c4e..4092068 100644
--- a/generate-cookiecutter-products.groovy
+++ b/generate-cookiecutter-products.groovy
@@ -28,16 +28,19 @@
def modelEnv = "${env.WORKSPACE}/model"
try {
- def templateContext = python.loadJson(COOKIECUTTER_TEMPLATE_CONTEXT)
+ def templateContext = readYaml text: COOKIECUTTER_TEMPLATE_CONTEXT
def templateDir = "${templateEnv}/template/dir"
def templateOutputDir = "${env.WORKSPACE}/template"
def cutterEnv = "${env.WORKSPACE}/cutter"
def jinjaEnv = "${env.WORKSPACE}/jinja"
- def clusterName = templateContext.cluster_name
- def clusterDomain = templateContext.cluster_domain
+ def clusterName = templateContext.default_context.cluster_name
+ def clusterDomain = templateContext.default_context.cluster_domain
def targetBranch = "feature/${clusterName}"
def outputDestination = "${modelEnv}/classes/cluster/${clusterName}"
+ currentBuild.description = clusterName
+ print("Using context:\n" + COOKIECUTTER_TEMPLATE_CONTEXT)
+
stage ('Download Cookiecutter template') {
git.checkoutGitRepository(templateEnv, COOKIECUTTER_TEMPLATE_URL, COOKIECUTTER_TEMPLATE_BRANCH, COOKIECUTTER_TEMPLATE_CREDENTIALS)
}
@@ -54,7 +57,7 @@
sh "mkdir -p ${templateOutputDir}"
sh "mkdir -p ${outputDestination}"
python.setupCookiecutterVirtualenv(cutterEnv)
- python.buildCookiecutterTemplate(templateDir, templateContext, templateOutputDir, cutterEnv)
+ python.buildCookiecutterTemplate(templateDir, COOKIECUTTER_TEMPLATE_CONTEXT, templateOutputDir, cutterEnv)
sh "mv -v ${templateOutputDir}/${clusterName}/* ${outputDestination}"
}
@@ -64,7 +67,7 @@
templateOutputDir = "${env.WORKSPACE}/template/output/cicd"
sh "mkdir -p ${templateOutputDir}"
python.setupCookiecutterVirtualenv(cutterEnv)
- python.buildCookiecutterTemplate(templateDir, templateContext, templateOutputDir, cutterEnv)
+ python.buildCookiecutterTemplate(templateDir, COOKIECUTTER_TEMPLATE_CONTEXT, templateOutputDir, cutterEnv)
sh "mv -v ${templateOutputDir}/${clusterName}/* ${outputDestination}"
}
}
@@ -75,7 +78,7 @@
templateOutputDir = "${env.WORKSPACE}/template/output/opencontrail"
sh "mkdir -p ${templateOutputDir}"
python.setupCookiecutterVirtualenv(cutterEnv)
- python.buildCookiecutterTemplate(templateDir, templateContext, templateOutputDir, cutterEnv)
+ python.buildCookiecutterTemplate(templateDir, COOKIECUTTER_TEMPLATE_CONTEXT, templateOutputDir, cutterEnv)
sh "mv -v ${templateOutputDir}/${clusterName}/* ${outputDestination}"
}
}
@@ -86,7 +89,7 @@
templateOutputDir = "${env.WORKSPACE}/template/output/kubernetes"
sh "mkdir -p ${templateOutputDir}"
python.setupCookiecutterVirtualenv(cutterEnv)
- python.buildCookiecutterTemplate(templateDir, templateContext, templateOutputDir, cutterEnv)
+ python.buildCookiecutterTemplate(templateDir, COOKIECUTTER_TEMPLATE_CONTEXT, templateOutputDir, cutterEnv)
sh "mv -v ${templateOutputDir}/${clusterName}/* ${outputDestination}"
}
}
@@ -97,7 +100,7 @@
templateOutputDir = "${env.WORKSPACE}/template/output/openstack"
sh "mkdir -p ${templateOutputDir}"
python.setupCookiecutterVirtualenv(cutterEnv)
- python.buildCookiecutterTemplate(templateDir, templateContext, templateOutputDir, cutterEnv)
+ python.buildCookiecutterTemplate(templateDir, COOKIECUTTER_TEMPLATE_CONTEXT, templateOutputDir, cutterEnv)
sh "mv -v ${templateOutputDir}/${clusterName}/* ${outputDestination}"
}
}
@@ -108,7 +111,7 @@
templateOutputDir = "${env.WORKSPACE}/template/output/stacklight"
sh "mkdir -p ${templateOutputDir}"
python.setupCookiecutterVirtualenv(cutterEnv)
- python.buildCookiecutterTemplate(templateDir, templateContext, templateOutputDir, cutterEnv)
+ python.buildCookiecutterTemplate(templateDir, COOKIECUTTER_TEMPLATE_CONTEXT, templateOutputDir, cutterEnv)
sh "mv -v ${templateOutputDir}/${clusterName}/* ${outputDestination}"
}
}
@@ -130,12 +133,6 @@
writeFile(file: nodeFile, text: nodeString)
}
- stage('Inject changes to Reclass model') {
- def outputSource = "${env.WORKSPACE}/template/output/"
- sh "mkdir -p ${outputDestination}"
- sh(returnStdout: true, script: "cp -vr ${outputSource} ${outputDestination}")
- }
-
stage ('Save changes to Reclass model') {
if (COMMIT_CHANGES.toBoolean()) {
git.changeGitBranch(modelEnv, targetBranch)
diff --git a/lab-pipeline.groovy b/lab-pipeline.groovy
index 5b7cc11..edfabbc 100644
--- a/lab-pipeline.groovy
+++ b/lab-pipeline.groovy
@@ -174,9 +174,6 @@
stage('Install Kubernetes infra') {
//orchestrate.installOpenstackMcpInfra(saltMaster)
- // Comment nameserver
- salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"])
-
// Install glusterfs
salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service'])
@@ -184,9 +181,6 @@
salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster and *01*', 'state.sls', ['keepalived'])
salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'state.sls', ['keepalived'])
- // Check the keepalived VIPs
- salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
-
// Setup glusterfs
salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server and *01*', 'state.sls', ['glusterfs.server.setup'])
salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
@@ -200,12 +194,9 @@
salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'state.sls', ['docker.host'])
salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'cmd.run', ['docker ps'])
- // Install bird
- salt.runSaltProcessStep(saltMaster, 'I@bird:server', 'state.sls', ['bird'])
-
// Install etcd
salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'state.sls', ['etcd.server.service'])
- salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'cmd.run', ['etcdctl cluster-health'])
+ salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'cmd.run', ['./var/lib/etcd/configenv && etcdctl cluster-health'])
}
@@ -213,11 +204,11 @@
//orchestrate.installOpenstackMcpControl(saltMaster)
// Install Kubernetes pool and Calico
+ salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['kubernetes.master.kube-addons'])
salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'state.sls', ['kubernetes.pool'])
- salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'cmd.run', ['calicoctl node status'])
// Setup etcd server
- salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['etcd.server.setup'])
+ salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master and *01*', 'state.sls', ['etcd.server.setup'])
// Run k8s without master.setup
salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
@@ -225,12 +216,6 @@
// Run k8s master setup
salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master and *01*', 'state.sls', ['kubernetes.master.setup'])
- // Revert comment nameserver
- salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"])
-
- // Set route
- salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'cmd.run', ['ip r a 10.254.0.0/16 dev ens4'])
-
// Restart kubelet
salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
}
@@ -308,7 +293,10 @@
// populate keystone services/tenants/roles/users
// keystone:client must be called locally
- salt.runSaltProcessStep(saltMaster, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
+ //salt.runSaltProcessStep(saltMaster, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
+ salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'service.restart', ['apache2'])
+ salt.enforceState(saltMaster, 'I@keystone:client', 'keystone.client', true)
+ salt.enforceState(saltMaster, 'I@keystone:client', 'keystone.client', true)
salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; keystone service-list'], null, true)
// Install glance and ensure glusterfs clusters
diff --git a/test-nodejs-pipeline.groovy b/test-nodejs-pipeline.groovy
index 30ea642..d0365a4 100644
--- a/test-nodejs-pipeline.groovy
+++ b/test-nodejs-pipeline.groovy
@@ -21,14 +21,40 @@
}
}
+
+def gerritRef
+try {
+ gerritRef = GERRIT_REFSPEC
+} catch (MissingPropertyException e) {
+ gerritRef = null
+}
+
+def defaultGitRef, defaultGitUrl
+try {
+ defaultGitRef = DEFAULT_GIT_REF
+ defaultGitUrl = DEFAULT_GIT_URL
+} catch (MissingPropertyException e) {
+ defaultGitRef = null
+ defaultGitUrl = null
+}
+def checkouted = false
+
node("docker") {
def containerId
try {
stage('Checkout source code') {
- gerrit.gerritPatchsetCheckout ([
- credentialsId : CREDENTIALS_ID,
- withWipeOut : true,
- ])
+ if (gerritRef) {
+ // job is triggered by Gerrit
+ checkouted = gerrit.gerritPatchsetCheckout ([
+ credentialsId : CREDENTIALS_ID,
+ withWipeOut : true,
+ ])
+ } else if(defaultGitRef && defaultGitUrl) {
+ checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", CREDENTIALS_ID)
+ }
+ if(!checkouted){
+ throw new Exception("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null")
+ }
}
stage('Start container') {
def workspace = common.getWorkspace()