blob: aa7e5e239e60757ae5e85a7852cb66e3fc151bc4 [file] [log] [blame]
Mateusz Los36e64e02019-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 Los36e64e02019-03-11 14:31:14 +010012salt = new com.mirantis.mk.Salt()
13def python = new com.mirantis.mk.Python()
Ivan Berezovskiy19c685a2019-11-05 17:42:57 +040014def ceph = new com.mirantis.mk.Ceph()
Mateusz Los36e64e02019-03-11 14:31:14 +010015orchestrate = new com.mirantis.mk.Orchestrate()
Ivan Berezovskiy19c685a2019-11-05 17:42:57 +040016pepperEnv = "pepperEnv"
Ivan Berezovskiy4c39c7d2019-11-19 20:04:12 +040017def flags = CLUSTER_FLAGS ? CLUSTER_FLAGS.tokenize(',') : []
Mateusz Los36e64e02019-03-11 14:31:14 +010018
19def runCephCommand(cmd) {
Ivan Berezovskiy19c685a2019-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 Los36e64e02019-03-11 14:31:14 +010021}
22
Ivan Berezovskiy19c685a2019-11-05 17:42:57 +040023def getpgmap() {
24 return runCephCommand('ceph pg ls remapped --format=json')['return'][0].values()[0]
Mateusz Los36e64e02019-03-11 14:31:14 +010025}
26
27def generatemapping(master,pgmap,map) {
Ivan Berezovskiy19c685a2019-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 Los36e64e02019-03-11 14:31:14 +010037 }
Mateusz Los36e64e02019-03-11 14:31:14 +010038}
39
Mateusz Los36e64e02019-03-11 14:31:14 +010040timeout(time: 12, unit: 'HOURS') {
41 node("python") {
Mateusz Los36e64e02019-03-11 14:31:14 +010042 // create connection to salt master
43 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
44
45 stage ("verify client versions")
46 {
Denis Egorenkoe983d452019-08-23 14:29:34 +040047 // I@docker:swarm and I@prometheus:server - mon* nodes
48 def nodes = salt.getMinions("pepperEnv", "I@ceph:common and not ( I@docker:swarm and I@prometheus:server )")
Mateusz Los36e64e02019-03-11 14:31:14 +010049 for ( node in nodes )
50 {
51 def versions = salt.cmdRun("pepperEnv", node, "ceph features --format json", checkResponse=true, batch=null, output=false).values()[0]
52 versions = new groovy.json.JsonSlurperClassic().parseText(versions[0][node])
53 if ( versions['client']['group']['release'] != 'luminous' )
54 {
55 throw new Exception("client installed on " + node + " is not luminous. Update all clients to luminous before using this pipeline")
56 }
57 }
58 }
59
Ivan Berezovskiy19c685a2019-11-05 17:42:57 +040060 stage("enable luminous compat") {
61 runCephCommand('ceph osd set-require-min-compat-client luminous')['return'][0].values()[0]
Mateusz Los36e64e02019-03-11 14:31:14 +010062 }
63
Ivan Berezovskiy19c685a2019-11-05 17:42:57 +040064 stage("enable upmap balancer") {
65 runCephCommand('ceph balancer on')['return'][0].values()[0]
66 runCephCommand('ceph balancer mode upmap')['return'][0].values()[0]
Mateusz Los36e64e02019-03-11 14:31:14 +010067 }
68
69
Ivan Berezovskiy19c685a2019-11-05 17:42:57 +040070 stage("set norebalance") {
71 runCephCommand('ceph osd set norebalance')['return'][0].values()[0]
Mateusz Los36e64e02019-03-11 14:31:14 +010072 }
73
74 stage('Install Ceph OSD') {
75 orchestrate.installCephOsd(pepperEnv, HOST)
76 }
77
78 def mapping = []
79
Ivan Berezovskiy19c685a2019-11-05 17:42:57 +040080 stage("update mappings") {
81 def pgmap
82 for (int x = 1; x <= 3; x++) {
83 pgmap = getpgmap()
84 if (pgmap == '') {
85 return 1
86 } else {
87 pgmap = new groovy.json.JsonSlurperClassic().parseText(pgmap)
88 generatemapping(pepperEnv, pgmap, mapping)
89 mapping.each(this.&runCephCommand)
90 sleep(30)
91 }
Mateusz Los36e64e02019-03-11 14:31:14 +010092 }
Mateusz Los36e64e02019-03-11 14:31:14 +010093 }
94
Ivan Berezovskiy19c685a2019-11-05 17:42:57 +040095 stage("unset norebalance") {
96 runCephCommand('ceph osd unset norebalance')['return'][0].values()[0]
Mateusz Los36e64e02019-03-11 14:31:14 +010097 }
98
Ivan Berezovskiy19c685a2019-11-05 17:42:57 +040099 stage("wait for healthy cluster") {
Ivan Berezovskiy4c39c7d2019-11-19 20:04:12 +0400100 ceph.waitForHealthy(pepperEnv, "I@ceph:mon and I@ceph:common:keyring:admin", flags)
Mateusz Los36e64e02019-03-11 14:31:14 +0100101 }
Mateusz Los36e64e02019-03-11 14:31:14 +0100102 }
103}