Merge "Allow upgrade etcd for k8s."
diff --git a/cloud-deploy-pipeline.groovy b/cloud-deploy-pipeline.groovy
index f05735a..eb9cc8e 100644
--- a/cloud-deploy-pipeline.groovy
+++ b/cloud-deploy-pipeline.groovy
@@ -134,12 +134,19 @@
                     }
 
                     if (STACK_REUSE.toBoolean() == false) {
-                        // Don't allow to set custom heat stack name
+                        // TODO(vsaienko): remove stack creation from this pipeline to separate job
+                        // Allow to set custom stack name but user-id will be added anyway
+                        // This will fix issue with cleanup when job is aborted by jenkins and
+                        // still guarantee stack count per user.
+                        def stackNameSuffix = "${JOB_NAME}-${BUILD_NUMBER}"
+                        if (STACK_NAME != ''){
+                          stackNameSuffix = STACK_NAME
+                        }
                         wrap([$class: 'BuildUser']) {
                             if (env.BUILD_USER_ID) {
-                                STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}"
+                                STACK_NAME = "${env.BUILD_USER_ID}-${stackNameSuffix}"
                             } else {
-                                STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}"
+                                STACK_NAME = "jenkins-${stackNameSuffix}"
                             }
                             currentBuild.description = STACK_NAME
                         }
diff --git a/galera-cluster-verify-restore.groovy b/galera-cluster-verify-restore.groovy
index b8826ec..2a575cc 100644
--- a/galera-cluster-verify-restore.groovy
+++ b/galera-cluster-verify-restore.groovy
@@ -29,11 +29,9 @@
                 if (resultCode == 129) {
                     common.errorMsg("Unable to obtain Galera slave minions list". "Without fixing this issue, pipeline cannot continue in verification and restoration.")
                     currentBuild.result = "FAILURE"
-                    return
                 } else if (resultCode == 130) {
                     common.errorMsg("Neither master or slaves are reachable. Without fixing this issue, pipeline cannot continue in verification and restoration.")
                     currentBuild.result = "FAILURE"
-                    return
                 }
             }
             if (resultCode == 1) {
@@ -50,5 +48,15 @@
                 common.errorMsg("Restoration process has failed.")
             }
         }
+        stage('Verify restoration result') {
+            exitCode = openstack.verifyGaleraStatus(pepperEnv, false)
+            if (exitCode >= 1) {
+                common.errorMsg("Restoration procedure was probably not successful. See verification report for more information.")
+                currentBuild.result = "FAILURE"
+            } else {
+                common.infoMsg("Restoration procedure seems to be successful. See verification report to be sure.")
+                currentBuild.result = "SUCCESS"
+            }
+        }
     }
 }