Repository navigation
kvm: support Host HA on Ceph RBD primary storage #14320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
weizhouapache
wants to merge
19
commits into
apache:main
Choose a base branch
from
weizhouapache:24-kvm-ha-on-ceph
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,245
−47
Draft
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
806fc22
kvm: support Host HA on Ceph RBD primary storage
weizhouapache ebc71b7
kvm: address review comments on Host HA for Ceph RBD
weizhouapache a36604e
kvm: validate input of the RBD Host HA scripts and the Ceph settings …
weizhouapache daacf3e
kvm: keep the Ceph key out of the logs and process list of the RBD Ho…
weizhouapache 3d932fe
kvmvmactivity_rbd.sh: do not depend on python3, and tell failures fro…
weizhouapache 4e6ca34
kvmvmactivity_rbd.sh: do not decide on an activity state which could …
weizhouapache dc7d14a
kvm: rewrite the RBD Host HA scripts in Python, with a faster VM-acti…
weizhouapache fcf71d1
kvm: choose the script which checks the VM activity by the type of th…
weizhouapache d1fb5da
kvm: use only the Python bindings of librados and librbd in the Host …
weizhouapache 902bc58
utils: add RbdUtils for the Ceph monitors of an RBD pool
weizhouapache 42c5aed
kvm: build the storage pool's Ceph monitors with RbdUtils
weizhouapache ed628c0
kvm: tell a missing object apart from an unreachable cluster in the R…
weizhouapache e9b6dda
utils: test the escaped colons of an IPv6 Ceph monitor without a port
weizhouapache 02fb3e8
Merge remote-tracking branch 'apache/main' into 24-kvm-ha-on-ceph
weizhouapache 324d2d8
kvm: name the RBD heartbeat objects after the GUID of the host
weizhouapache 78e4a2f
kvm: name the host id of the heartbeat checks heartBeatHostId
weizhouapache 4036374
Merge remote-tracking branch 'apache/main' into 24-kvm-ha-on-ceph
weizhouapache bbe5c92
kvm: check first that the Python bindings of librados and librbd are …
weizhouapache e3d603c
packaging: suggest, instead of require, the Python bindings of librad…
weizhouapache File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| #!/bin/bash | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| # Ceph RBD flavor of kvmheartbeat.sh/kvmsmpheartbeat.sh. | ||
| # | ||
| # There is no shared POSIX mount point to write a heartbeat file to when the | ||
| # primary storage pool is Ceph RBD, so the heartbeat timestamp is instead | ||
| # stored as a small RADOS object (one object per host) in the same RBD pool. | ||
| # Any host with a working path to the Ceph cluster can write/read this object, | ||
| # which gives the same semantics as the NFS/SharedMountPoint heartbeat file. | ||
|
|
||
| help() { | ||
| printf "Usage: $0 | ||
| -s ceph monitor host(s), comma separated | ||
| -o ceph/rbd pool name | ||
| -n cephx auth user (optional) | ||
| -k cephx auth key, base64 (optional, required if -n is set) | ||
| -h host | ||
| -r write/read hb log | ||
| -c cleanup | ||
| -t interval between read hb log\n" | ||
| exit 1 | ||
| } | ||
|
weizhouapache marked this conversation as resolved.
Outdated
|
||
| #set -x | ||
| MonHosts= | ||
| PoolName= | ||
| CephUser= | ||
| CephKey= | ||
| HostIP= | ||
| interval= | ||
| rflag=0 | ||
| cflag=0 | ||
|
|
||
| while getopts 's:o:n:k:h:t:rc' OPTION | ||
| do | ||
| case $OPTION in | ||
| s) | ||
| MonHosts="$OPTARG" | ||
| ;; | ||
| o) | ||
| PoolName="$OPTARG" | ||
| ;; | ||
| n) | ||
| CephUser="$OPTARG" | ||
| ;; | ||
| k) | ||
| CephKey="$OPTARG" | ||
| ;; | ||
| h) | ||
| HostIP="$OPTARG" | ||
| ;; | ||
| r) | ||
| rflag=1 | ||
| ;; | ||
| t) | ||
| interval="$OPTARG" | ||
| ;; | ||
| c) | ||
| cflag=1 | ||
| ;; | ||
| *) | ||
| help | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [ -z "$MonHosts" ] || [ -z "$PoolName" ] | ||
| then | ||
| exit 1 | ||
| fi | ||
|
|
||
| RadosOpts=(--mon-host "$MonHosts") | ||
| if [ -n "$CephUser" ] | ||
| then | ||
| RadosOpts+=(--id "$CephUser" --key "$CephKey") | ||
| fi | ||
|
weizhouapache marked this conversation as resolved.
Outdated
|
||
|
|
||
| hbObject="KVMHA-hb-$HostIP" | ||
|
weizhouapache marked this conversation as resolved.
Outdated
|
||
|
|
||
| write_hbLog() { | ||
| tmpFile=$(mktemp) | ||
| date +%s > "$tmpFile" | ||
| rados -p "$PoolName" "${RadosOpts[@]}" put "$hbObject" "$tmpFile" &> /dev/null | ||
|
weizhouapache marked this conversation as resolved.
Outdated
|
||
| rc=$? | ||
| rm -f "$tmpFile" | ||
| return $rc | ||
| } | ||
|
|
||
| check_hbLog() { | ||
| now=$(date +%s) | ||
| hb=$(rados -p "$PoolName" "${RadosOpts[@]}" get "$hbObject" - 2> /dev/null) | ||
| if ! [[ "$hb" =~ ^[0-9]+$ ]] | ||
| then | ||
| # Either the RADOS object doesn't exist yet (host never wrote a heartbeat) | ||
| # or the Ceph cluster can't be reached right now. Either way we can't | ||
| # confirm the host is alive, so fail safe and report it as DEAD. | ||
| return 255 | ||
| fi | ||
| diff=$(expr $now - $hb) | ||
| if [ $diff -gt $interval ] | ||
| then | ||
| return $diff | ||
|
weizhouapache marked this conversation as resolved.
Outdated
|
||
| fi | ||
| return 0 | ||
| } | ||
|
|
||
| if [ "$rflag" == "1" ] | ||
| then | ||
| check_hbLog | ||
| diff=$? | ||
| if [ $diff == 0 ] | ||
| then | ||
| echo "=====> ALIVE <=====" | ||
| else | ||
| echo "=====> Considering host as DEAD because last write to RADOS object [$hbObject] in pool [$PoolName] was [$diff] seconds ago, but the max interval is [$interval] <======" | ||
| fi | ||
| exit 0 | ||
| elif [ "$cflag" == "1" ] | ||
| then | ||
| /usr/bin/logger -t heartbeat "kvmheartbeat_rbd.sh will reboot system because it was unable to write the heartbeat to the Ceph RBD storage." | ||
| sync & | ||
| sleep 5 | ||
| echo b > /proc/sysrq-trigger | ||
| exit $? | ||
| else | ||
| write_hbLog | ||
| exit $? | ||
| fi | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.