Merge "Add repositories refresh to ceph update pipeline"
diff --git a/ceph-add-osd-upmap.groovy b/ceph-add-osd-upmap.groovy
index 5c90c72..f873534 100644
--- a/ceph-add-osd-upmap.groovy
+++ b/ceph-add-osd-upmap.groovy
@@ -44,17 +44,21 @@
             // create connection to salt master
             python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
 
-            stage ("verify client versions")
-            {
+            stage ("verification of supported features") {
+                def checknode = salt.runSaltProcessStep(pepperEnv, HOST, 'test.ping')
+                if (checknode['return'][0].values().isEmpty()) {
+                    common.errorMsg("Host not found")
+                    throw new InterruptedException()
+                }
                 // I@docker:swarm and I@prometheus:server - mon* nodes
-                def nodes = salt.getMinions(pepperEnv, "I@ceph:common and not ( I@docker:swarm and I@prometheus:server )")
+                def nodes = salt.getMinions(pepperEnv, "I@ceph:common and not ( I@docker:swarm and I@prometheus:server ) and not " + HOST)
                 for ( node in nodes )
                 {
-                    def versions = salt.cmdRun(pepperEnv, node, "ceph features --format json", checkResponse=true, batch=null, output=false).values()[0]
-                    versions = new groovy.json.JsonSlurperClassic().parseText(versions[0][node])
-                    if ( versions['client']['group']['release'] != 'luminous' )
+                    def features = salt.cmdRun(pepperEnv, node, "ceph features --format json", checkResponse=true, batch=null, output=false).values()[0]
+                    features = new groovy.json.JsonSlurperClassic().parseText(features[0][node])
+                    if ( fetures['client']['group']['release'] != 'luminous' )
                     {
-                        throw new Exception("client installed on " + node + " is not luminous. Update all clients to luminous before using this pipeline")
+                        throw new Exception("client installed on " + node + " does not support upmap. Update all clients to luminous or newer before using this pipeline")
                     }
                 }
             }
diff --git a/cloud-deploy-pipeline.groovy b/cloud-deploy-pipeline.groovy
index 144f604..f473d8e 100644
--- a/cloud-deploy-pipeline.groovy
+++ b/cloud-deploy-pipeline.groovy
@@ -50,6 +50,7 @@
                                 - 10 - number of nodes
                                 - 10% - percentage of all targeted nodes
  *   DIST_UPGRADE_NODES         Whether to run "apt-get dist-upgrade" on all nodes in cluster before deployment
+ *   UPGRADE_SALTSTACK          Whether to install recent versions of saltstack packages
 
  *
  * Test settings:
@@ -119,6 +120,10 @@
 if (common.validInputParam('DIST_UPGRADE_NODES')) {
     upgrade_nodes = "${DIST_UPGRADE_NODES}".toBoolean()
 }
+def upgrade_salt = false
+if (common.validInputParam('UPGRADE_SALTSTACK')){
+    upgrade_salt = "${UPGRADE_SALTSTACK}".toBoolean()
+}
 
 timeout(time: 12, unit: 'HOURS') {
     node(slave_node) {
@@ -380,6 +385,11 @@
                     }
                     orchestrate.installFoundationInfra(venvPepper, staticMgmtNetwork, extra_tgt, batch_size)
 
+                    if (upgrade_salt) {
+                        debian.upgradeSaltPackages(venvPepper, 'I@salt:master')
+                        debian.upgradeSaltPackages(venvPepper, 'I@salt:minion and not I@salt:master')
+                    }
+
                     if (common.checkContains('STACK_INSTALL', 'kvm')) {
                         if (upgrade_nodes) {
                             debian.osUpgradeNode(venvPepper, 'I@salt:control', 'dist-upgrade', 30, 20, batch_size)
@@ -539,8 +549,7 @@
                 // Workaround for PROD-17765 issue to prevent crashes of keystone.role_present state.
                 // More details: https://mirantis.jira.com/browse/PROD-17765
                 salt.restartSaltMinion(venvPepper, "I@keystone:client ${extra_tgt}")
-                //
-                salt.minionsReachable(venvPepper, 'I@salt:master', 'I@keystone:client ${extra_tgt}', null, 10, 6)
+                salt.minionsReachable(venvPepper, 'I@salt:master', "I@keystone:client ${extra_tgt}", null, 10, 6)
 
                 stage('Install OpenStack network') {
 
diff --git a/test-salt-formulas-env.groovy b/test-salt-formulas-env.groovy
index de631bf..19079b5 100644
--- a/test-salt-formulas-env.groovy
+++ b/test-salt-formulas-env.groovy
@@ -37,7 +37,7 @@
 
 throttle(['test-formula']) {
   timeout(time: 1, unit: 'HOURS') {
-    node("python&&docker") {
+    node("old16.04") {
       try {
         stage("checkout") {
           if (defaultGitRef && defaultGitUrl) {
diff --git a/test-salt-formulas-pipeline.groovy b/test-salt-formulas-pipeline.groovy
index 640cfed..e84386a 100644
--- a/test-salt-formulas-pipeline.groovy
+++ b/test-salt-formulas-pipeline.groovy
@@ -14,7 +14,9 @@
 def gerritRef = env.GERRIT_REFSPEC ?: null
 def defaultGitRef = env.DEFAULT_GIT_REF ?: null
 def defaultGitUrl = env.DEFAULT_GIT_URL ?: null
-def slaveNode = env.SLAVE_NODE ?: 'virtual'
+// vkhlyunev: New slaves breaks old jobs, sticking to ols slaves until fixed
+//def slaveNode = env.SLAVE_NODE ?: 'virtual'
+def slaveNode = env.SLAVE_NODE ?: 'old16.04'
 def saltVersion = env.SALT_VERSION ?: ""
 
 gerritBranch = 'master'
diff --git a/upgrade-mcp-release.groovy b/upgrade-mcp-release.groovy
index 5db2eb2..1072c97 100644
--- a/upgrade-mcp-release.groovy
+++ b/upgrade-mcp-release.groovy
@@ -63,6 +63,10 @@
     salt.cmdRun(venvPepper, "I@salt:master", "salt -C '${target}' --async pkg.install force_yes=True pkgs='$pkgs'")
     // can't use same function from pipeline lib, as at the moment of running upgrade pipeline Jenkins
     // still using pipeline lib from current old mcp-version
+
+    // sleep to make sure package update started, otherwise checks will pass on still running old instance
+    sleep(120)
+
     common.retry(20, 60) {
         salt.minionsReachable(venvPepper, 'I@salt:master', '*')
         def running = salt.runSaltProcessStep(venvPepper, target, 'saltutil.running', [], null, true, 5)
@@ -848,6 +852,8 @@
             }
 
             stage('Update Drivetrain') {
+                salt.enforceState(venvPepper, '*', 'linux.system.package', true, true, batchSize, false, 60, 2)
+
                 if (upgradeSaltStack) {
                     updateSaltStack("I@salt:master", '["salt-master", "salt-common", "salt-api", "salt-minion"]')