Repository navigation
Conversation
RBD primary storage 연결시 + 및 / 기호를 -와 _ 로 변경하는 로직 개선
rbd multi monitor 지원
comma로 넣을 경우 userInfo 도 null 로 출력되는 현상 수정
rbd일 때 uuid 에러로 생성로직 변경
multi monitor인 경우 로직 변경
Primary Storage가 RBD인 경우에 Host HA가 동작하도록 기능개선
nfsstoragepool, rbdstoragepool 분리
storagepool > pooltype 제거 및 메서드명변경(getRbdMonIpAddress)
rbd pool auth 변경가능하도록 수정
nfs, rbd Storage hb모니터링 함께 되도록 수정
|
@blueorangutan package |
|
@sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 2208 |
|
@blueorangutan test |
|
@sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
This looks very interesting. I'll review this and get back. Give me a few days |
|
Trillian test result (tid-2879)
|
|
May I ask why you are not just looking up if there is a Watcher on RBD images? |
|
Thanks your review. @wido The reason is
|
Rbd primary ha
코딩규칙 및 요청사항 수정
runHeartbeatToPool 메서드명 수정
HA Cloudstack 요청사항 수정
wido
left a comment
There was a problem hiding this comment.
I am not convinced that this is the best route forward.
RBD already supports watchers and exclusive locking on images by default. If a host dies you should see within 30 sec or so if it is no longer watching a RBD image and also has not refreshed it's lock anymore.
This external script we are calling also does not support IPv6 (InetAddress) and would rely on external tooling.
Imho we should have each Host maybe just 'watch' a RBD image. Other hosts can check if there still is a watcher on that image. If not we can assume the Host has died.
Overall I think we should not merge this and rely on the things Ceph already has like exclusive locking and watchers on RBD images.
1. 각 호스트용 rbd 이미지(hb-hostip) 생성하여 watcher 감시 2. /etc/ceph 파일생성 대신 -c, -k 옵션을 사용하여 rbd 실행 3. keyring파일은 /etc/cloudstack/agent/ 경로에 생성
|
moved to 4.21.0.0 milestone |
|
@dhslove can you please advice if this PR is still valid and can we target this to 4.22 ? |
|
@harikrishna-patnala Sorry for the late reply. I think it would be better to close this PR and implement this feature in a new PR rather than maintain it. I currently have the tested code for this feature, so I think I can contribute it to the next CloudStack version. Please let me know your thoughts. |
thanks @dhslove , that would be great, go ahead. |
|
tbc |
maybe remove the milestone and project too ? |
|
Hello, any plans to continue working on this? |
@calvix |
Extend the existing KVM Host-HA heartbeat/VM-activity-check framework (currently limited to NetworkFilesystem and SharedMountPoint pools) to also cover RBD primary storage, based on the approach from the old PR apache#5862, adapted to the current HA architecture and reusing the multi-monitor Ceph support already added in apache#6792. - Add StoragePoolType.RBD to LIBVIRT_STORAGE_POOL_TYPES_WITH_HA_SUPPORT, which is the single switch that makes pool registration, KVMHAMonitor, and the CheckOnHostCommand/CheckVMActivityOnStoragePoolCommand wrappers treat RBD pools as HA-capable. - LibvirtStoragePool: build rbd/rados connection args (--mon-host, pool, and cephx --id/--key when set) from the pool's existing sourceHost/ sourceDir/authUsername/authSecret fields for the heartbeat and VM-activity checks, mirroring the conventions KVMPhysicalDisk already uses to talk to RBD. - Add kvmheartbeat_rbd.sh and kvmvmactivity_rbd.sh: RBD has no shared mount point to write a heartbeat file to, so the heartbeat timestamp is stored as a small RADOS object per host instead, and VM activity is detected via RBD watchers (rbd status) rather than file mtimes. - Minor: fix a stale "NFS storage pool" log message in KVMHAMonitor now that this path also runs for RBD. - Add LibvirtStoragePoolTest#testIsPoolSupportHA covering the new RBD case (no HA/heartbeat tests existed previously for any pool type).
Extend the existing KVM Host-HA heartbeat/VM-activity-check framework (currently limited to NetworkFilesystem and SharedMountPoint pools) to also cover RBD primary storage, based on the approach from the old PR apache#5862, adapted to the current HA architecture and reusing the multi-monitor Ceph support already added in apache#6792. - Add StoragePoolType.RBD to LIBVIRT_STORAGE_POOL_TYPES_WITH_HA_SUPPORT, which is the single switch that makes pool registration, KVMHAMonitor, and the CheckOnHostCommand/CheckVMActivityOnStoragePoolCommand wrappers treat RBD pools as HA-capable. - LibvirtStoragePool: build rbd/rados connection args (--mon-host, pool, and cephx --id/--key when set) from the pool's existing sourceHost/ sourceDir/authUsername/authSecret fields for the heartbeat and VM-activity checks, mirroring the conventions KVMPhysicalDisk already uses to talk to RBD. - Add kvmheartbeat_rbd.sh and kvmvmactivity_rbd.sh: RBD has no shared mount point to write a heartbeat file to, so the heartbeat timestamp is stored as a small RADOS object per host instead, and VM activity is detected via RBD watchers (rbd status) rather than file mtimes. - Minor: fix a stale "NFS storage pool" log message in KVMHAMonitor now that this path also runs for RBD. - Add LibvirtStoragePoolTest#testIsPoolSupportHA covering the new RBD case (no HA/heartbeat tests existed previously for any pool type).
* kvm: support Host HA on Ceph RBD primary storage Extend the existing KVM Host-HA heartbeat/VM-activity-check framework (currently limited to NetworkFilesystem and SharedMountPoint pools) to also cover RBD primary storage, based on the approach from the old PR #5862, adapted to the current HA architecture and reusing the multi-monitor Ceph support already added in #6792. - Add StoragePoolType.RBD to LIBVIRT_STORAGE_POOL_TYPES_WITH_HA_SUPPORT, which is the single switch that makes pool registration, KVMHAMonitor, and the CheckOnHostCommand/CheckVMActivityOnStoragePoolCommand wrappers treat RBD pools as HA-capable. - LibvirtStoragePool: build rbd/rados connection args (--mon-host, pool, and cephx --id/--key when set) from the pool's existing sourceHost/ sourceDir/authUsername/authSecret fields for the heartbeat and VM-activity checks, mirroring the conventions KVMPhysicalDisk already uses to talk to RBD. - Add kvmheartbeat_rbd.sh and kvmvmactivity_rbd.sh: RBD has no shared mount point to write a heartbeat file to, so the heartbeat timestamp is stored as a small RADOS object per host instead, and VM activity is detected via RBD watchers (rbd status) rather than file mtimes. - Minor: fix a stale "NFS storage pool" log message in KVMHAMonitor now that this path also runs for RBD. - Add LibvirtStoragePoolTest#testIsPoolSupportHA covering the new RBD case (no HA/heartbeat tests existed previously for any pool type). * kvm: address review comments on Host HA for Ceph RBD - pass the pool's monitor port to the RBD heartbeat/activity scripts, for every monitor, instead of relying on the default port - kvmheartbeat_rbd.sh: keep the heartbeat age out of the function return status, which wraps above 255 and made a long-stale heartbeat look ALIVE - remove pools from the HA monitor on deletion for all storage pool types with HA support, without trying to umount an empty mount path - make the missing-script error message generic - add unit tests for the RBD monitor list (IPv4, IPv6, mixed, with/without port) * kvm: validate input of the RBD Host HA scripts and the Ceph settings of the pool Follow-up to the review of the Host HA on Ceph RBD support: - kvmheartbeat_rbd.sh and kvmvmactivity_rbd.sh: exit with an error when the host IP, which names the RADOS objects, is missing (the self-fencing -c of the heartbeat script does not need it), or when a Ceph user is given without its key - LibvirtStoragePool: trim the Ceph monitors and skip empty entries, with or without a port; pass the Ceph user and key only if both are set and fail with a clear error if only one of them is - KVMHAMonitor: run umount without a shell when removing a pool - kvmvmactivity_rbd.sh: fix the -t help text and drop the unused field from the stored activity state - add unit tests for the monitor list (multiple IPv4 and IPv6 monitors, with and without a port, with spaces) and for the Ceph user and key handling * kvm: keep the Ceph key out of the logs and process list of the RBD Host HA checks, and harden the parsing Follow-up to the review of the Host HA on Ceph RBD support: - LibvirtStoragePool: do not add a port to Ceph monitors which have one already, and only wrap bare IPv6 addresses in square brackets; mask the Ceph key in the logged command - kvmheartbeat_rbd.sh, kvmvmactivity_rbd.sh: give the Ceph key to rados and rbd in a temporary keyfile instead of --key - kvmheartbeat_rbd.sh: require -t to be a number when checking a heartbeat - kvmvmactivity_rbd.sh: read the list of volumes without word splitting or globbing, skipping empty entries, and check if the activity object exists by the exit status of rados stat - add unit tests for monitors with a port and for the masked key * kvmvmactivity_rbd.sh: do not depend on python3, and tell failures from a DEAD host Follow-up to the review of the Host HA on Ceph RBD support: - list the watchers of an image from the plain output of rbd status instead of parsing json with python3 - fail with exit status 2, without a DEAD verdict, when the watchers or the activity state can not be read, so that it is not taken for a dead host - name in the DEAD message why the heartbeat did not show a live host - ignore an activity state which is not in the expected format - kvmheartbeat_rbd.sh, kvmvmactivity_rbd.sh: the Ceph key is used as it is, not decoded from base64, as the help text now says * kvmvmactivity_rbd.sh: do not decide on an activity state which could not be saved When the new activity state can not be written to the RADOS object, the next check would use an old state. Report it as not known whether the host is alive (exit status 2), as when the watchers can not be read. * kvm: rewrite the RBD Host HA scripts in Python, with a faster VM-activity check Follow-up to the review of the Host HA on Ceph RBD support: - kvmheartbeat_rbd.sh and kvmvmactivity_rbd.sh are now kvmheartbeat_rbd.py and kvmvmactivity_rbd.py, with the same options, output and exit status - the Ceph key is no longer an argument of the scripts: the agent gives it in the environment variable CEPH_KEY, and the scripts give it to rados and rbd in CEPH_ARGS, so it is not in the process list and no keyfile is needed; the heartbeat and the activity state are given to rados on standard input instead of temporary files - kvmvmactivity_rbd.py lists the watchers of the volumes over one connection with the Python bindings of librados and librbd (16 s instead of 97 s for 1000 volumes without a watcher), and runs rbd status for each volume if the bindings are not installed or can not be used - for a RBD pool, the volumes are given to kvmvmactivity_rbd.py in a temporary file with the new option -U, as they can be more than the 128 KiB which an argument of a command can have (about 3500 volumes), and as the whole command is written to the agent log at each check - the warnings of a failed heartbeat or VM-activity check no longer say that it may shut the host down: it is considered dead, which may trigger HA actions, such as fencing it and restarting its VMs on other hosts - add unit tests for the environment of the scripts, the Ceph user and key and the file with the volumes * kvm: choose the script which checks the VM activity by the type of the pool LibvirtCheckVMActivityOnStoragePoolCommandWrapper gave the script of the agent, kvmvmactivity.sh, to every pool, and LibvirtStoragePool replaced it with the script of RBD by itself. Choose the script in the wrapper: kvmvmactivity_rbd.py for a RBD pool, and the script of the agent for the other pools. If the script of RBD can not be found, the check fails with a message, instead of running without a script. LibvirtStoragePool uses the script which it is given. * kvm: use only the Python bindings of librados and librbd in the Host HA scripts on Ceph RBD The Host HA scripts for Ceph RBD read and write the heartbeat, the activity state and the watchers of the volumes over one connection, with the Python bindings of librados and librbd, instead of running the rados and rbd commands. The code is shared in kvmha_rbd.py. - Each operation has a timeout of 30 seconds (rados_osd_op_timeout, rados_mon_op_timeout, client_mount_timeout and the connect), so that an unreachable cluster does not block a check. - The cephx key is given to the bindings in their configuration. It is not an argument, and it is not in the environment of any other command. - Nothing is written to the standard error output, as the agent reads only the first line of the output of the scripts, and a message of librados would hide the DEAD verdict. - If the bindings are missing, the heartbeat is not written (exit 1), and the heartbeat check and the VM activity check are inconclusive (exit 2, no DEAD), so that a host is not considered dead because of it. - The cloudstack-agent packages require python3-rados and python3-rbd. * utils: add RbdUtils for the Ceph monitors of an RBD pool Everything that talks to Ceph needs the pool's monitors as a list the client can parse, and the rules are the same wherever that list is built: give each monitor the pool's port unless it names one already, and put a bare IPv6 address in square brackets so its own colons stay distinguishable from the separator before the port. The mon_host option of a disk's rbd: string wants the same list again, with ':' and ';' escaped, because those two separate the options of that string and its monitors. None of it depends on a storage pool, so collect it in RbdUtils as static methods with their unit tests, rather than leaving each caller to grow a copy that is right in a different set of cases. * kvm: build the storage pool's Ceph monitors with RbdUtils LibvirtStoragePool carried its own copy of the monitor-list logic. Call the shared one instead; the cases its tests covered are covered by RbdUtilsTest. * kvm: tell a missing object apart from an unreachable cluster in the RBD HA scripts Both checks treated every Ceph failure alike, so two very different answers came out the same. A host that has never written a heartbeat, and a cluster this host cannot reach, are not the same thing: only the first says anything about the host being checked. Raise ObjectNotFoundError when the RADOS object is absent and keep CephError for a cluster that cannot be read. The heartbeat check then reports the host DEAD only for the missing or empty object, and exits unknown when Ceph itself is out of reach, as the VM activity check already did. Let the activity check survive a volume that is gone. Asking an image that no longer exists for its watchers now yields nothing instead of failing the whole check, so a volume the management server still lists does not decide the fate of the others. If none of the images exist the host's state is genuinely unknown, which is a failure rather than an answer of "no activity". * utils: test the escaped colons of an IPv6 Ceph monitor without a port composeOptionForMonHosts escapes every ':' of a monitor, because the colons separate the options of the rbd: string. That includes the colons of an IPv6 address, also when the pool has no port to add. Test that case, and make addPortToRbdMonitor, which is only used by RbdUtils itself, protected. * kvm: name the RBD heartbeat objects after the GUID of the host The objects KVMHA-hb-<host> and KVMHA-ac-<host> were named after the private IPv4 address of the host, as the heartbeat files on NFS. A host which gets a new IP address would lose its heartbeat, and the objects of a removed host could not be found from its GUID. On RBD pools the agent writes the heartbeat under the GUID of the host as the management server knows it (the guid of the agent and the name of the resource), and the checks of the neighbours use the GUID of the HostTO. The other pool types still use the private IP address, so that the heartbeat files do not change in a rolling upgrade. * kvm: name the host id of the heartbeat checks heartBeatHostId The id of the heartbeat of a host is the GUID of the host on RBD pools, and its IP address on the other pools, so hostId could be mistaken for the id of the host. * kvm: check first that the Python bindings of librados and librbd are installed in the RBD HA scripts The packages python3-rados and python3-rbd are only suggested by the agent packages, so the scripts check at the start that they can be imported, and say which package is missing: - the heartbeat is not written (exit 1), with the reason - the heartbeat check and the VM activity check are inconclusive (exit 2, no DEAD), so the host is not considered dead The self-fencing (-c) does not use Ceph, so it does not need them. * packaging: suggest, instead of require, the Python bindings of librados and librbd python3-rados and python3-rbd are in the repository of Ceph, which is not configured on every host, so the agent could not be installed on EL8 without it, even without Ceph storage. The scripts of the Host HA on RBD check that they are installed. * KVM HA on Ceph: address review findings - Report "cannot tell" instead of dead when the RADOS heartbeat object is missing or malformed, or when the neighbour monitors no HA pool - Decide the verdict over all pools instead of the last one - Keep the HA monitor thread alive when a pool cannot run its heartbeat - Do not monitor an RBD pool whose Ceph Python bindings are missing - Share the heartbeat freshness rule (interval plus slack) between scripts - Keep deleting RBD and SharedMountPoint pools with their details - Move the RBD specific decisions into the storage pool * kvm: delete RBD and SharedMountPoint pools with their details again Only the removal from the HA monitor depends on the pool types with HA support. The delete itself stays as it was: only NFS uses the delete without the details, which unmounts the pool. The other types keep the delete which takes the details, so that the libvirt pool, which VMs may still use, is not destroyed. * kvm: allow a RBD heartbeat to be as old as a write which the agent lets take A write of the heartbeat which starts on time can take long when Ceph is slow: connecting and writing take up to 30 seconds each. The agent stops a write after heartbeat.update.timeout, so a heartbeat of a host which is alive can be older than the interval by that time. The agent gives heartbeat.update.timeout to the heartbeat and the VM activity scripts of RBD with -w, and a heartbeat is stale when it is older than the interval plus that time. Without -w the scripts use 60 seconds, the default of the property. * kvm: monitor a storage pool for HA again if it is not deleted A pool is removed from the HA monitor before it is deleted, so that no heartbeat is written while the pool is removed: the monitor holds its lock while it writes the heartbeats, so none is on going when the pool is removed from it, and a write which fails while the pool is unmounted could fence the host. If the delete does not succeed or throws, the pool is still there, but it was no longer monitored, so the host stopped writing its heartbeat on a pool which its VMs may still use. It is added to the monitor again. * kvm: give the Ceph key to the HA scripts only with its user addRbdConnectionArgs requires the Ceph user and its key to be either both set or both unset. The key in the environment of the scripts is now given under the same condition, and not whenever it is set. * kvm: report why the Ceph cluster could not be used by the RBD HA scripts If the cluster could not be connected, or the pool could not be opened, the error was dropped, and the operations failed with the name of an object, so that the output of the scripts did not say what was wrong. The reason of librados is now kept, and the scripts print it when a heartbeat can not be read or written, or when the activity of the VMs can not be checked. The exit status does not change: a failed read says that it is not known whether the host is alive (2), a failed write of the heartbeat is a failure (1). kvmvmactivity_rbd.py exits with 2 for an argument which is not valid, as it does for the other arguments and as its header says. The heartbeat is written as an integer timestamp explicitly. * kvm: keep a storage pool which is not deleted known to the manager A pool of a type with HA support (a libvirt storage pool) which is not deleted is monitored for HA again, as it is still there, but it was still removed from the information which the manager keeps to create the pool again. It now stays known as well. The other types keep being forgotten when their delete does not succeed: their adaptors return false if they have no such pool. The tests of the delete are reduced to the cases which differ. * kvm: note that the margin of the heartbeat age covers one write The agent writes the heartbeats of its pools one after another, so with several RBD pools on the same slow cluster the gap between two heartbeats of a pool can be longer than the margin, which covers one slow write. It is an edge case, which is now said next to the margin. * kvm: wait for a late heartbeat before reporting a host as dead The heartbeat of a host on RBD is judged against the interval plus the time which the agent lets a write take. A host whose agent is lost is investigated once, and a heartbeat which was still within that margin made the neighbour answer that the host is alive. A host which is in the Alert state without an owning management server is not investigated again, so HA never started for it. A heartbeat which is late (older than the interval) but not older than the limit is now waited for: the script reads it again every 5 seconds, and reports the host as alive as soon as a new heartbeat is there, or as dead when the limit has passed without one. The margin is unchanged, so a host which is alive but slow to write is still seen alive, and the answer no longer depends on when the question is asked. * KVM HA on RBD: an empty volume list is DEAD only if the heartbeat is stale kvmvmactivity_rbd.py reported a host with no volumes as DEAD even when the heartbeat could not be read (Ceph unreachable, object missing or invalid). That is not known, so it now exits with 2 as the other cases. Document in KVMStoragePoolManager why a delete which is not successful means that a pool with HA support is still there.
Description
This PR includes the features to provide high availability using Ceph RBD-based Primary Storage.
The KVM Host HA feature uses NFS Primary Storage. However, an additional storage consideration in KVM is Ceph RBD. This PR considers the following two to provide HA using RBD.
This PR includes the feature to enter multiple monitor addresses separated by commas in the RADOS Monitor item when registering RBD Primary Storage.
And it includes adding code to provide HA based on RBD Primary Storage.
To support RBD-based HA, add RBDStoragePool class to KVMHABase and use it to perform heartbeat check and activity check in the same way as NFS. Similar to how NFS writes hb and ac files to a KVMHA directory, RADOS commands are used to put hb and ac files into the RBD pool registered as primary storage.
To perform this heartbeat and activity check, kvmheartbeat_rbd.sh and kvmvmactivity_rbd.sh files were added. This is to clearly distinguish roles from the same shell file for nfs.
This PR is necessary to support agent-free HA based on Ceph RBD like NFS, even if the related PR #4978 is merged.
The execution result of the function can be checked in the attached image.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
RBD Multiple Monitor Support - Add RBD Primary Storage

RBD Multiple Monitor Support - RBD Primary Storage List

RBD Multiple Monitor Support - KVM Host Secret List

RBD Multiple Monitor Support - VM Disk XML(Multi RBD Monitor)

RBD Based KVM Host HA - One of Hosts Off

RBD Based KVM Host HA - Host Suspect State

RBD Based KVM Host HA - Host Down State
