Mateusz Los | ddfa846 | 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 | ddfa846 | 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 | 2325dcb | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 14 | def ceph = new com.mirantis.mk.Ceph() |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 15 | orchestrate = new com.mirantis.mk.Orchestrate() |
Ivan Berezovskiy | 2325dcb | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 16 | pepperEnv = "pepperEnv" |
Ivan Berezovskiy | 373e8a3 | 2019-11-19 20:04:12 +0400 | [diff] [blame] | 17 | def flags = CLUSTER_FLAGS ? CLUSTER_FLAGS.tokenize(',') : [] |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 18 | |
| 19 | def runCephCommand(cmd) { |
Ivan Berezovskiy | 2325dcb | 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 | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 21 | } |
| 22 | |
Ivan Berezovskiy | 2325dcb | 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 | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | def generatemapping(master,pgmap,map) { |
Ivan Berezovskiy | 2325dcb | 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 | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 37 | } |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 38 | } |
| 39 | |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 40 | timeout(time: 12, unit: 'HOURS') { |
| 41 | node("python") { |
Mateusz Los | ddfa846 | 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 | |
Ivan Berezovskiy | 2325dcb | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 45 | 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 Los | 0e18311 | 2019-04-04 20:10:05 +0200 | [diff] [blame] | 48 | |
Ivan Berezovskiy | 2325dcb | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 49 | if (versions[0][admin].contains('jewel')) { |
| 50 | throw new Exception("Update all clients to luminous before using this pipeline") |
| 51 | } |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 52 | } |
| 53 | |
Ivan Berezovskiy | 2325dcb | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 54 | stage("enable luminous compat") { |
| 55 | runCephCommand('ceph osd set-require-min-compat-client luminous')['return'][0].values()[0] |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 56 | } |
| 57 | |
Ivan Berezovskiy | 2325dcb | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 58 | stage("enable upmap balancer") { |
| 59 | runCephCommand('ceph balancer on')['return'][0].values()[0] |
| 60 | runCephCommand('ceph balancer mode upmap')['return'][0].values()[0] |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | |
Ivan Berezovskiy | 2325dcb | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 64 | stage("set norebalance") { |
| 65 | runCephCommand('ceph osd set norebalance')['return'][0].values()[0] |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | stage('Install Ceph OSD') { |
| 69 | orchestrate.installCephOsd(pepperEnv, HOST) |
| 70 | } |
| 71 | |
| 72 | def mapping = [] |
| 73 | |
Ivan Berezovskiy | 2325dcb | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 74 | 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 Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 85 | } |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 86 | } |
| 87 | |
Ivan Berezovskiy | 2325dcb | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 88 | stage("unset norebalance") { |
| 89 | runCephCommand('ceph osd unset norebalance')['return'][0].values()[0] |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 90 | } |
| 91 | |
Ivan Berezovskiy | 2325dcb | 2019-11-05 17:42:57 +0400 | [diff] [blame] | 92 | stage("wait for healthy cluster") { |
Ivan Berezovskiy | 373e8a3 | 2019-11-19 20:04:12 +0400 | [diff] [blame] | 93 | ceph.waitForHealthy(pepperEnv, "I@ceph:mon and I@ceph:common:keyring:admin", flags) |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 94 | } |
Mateusz Los | ddfa846 | 2019-03-11 14:31:14 +0100 | [diff] [blame] | 95 | } |
| 96 | } |