[ceph-client] Add back a new version of reweight_osds()
https://review.opendev.org/733193 removed the reweight_osds() function from the ceph-client and weighted OSDs as they are added in the ceph-osd chart instead. Since then some situations have come up where OSDs were already deployed with incorrect weights and this function is needed in order to weight them properly later on. This new version calculates an expected weight for each OSD, compares it to the OSD's actual weight, and makes an adjustment if necessary. Change-Id: I58bc16fc03b9234a08847d29aa14067bec05f1f1
This commit is contained in:
parent
5d50433362
commit
aaf52acc27
@ -67,6 +67,17 @@ create_crushrule {{ .name }} {{ .crush_rule }} {{ .failure_domain }} {{ .device_
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
function reweight_osds () {
|
||||
OSD_DF_OUTPUT=$(ceph --cluster "${CLUSTER}" osd df --format json-pretty)
|
||||
for OSD_ID in $(ceph --cluster "${CLUSTER}" osd ls); do
|
||||
OSD_EXPECTED_WEIGHT=$(echo "${OSD_DF_OUTPUT}" | grep -A7 "\bosd.${OSD_ID}\b" | awk '/"kb"/{ gsub(",",""); d= $2/1073741824 ; r = sprintf("%.2f", d); print r }');
|
||||
OSD_WEIGHT=$(echo "${OSD_DF_OUTPUT}" | grep -A3 "\bosd.${OSD_ID}\b" | awk '/crush_weight/{print $2}' | cut -d',' -f1)
|
||||
if [[ "${OSD_WEIGHT}" != "${OSD_EXPECTED_WEIGHT}" ]]; then
|
||||
ceph --cluster "${CLUSTER}" osd crush reweight osd.${OSD_ID} ${OSD_EXPECTED_WEIGHT};
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function enable_autoscaling () {
|
||||
if [[ "${ENABLE_AUTOSCALER}" == "true" ]]; then
|
||||
ceph mgr module enable pg_autoscaler
|
||||
@ -171,6 +182,8 @@ function manage_pool () {
|
||||
ceph --cluster "${CLUSTER}" osd pool set-quota "${POOL_NAME}" max_bytes $POOL_QUOTA
|
||||
}
|
||||
|
||||
reweight_osds
|
||||
|
||||
{{ $targetPGperOSD := .Values.conf.pool.target.pg_per_osd }}
|
||||
{{ $crushRuleDefault := .Values.conf.pool.default.crush_rule }}
|
||||
{{ $targetQuota := .Values.conf.pool.target.quota | default 100 }}
|
||||
|
Loading…
Reference in New Issue
Block a user