2017-07-20 22:26:42 +00:00
|
|
|
#!/usr/bin/env bash
|
2013-01-30 09:04:54 +00:00
|
|
|
|
2017-07-20 22:26:42 +00:00
|
|
|
set -ex
|
2013-01-30 09:04:54 +00:00
|
|
|
|
2014-03-05 20:52:08 +00:00
|
|
|
function expect_false()
|
|
|
|
{
|
|
|
|
set -x
|
|
|
|
if "$@"; then return 1; else return 0; fi
|
|
|
|
}
|
|
|
|
|
2013-01-30 09:04:54 +00:00
|
|
|
ceph osd crush dump
|
2013-03-22 19:32:47 +00:00
|
|
|
|
|
|
|
# rules
|
2013-01-30 09:04:54 +00:00
|
|
|
ceph osd crush rule dump
|
|
|
|
ceph osd crush rule ls
|
|
|
|
ceph osd crush rule list
|
|
|
|
|
|
|
|
ceph osd crush rule create-simple foo default host
|
|
|
|
ceph osd crush rule create-simple foo default host
|
|
|
|
ceph osd crush rule create-simple bar default host
|
|
|
|
|
2017-07-06 18:54:47 +00:00
|
|
|
# make sure we're at luminous+ before using crush device classes
|
2017-09-07 12:18:27 +00:00
|
|
|
ceph osd require-osd-release mimic
|
2017-07-30 07:05:05 +00:00
|
|
|
ceph osd crush rm-device-class all
|
2017-07-10 00:55:15 +00:00
|
|
|
ceph osd crush set-device-class ssd osd.0
|
|
|
|
ceph osd crush set-device-class hdd osd.1
|
2017-06-29 20:33:15 +00:00
|
|
|
ceph osd crush rule create-replicated foo-ssd default host ssd
|
|
|
|
ceph osd crush rule create-replicated foo-hdd default host hdd
|
2017-08-17 02:34:26 +00:00
|
|
|
ceph osd crush rule ls-by-class ssd | grep 'foo-ssd'
|
|
|
|
ceph osd crush rule ls-by-class ssd | expect_false grep 'foo-hdd'
|
|
|
|
ceph osd crush rule ls-by-class hdd | grep 'foo-hdd'
|
|
|
|
ceph osd crush rule ls-by-class hdd | expect_false grep 'foo-ssd'
|
2017-06-29 20:33:15 +00:00
|
|
|
|
2017-06-30 19:56:57 +00:00
|
|
|
ceph osd erasure-code-profile set ec-foo-ssd crush-device-class=ssd m=2 k=2
|
|
|
|
ceph osd pool create ec-foo 2 erasure ec-foo-ssd
|
|
|
|
ceph osd pool rm ec-foo ec-foo --yes-i-really-really-mean-it
|
|
|
|
|
2013-01-30 09:04:54 +00:00
|
|
|
ceph osd crush rule ls | grep foo
|
|
|
|
|
2017-08-15 08:46:15 +00:00
|
|
|
ceph osd crush rule rename foo foo-asdf
|
2017-08-29 00:21:07 +00:00
|
|
|
ceph osd crush rule rename foo foo-asdf # idempotent
|
2017-08-15 08:46:15 +00:00
|
|
|
ceph osd crush rule rename bar bar-asdf
|
|
|
|
ceph osd crush rule ls | grep 'foo-asdf'
|
|
|
|
ceph osd crush rule ls | grep 'bar-asdf'
|
|
|
|
ceph osd crush rule rm foo 2>&1 | grep 'does not exist'
|
|
|
|
ceph osd crush rule rm bar 2>&1 | grep 'does not exist'
|
|
|
|
ceph osd crush rule rename foo-asdf foo
|
2017-08-29 00:21:07 +00:00
|
|
|
ceph osd crush rule rename foo-asdf foo # idempotent
|
2017-08-15 08:46:15 +00:00
|
|
|
ceph osd crush rule rename bar-asdf bar
|
|
|
|
ceph osd crush rule ls | expect_false grep 'foo-asdf'
|
|
|
|
ceph osd crush rule ls | expect_false grep 'bar-asdf'
|
2013-01-30 09:04:54 +00:00
|
|
|
ceph osd crush rule rm foo
|
|
|
|
ceph osd crush rule rm foo # idempotent
|
|
|
|
ceph osd crush rule rm bar
|
|
|
|
|
|
|
|
# can't delete in-use rules, tho:
|
2017-07-21 17:46:04 +00:00
|
|
|
ceph osd pool create pinning_pool 1
|
2017-06-20 21:45:59 +00:00
|
|
|
expect_false ceph osd crush rule rm replicated_rule
|
2017-07-21 17:46:04 +00:00
|
|
|
ceph osd pool rm pinning_pool pinning_pool --yes-i-really-really-mean-it
|
2013-01-30 09:04:54 +00:00
|
|
|
|
2013-03-22 19:32:47 +00:00
|
|
|
# build a simple map
|
2014-03-05 21:15:58 +00:00
|
|
|
expect_false ceph osd crush add-bucket foo osd
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd crush add-bucket foo root
|
|
|
|
o1=`ceph osd create`
|
|
|
|
o2=`ceph osd create`
|
|
|
|
ceph osd crush add $o1 1 host=host1 root=foo
|
2013-06-13 21:01:01 +00:00
|
|
|
ceph osd crush add $o1 1 host=host1 root=foo # idemptoent
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd crush add $o2 1 host=host2 root=foo
|
2013-06-13 21:01:01 +00:00
|
|
|
ceph osd crush add $o2 1 host=host2 root=foo # idempotent
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd crush add-bucket bar root
|
2013-06-13 21:01:01 +00:00
|
|
|
ceph osd crush add-bucket bar root # idempotent
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd crush link host1 root=bar
|
2013-06-13 21:01:01 +00:00
|
|
|
ceph osd crush link host1 root=bar # idempotent
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd crush link host2 root=bar
|
2013-06-13 21:01:01 +00:00
|
|
|
ceph osd crush link host2 root=bar # idempotent
|
2013-03-22 19:32:47 +00:00
|
|
|
|
|
|
|
ceph osd tree | grep -c osd.$o1 | grep -q 2
|
|
|
|
ceph osd tree | grep -c host1 | grep -q 2
|
|
|
|
ceph osd tree | grep -c osd.$o2 | grep -q 2
|
|
|
|
ceph osd tree | grep -c host2 | grep -q 2
|
2014-03-05 20:52:08 +00:00
|
|
|
expect_false ceph osd crush rm host1 foo # not empty
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd crush unlink host1 foo
|
2013-04-03 22:45:34 +00:00
|
|
|
ceph osd crush unlink host1 foo
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd tree | grep -c host1 | grep -q 1
|
|
|
|
|
2014-03-05 20:52:08 +00:00
|
|
|
expect_false ceph osd crush rm foo # not empty
|
|
|
|
expect_false ceph osd crush rm bar # not empty
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd crush unlink host1 bar
|
|
|
|
ceph osd tree | grep -c host1 | grep -q 1 # now an orphan
|
2013-03-27 05:47:11 +00:00
|
|
|
ceph osd crush rm osd.$o1 host1
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd crush rm host1
|
|
|
|
ceph osd tree | grep -c host1 | grep -q 0
|
2018-03-12 09:08:34 +00:00
|
|
|
expect_false ceph osd tree-from host1
|
|
|
|
ceph osd tree-from host2
|
|
|
|
expect_false ceph osd tree-from osd.$o2
|
2013-03-22 19:32:47 +00:00
|
|
|
|
2014-03-05 20:52:08 +00:00
|
|
|
expect_false ceph osd crush rm bar # not empty
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd crush unlink host2
|
2015-05-12 23:37:56 +00:00
|
|
|
|
2017-08-21 09:04:27 +00:00
|
|
|
ceph osd crush add-bucket host-for-test host root=root-for-test rack=rack-for-test
|
|
|
|
ceph osd tree | grep host-for-test
|
|
|
|
ceph osd tree | grep rack-for-test
|
|
|
|
ceph osd tree | grep root-for-test
|
|
|
|
ceph osd crush rm host-for-test
|
|
|
|
ceph osd crush rm rack-for-test
|
|
|
|
ceph osd crush rm root-for-test
|
|
|
|
|
2015-05-12 23:37:56 +00:00
|
|
|
# reference foo and bar with a rule
|
|
|
|
ceph osd crush rule create-simple foo-rule foo host firstn
|
|
|
|
expect_false ceph osd crush rm foo
|
|
|
|
ceph osd crush rule rm foo-rule
|
|
|
|
|
2013-03-22 19:32:47 +00:00
|
|
|
ceph osd crush rm bar
|
|
|
|
ceph osd crush rm foo
|
|
|
|
ceph osd crush rm osd.$o2 host2
|
|
|
|
ceph osd crush rm host2
|
2013-03-27 05:47:11 +00:00
|
|
|
|
2017-01-18 23:02:54 +00:00
|
|
|
ceph osd crush add-bucket foo host
|
|
|
|
ceph osd crush move foo root=default rack=localrack
|
|
|
|
|
|
|
|
ceph osd crush create-or-move osd.$o1 1.0 root=default
|
|
|
|
ceph osd crush move osd.$o1 host=foo
|
|
|
|
ceph osd find osd.$o1 | grep host | grep foo
|
|
|
|
|
2013-04-03 22:45:34 +00:00
|
|
|
ceph osd crush rm osd.$o1
|
|
|
|
ceph osd crush rm osd.$o2
|
2013-03-22 19:32:47 +00:00
|
|
|
|
2013-09-09 23:20:41 +00:00
|
|
|
ceph osd crush rm foo
|
|
|
|
|
2013-09-24 22:26:03 +00:00
|
|
|
# test reweight
|
|
|
|
o3=`ceph osd create`
|
2013-09-25 17:10:21 +00:00
|
|
|
ceph osd crush add $o3 123 root=default
|
2013-09-24 22:26:03 +00:00
|
|
|
ceph osd tree | grep osd.$o3 | grep 123
|
|
|
|
ceph osd crush reweight osd.$o3 113
|
2017-07-08 03:47:42 +00:00
|
|
|
expect_false ceph osd crush reweight osd.$o3 123456
|
2013-09-24 22:26:03 +00:00
|
|
|
ceph osd tree | grep osd.$o3 | grep 113
|
|
|
|
ceph osd crush rm osd.$o3
|
|
|
|
ceph osd rm osd.$o3
|
|
|
|
|
2014-05-25 21:02:16 +00:00
|
|
|
# test reweight-subtree
|
|
|
|
o4=`ceph osd create`
|
|
|
|
o5=`ceph osd create`
|
|
|
|
ceph osd crush add $o4 123 root=default host=foobaz
|
|
|
|
ceph osd crush add $o5 123 root=default host=foobaz
|
|
|
|
ceph osd tree | grep osd.$o4 | grep 123
|
|
|
|
ceph osd tree | grep osd.$o5 | grep 123
|
|
|
|
ceph osd crush reweight-subtree foobaz 155
|
2017-07-08 03:47:42 +00:00
|
|
|
expect_false ceph osd crush reweight-subtree foobaz 123456
|
2014-05-25 21:02:16 +00:00
|
|
|
ceph osd tree | grep osd.$o4 | grep 155
|
|
|
|
ceph osd tree | grep osd.$o5 | grep 155
|
|
|
|
ceph osd crush rm osd.$o4
|
|
|
|
ceph osd crush rm osd.$o5
|
|
|
|
ceph osd rm osd.$o4
|
|
|
|
ceph osd rm osd.$o5
|
|
|
|
|
2017-07-13 21:46:15 +00:00
|
|
|
# weight sets
|
2017-07-19 14:13:23 +00:00
|
|
|
# make sure we require luminous before testing weight-sets
|
|
|
|
ceph osd set-require-min-compat-client luminous
|
2017-07-13 21:46:15 +00:00
|
|
|
ceph osd crush weight-set dump
|
|
|
|
ceph osd crush weight-set ls
|
|
|
|
expect_false ceph osd crush weight-set reweight fooset osd.0 .9
|
|
|
|
ceph osd pool create fooset 8
|
|
|
|
ceph osd pool create barset 8
|
|
|
|
ceph osd pool set barset size 3
|
|
|
|
expect_false ceph osd crush weight-set reweight fooset osd.0 .9
|
|
|
|
ceph osd crush weight-set create fooset flat
|
|
|
|
ceph osd crush weight-set create barset positional
|
|
|
|
ceph osd crush weight-set ls | grep fooset
|
|
|
|
ceph osd crush weight-set ls | grep barset
|
|
|
|
ceph osd crush weight-set dump
|
|
|
|
ceph osd crush weight-set reweight fooset osd.0 .9
|
|
|
|
expect_false ceph osd crush weight-set reweight fooset osd.0 .9 .9
|
|
|
|
expect_false ceph osd crush weight-set reweight barset osd.0 .9
|
|
|
|
ceph osd crush weight-set reweight barset osd.0 .9 .9 .9
|
|
|
|
ceph osd crush weight-set ls | grep -c fooset | grep -q 1
|
|
|
|
ceph osd crush weight-set rm fooset
|
|
|
|
ceph osd crush weight-set ls | grep -c fooset | grep -q 0
|
|
|
|
ceph osd crush weight-set ls | grep barset
|
|
|
|
ceph osd crush weight-set rm barset
|
|
|
|
ceph osd crush weight-set ls | grep -c barset | grep -q 0
|
|
|
|
ceph osd crush weight-set create-compat
|
|
|
|
ceph osd crush weight-set ls | grep '(compat)'
|
|
|
|
ceph osd crush weight-set rm-compat
|
|
|
|
|
2017-08-07 22:30:39 +00:00
|
|
|
# weight set vs device classes
|
|
|
|
ceph osd pool create cool 2
|
|
|
|
ceph osd pool create cold 2
|
|
|
|
ceph osd pool set cold size 2
|
|
|
|
ceph osd crush weight-set create-compat
|
|
|
|
ceph osd crush weight-set create cool flat
|
|
|
|
ceph osd crush weight-set create cold positional
|
|
|
|
ceph osd crush rm-device-class osd.0
|
|
|
|
ceph osd crush weight-set reweight-compat osd.0 10.5
|
|
|
|
ceph osd crush weight-set reweight cool osd.0 11.5
|
|
|
|
ceph osd crush weight-set reweight cold osd.0 12.5 12.4
|
|
|
|
ceph osd crush set-device-class fish osd.0
|
|
|
|
ceph osd crush tree --show-shadow | grep osd\\.0 | grep fish | grep 10\\.
|
|
|
|
ceph osd crush tree --show-shadow | grep osd\\.0 | grep fish | grep 11\\.
|
|
|
|
ceph osd crush tree --show-shadow | grep osd\\.0 | grep fish | grep 12\\.
|
|
|
|
ceph osd crush rm-device-class osd.0
|
|
|
|
ceph osd crush set-device-class globster osd.0
|
|
|
|
ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 10\\.
|
|
|
|
ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 11\\.
|
|
|
|
ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 12\\.
|
|
|
|
ceph osd crush weight-set reweight-compat osd.0 7.5
|
|
|
|
ceph osd crush weight-set reweight cool osd.0 8.5
|
|
|
|
ceph osd crush weight-set reweight cold osd.0 6.5 6.6
|
|
|
|
ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 7\\.
|
|
|
|
ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 8\\.
|
|
|
|
ceph osd crush tree --show-shadow | grep osd\\.0 | grep globster | grep 6\\.
|
|
|
|
ceph osd crush rm-device-class osd.0
|
|
|
|
ceph osd pool rm cool cool --yes-i-really-really-mean-it
|
|
|
|
ceph osd pool rm cold cold --yes-i-really-really-mean-it
|
|
|
|
ceph osd crush weight-set rm-compat
|
|
|
|
|
2013-01-30 09:04:54 +00:00
|
|
|
echo OK
|