Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 1 | /** |
| 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 Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 12 | salt = new com.mirantis.mk.Salt() |
| 13 | def python = new com.mirantis.mk.Python() |
Ivan Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 14 | def ceph = new com.mirantis.mk.Ceph() |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 15 | orchestrate = new com.mirantis.mk.Orchestrate() |
Ivan Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 16 | pepperEnv = "pepperEnv" |
Ivan Berezovskiy | 4c39c7d | 2019-11-19 20:04:12 +0400 | [diff] [blame^] | 17 | def flags = CLUSTER_FLAGS ? CLUSTER_FLAGS.tokenize(',') : [] |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 18 | |
| 19 | def runCephCommand(cmd) { |
Ivan Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 20 | return salt.cmdRun(pepperEnv, "I@ceph:mon and I@ceph:common:keyring:admin", cmd, checkResponse = true, batch = null, output = false) |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 21 | } |
| 22 | |
Ivan Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 23 | def getpgmap() { |
| 24 | return runCephCommand('ceph pg ls remapped --format=json')['return'][0].values()[0] |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | def generatemapping(master,pgmap,map) { |
Ivan Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 28 | 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 Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 37 | } |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 38 | } |
| 39 | |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 40 | timeout(time: 12, unit: 'HOURS') { |
| 41 | node("python") { |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 42 | // create connection to salt master |
| 43 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 44 | |
| 45 | stage ("verify client versions") |
| 46 | { |
Denis Egorenko | e983d45 | 2019-08-23 14:29:34 +0400 | [diff] [blame] | 47 | // 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 Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 49 | 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 Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 60 | stage("enable luminous compat") { |
| 61 | runCephCommand('ceph osd set-require-min-compat-client luminous')['return'][0].values()[0] |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 62 | } |
| 63 | |
Ivan Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 64 | stage("enable upmap balancer") { |
| 65 | runCephCommand('ceph balancer on')['return'][0].values()[0] |
| 66 | runCephCommand('ceph balancer mode upmap')['return'][0].values()[0] |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | |
Ivan Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 70 | stage("set norebalance") { |
| 71 | runCephCommand('ceph osd set norebalance')['return'][0].values()[0] |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | stage('Install Ceph OSD') { |
| 75 | orchestrate.installCephOsd(pepperEnv, HOST) |
| 76 | } |
| 77 | |
| 78 | def mapping = [] |
| 79 | |
Ivan Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 80 | 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 Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 92 | } |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 93 | } |
| 94 | |
Ivan Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 95 | stage("unset norebalance") { |
| 96 | runCephCommand('ceph osd unset norebalance')['return'][0].values()[0] |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 97 | } |
| 98 | |
Ivan Berezovskiy | 19c685a | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 99 | stage("wait for healthy cluster") { |
Ivan Berezovskiy | 4c39c7d | 2019-11-19 20:04:12 +0400 | [diff] [blame^] | 100 | ceph.waitForHealthy(pepperEnv, "I@ceph:mon and I@ceph:common:keyring:admin", flags) |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 101 | } |
Mateusz Los | 36e64e0 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 102 | } |
| 103 | } |