blob: c193d3962cc49f516c718190bd7c0618b85d3645 [file] [log] [blame]
Mateusz Losddfa8462019-03-11 14:31:14 +01001/**
2 *
3 * Add Ceph node to existing cluster using upmap mechanism
4 *
5 * Requred parameters:
6 * SALT_MASTER_URL URL of Salt master
7 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
8 * HOST Host (minion id) to be added
9 *
10 */
11
Mateusz Losddfa8462019-03-11 14:31:14 +010012salt = new com.mirantis.mk.Salt()
13def python = new com.mirantis.mk.Python()
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040014def ceph = new com.mirantis.mk.Ceph()
Mateusz Losddfa8462019-03-11 14:31:14 +010015orchestrate = new com.mirantis.mk.Orchestrate()
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040016pepperEnv = "pepperEnv"
Ivan Berezovskiy373e8a32019-11-19 20:04:12 +040017def flags = CLUSTER_FLAGS ? CLUSTER_FLAGS.tokenize(',') : []
Mateusz Losddfa8462019-03-11 14:31:14 +010018
19def runCephCommand(cmd) {
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040020 return salt.cmdRun(pepperEnv, "I@ceph:mon and I@ceph:common:keyring:admin", cmd, checkResponse = true, batch = null, output = false)
Mateusz Losddfa8462019-03-11 14:31:14 +010021}
22
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040023def getpgmap() {
24 return runCephCommand('ceph pg ls remapped --format=json')['return'][0].values()[0]
Mateusz Losddfa8462019-03-11 14:31:14 +010025}
26
27def generatemapping(master,pgmap,map) {
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040028 def pg_new
29 def pg_old
30 for (pg in pgmap) {
31 pg_new = pg["up"].minus(pg["acting"])
32 pg_old = pg["acting"].minus(pg["up"])
33 for (i = 0; i < pg_new.size(); i++) {
34 def string = "ceph osd pg-upmap-items " + pg["pgid"].toString() + " " + pg_new[i] + " " + pg_old[i] + ";"
35 map.add(string)
36 }
Mateusz Losddfa8462019-03-11 14:31:14 +010037 }
Mateusz Losddfa8462019-03-11 14:31:14 +010038}
39
Mateusz Losddfa8462019-03-11 14:31:14 +010040timeout(time: 12, unit: 'HOURS') {
41 node("python") {
Mateusz Losddfa8462019-03-11 14:31:14 +010042 // create connection to salt master
43 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
44
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040045 stage("verify client versions") {
46 def admin = salt.getMinions(pepperEnv, "I@ceph:mon and I@ceph:common:keyring:admin")[0]
47 def versions = salt.cmdRun(pepperEnv, admin, "ceph features", checkResponse = true, batch = null, output = false).values()[0]
Mateusz Los0e183112019-04-04 20:10:05 +020048
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040049 if (versions[0][admin].contains('jewel')) {
50 throw new Exception("Update all clients to luminous before using this pipeline")
51 }
Mateusz Losddfa8462019-03-11 14:31:14 +010052 }
53
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040054 stage("enable luminous compat") {
55 runCephCommand('ceph osd set-require-min-compat-client luminous')['return'][0].values()[0]
Mateusz Losddfa8462019-03-11 14:31:14 +010056 }
57
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040058 stage("enable upmap balancer") {
59 runCephCommand('ceph balancer on')['return'][0].values()[0]
60 runCephCommand('ceph balancer mode upmap')['return'][0].values()[0]
Mateusz Losddfa8462019-03-11 14:31:14 +010061 }
62
63
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040064 stage("set norebalance") {
65 runCephCommand('ceph osd set norebalance')['return'][0].values()[0]
Mateusz Losddfa8462019-03-11 14:31:14 +010066 }
67
68 stage('Install Ceph OSD') {
69 orchestrate.installCephOsd(pepperEnv, HOST)
70 }
71
72 def mapping = []
73
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040074 stage("update mappings") {
75 def pgmap
76 for (int x = 1; x <= 3; x++) {
77 pgmap = getpgmap()
78 if (pgmap == '') {
79 return 1
80 } else {
81 pgmap = new groovy.json.JsonSlurperClassic().parseText(pgmap)
82 generatemapping(pepperEnv, pgmap, mapping)
83 mapping.each(this.&runCephCommand)
84 }
Mateusz Losddfa8462019-03-11 14:31:14 +010085 }
Mateusz Losddfa8462019-03-11 14:31:14 +010086 }
87
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040088 stage("unset norebalance") {
89 runCephCommand('ceph osd unset norebalance')['return'][0].values()[0]
Mateusz Losddfa8462019-03-11 14:31:14 +010090 }
91
Ivan Berezovskiy2325dcb2019-11-05 17:42:57 +040092 stage("wait for healthy cluster") {
Ivan Berezovskiy373e8a32019-11-19 20:04:12 +040093 ceph.waitForHealthy(pepperEnv, "I@ceph:mon and I@ceph:common:keyring:admin", flags)
Mateusz Losddfa8462019-03-11 14:31:14 +010094 }
Mateusz Losddfa8462019-03-11 14:31:14 +010095 }
96}