Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P68901
ceph_reweight_rack.py
Active
Public
Actions
Authored by
ProdPasteBot
on Sep 11 2024, 7:53 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F57499120: ceph_reweight_rack.py
Sep 11 2024, 7:53 AM
2024-09-11 07:53:47 (UTC+0)
Subscribers
None
#!/usr/bin/env python3
import
subprocess
import
json
import
click
@click.command
()
@click.argument
(
"RACK"
)
def
main
(
rack
:
str
)
->
None
:
rack_json
=
subprocess
.
check_output
([
"ceph"
,
"osd"
,
"df"
,
rack
,
"-f=json"
])
rack_data
=
json
.
loads
(
rack_json
)
to_reweight
:
list
[
tuple
[
str
,
float
]]
=
[]
for
node_data
in
rack_data
[
"nodes"
]:
osd
=
node_data
[
"name"
]
osd_variance
=
node_data
[
"var"
]
if
osd_variance
<
1.1
:
print
(
f
"Skipping osd {osd}, not too full (var={osd_variance})"
)
continue
print
(
f
"Reweighting osd {osd}"
)
weight_json
=
subprocess
.
check_output
([
"ceph"
,
"osd"
,
"df"
,
"-f=json"
,
osd
])
weight_data
=
json
.
loads
(
weight_json
)
cur_weight
=
weight_data
[
"nodes"
][
0
][
"reweight"
]
print
(
f
" cur_weight={cur_weight}"
)
new_weight
=
cur_weight
-
0.05
if
new_weight
<
0.5
:
print
(
f
"WARNING: weight of {osd} will go under 0.5 -> {new_weight}"
)
print
(
f
" new_weight={new_weight}"
)
to_reweight
.
append
((
osd
,
new_weight
))
print
(
f
"Reweighting a total of {len(to_reweight)} osds"
)
print
(
"If that's ok, hit enter"
)
input
()
for
osd
,
new_weight
in
to_reweight
:
print
(
f
"Reweighting osd {osd}"
)
subprocess
.
check_call
([
"ceph"
,
"osd"
,
"reweight"
,
osd
,
str
(
new_weight
)])
if
__name__
==
"__main__"
:
main
()
Event Timeline
ProdPasteBot
edited the content of this paste.
(Show Details)
Sep 11 2024, 7:53 AM
2024-09-11 07:53:47 (UTC+0)
ProdPasteBot
changed the title of this paste from untitled to
ceph_reweight_rack.py
.
dcaro
mentioned this in
T374043: Drain C8 rack
.
Sep 11 2024, 8:43 AM
2024-09-11 08:43:45 (UTC+0)
Log In to Comment