[ceph-mon] Skip monmap endpoint check for missing mons

This change adds a condition to ensure that an IP address was
obtained for a ceph-mon kubernetes endpoint before building the
expected endpoint string and checking it against the monmap. If an
IP address isn't available, the check is skipped for that mon.

Change-Id: I45a2e2987b5ef0c27b0bb765f7967fcce1af62e4
This commit is contained in:
Stephen Taylor 2021-10-15 12:05:10 -06:00
parent 66fedd5d39
commit 718db3682e
3 changed files with 10 additions and 5 deletions

View File

@ -15,6 +15,6 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Ceph Mon
name: ceph-mon
version: 0.1.16
version: 0.1.17
home: https://github.com/ceph/ceph
...

View File

@ -41,11 +41,15 @@ function check_mon_addrs {
for mon in ${mon_hostnames}; do
local mon_endpoint=$(echo "${mon_dump}" | awk "/${mon}/{print \$2}")
local mon_ip=$(jq -r ".subsets[0].addresses[] | select(.nodeName == \"${mon}\") | .ip" <<< ${mon_endpoints})
local desired_endpoint=$(printf '[v1:%s:%s/0,v2:%s:%s/0]' ${mon_ip} ${v1_port} ${mon_ip} ${v2_port})
if [[ "${mon_endpoint}" != "${desired_endpoint}" ]]; then
echo "endpoint for ${mon} is ${mon_endpoint}, setting it to ${desired_endpoint}"
ceph mon set-addrs ${mon} ${desired_endpoint}
# Skip this mon if it doesn't appear in the list of kubernetes endpoints
if [[ -n "${mon_ip}" ]]; then
local desired_endpoint=$(printf '[v1:%s:%s/0,v2:%s:%s/0]' ${mon_ip} ${v1_port} ${mon_ip} ${v2_port})
if [[ "${mon_endpoint}" != "${desired_endpoint}" ]]; then
echo "endpoint for ${mon} is ${mon_endpoint}, setting it to ${desired_endpoint}"
ceph mon set-addrs ${mon} ${desired_endpoint}
fi
fi
done
}

View File

@ -17,4 +17,5 @@ ceph-mon:
- 0.1.14 Update htk requirements
- 0.1.15 Prevent mon-check from removing mons when down temporarily
- 0.1.16 Correct Ceph Mon Check Ports
- 0.1.17 Skip monmap endpoint check for missing mons
...