Skip to content

Support multiple ceph monitors - #6792

Merged
DaanHoogland merged 15 commits into
apache:mainfrom
weizhouapache:4.18-multiple-ceph-monitors
Oct 21, 2022
Merged

DaanHoogland merged 15 commits into
apache:mainfrom
weizhouapache:4.18-multiple-ceph-monitors

Conversation

@weizhouapache

@weizhouapache weizhouapache commented Sep 30, 2022 •

Copy link
Copy Markdown
Member

Description

This PR adds the support for multiple ceph monitors on UI and API.

image

What have been tested and work

What have been tested but do not work (I believe they are not caused by this PR)

  • vm live migration with volume to another RBD primary storage
  • direct download to RBD primary storage
  • VM snapshots on RBD primary storage

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Screenshots (if appropriate):

How Has This Been Tested?

in agent.log

Executing: qemu-img convert -O qcow2 -U --image-opts driver=raw,file.filename=rbd:cloudstack/c2a23920-9b0f-4e38-b68c-2ca2d040d9c5@79c0cb77-3733-4621-9555-9d8ba6d169b8:mon_host=10.0.32.254,10.0.32.207,10.0.32.208:auth_supported=cephx:id=cloudstack:key=AQDwHTNjjHXRKRAAJb+AToFr6x4a1AvKUc4Ksg==:rbd_default_format=2:client_mount_timeout=30 /mnt/7ceab3e8-1091-3c9e-84f9-2a1e20eb4051/snapshots/2/1490/79c0cb77-3733-4621-9555-9d8ba6d169b8

qemu-img: warning: short-form boolean option '10.0.32.207' deprecatedPlease use 10.0.32.207=on insteadqemu-img: Could not open 'driver=raw,file.filename=rbd:cloudstack/c2a23920-9b0f-4e38-b68c-2ca2d040d9c5@79c0cb77-3733-4621-9555-9d8ba6d169b8:mon_host=10.0.32.254,10.0.32.207,10.0.32.208:auth_supported=cephx:id=cloudstack:key=AQDwHTNjjHXRKRAAJb+AToFr6x4a1AvKUc4Ksg==:rbd_default_format=2:client_mount_timeout=30': Could not open 'rbd:cloudstack/c2a23920-9b0f-4e38-b68c-2ca2d040d9c5@79c0cb77-3733-4621-9555-9d8ba6d169b8:mon_host=10.0.32.254': No such file or directory
volume snapshot fails on RBD storage with the following error

qemu-img: Could not open 'driver=raw,file.filename=rbd:cloudstack/test_wei.img:mon_host=10.0.32.254:auth_supported=cephx:id=cloudstack:key=AQDwHTNjjHXRKRAAJb+AToFr6x4a1AvKUc4Ksg==:rbd_default_format=2:client_mount_timeout=30': Could not open 'rbd:cloudstack/test_wei.img:mon_host=10.0.32.254:auth_supported=cephx:id=cloudstack:key=AQDwHTNjjHXRKRAAJb+AToFr6x4a1AvKUc4Ksg==:rbd_default_format=2:client_mount_timeout=30': No such file or directory

However, it works without using image options

Therefore, do not pass the image options if the image format is not QCOW2 and LUKS.
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@weizhouapache weizhouapache mentioned this pull request Sep 30, 2022
1 of 5 tasks
@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 4326

@wido wido left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good! Just a few IPv6 requests

@codecov

codecov Bot commented Sep 30, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #6792 (7ad0b52) into main (713a236) will increase coverage by 0.03%.
The diff coverage is 55.17%.

@@             Coverage Diff              @@
##               main    #6792      +/-   ##
============================================
+ Coverage     10.60%   10.63%   +0.03%     
- Complexity     6849     6866      +17     
============================================
  Files          2466     2466              
  Lines        244549   244563      +14     
  Branches      38262    38265       +3     
============================================
+ Hits          25936    26014      +78     
+ Misses       215331   215262      -69     
- Partials       3282     3287       +5     
Impacted Files Coverage Δ
...ypervisor/kvm/resource/LibvirtDomainXMLParser.java 48.49% <0.00%> (ø)
...cycle/CloudStackPrimaryDataStoreLifeCycleImpl.java 0.00% <0.00%> (ø)
.../cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java 70.45% <70.00%> (+0.18%) ⬆️
...om/cloud/hypervisor/kvm/resource/LibvirtVMDef.java 67.04% <85.71%> (+2.88%) ⬆️
...hypervisor/kvm/resource/LibvirtStoragePoolDef.java 77.77% <100.00%> (+1.98%) ⬆️
...isor/kvm/resource/LibvirtStoragePoolXMLParser.java 60.65% <100.00%> (+60.65%) ⬆️
...apache/cloudstack/utils/qemu/QemuImageOptions.java 73.07% <100.00%> (+16.55%) ⬆️
...rg/apache/cloudstack/quota/QuotaStatementImpl.java 36.28% <0.00%> (-3.99%) ⬇️
... and 2 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@weizhouapache

Copy link
Copy Markdown
Member Author

@wido
I have made some changes to support ceph monitors with IPv6 addresses. some test cases are added as well.

I am seriously wondering if you are using ceph with IPv6 address in your production, because I faced some blocker issues in my testing
(1) failed to copy template to ceph storage when deploy a vm. this is fixed by 4a242a7
(2) failed to take volume snapshot, this is also fixed by commit 4a242a7
(3) failed to start vm
when I create storage pool, the ipv6 addresses must have brackets ("[" and "]"), but the brackets must be removed in vm definition xml. this is fixed by 34f8732

With all commits in this PR, the RBD storage pools with single or multiple Ipv4/ipv6 monitors work well in my testing.
I will continue on testing.
now it is ready for code reviews. @wido @DaanHoogland @rohityadavcloud @borisstoyanov

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a Jenkins job has been kicked to build packages. It will be bundled with

SystemVM template(s). I'll keep you posted as I make progress.

@sonarqubecloud

sonarqubecloud Bot commented Oct 5, 2022

Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 8 Code Smells

61.6% 61.6% Coverage
0.0% 0.0% Duplication

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✖️ el8 ✖️ debian ✔️ suse15. SL-JID 4355

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 4363

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test ubuntu22 kvm-ubuntu22

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a Trillian-Jenkins test job (ubuntu22 mgmt + kvm-ubuntu22) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-5075)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 41746 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6792-t5075-kvm-centos7.zip
Smoke tests completed. 104 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-5076)
Environment: kvm-ubuntu22 (x2), Advanced Networking with Mgmt server u22
Total time taken: 43956 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6792-t5076-kvm-ubuntu22.zip
Smoke tests completed. 103 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_08_upgrade_kubernetes_ha_cluster Failure 592.41 test_kubernetes_clusters.py

@weizhouapache

Copy link
Copy Markdown
Member Author

when testing this PR we have found an issue that

  • centos7 kvm host can NOT connect to ceph 17 (single monitor or multiple monitors)
  • centos7 kvm host can connecto to ceph 15

thanks @NuxRo

@NuxRo NuxRo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some testing, looks good to me!

@DaanHoogland
DaanHoogland requested a review from wido October 21, 2022 06:48

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

@DaanHoogland DaanHoogland added this to the 4.18.0.0 milestone Oct 21, 2022
@DaanHoogland DaanHoogland self-assigned this Oct 21, 2022
@DaanHoogland

Copy link
Copy Markdown
Contributor

@wido by the looks of it all your comments are met, right?

@yadvr
yadvr marked this pull request as ready for review October 21, 2022 08:23
@yadvr

yadvr commented Oct 21, 2022

Copy link
Copy Markdown
Member

LGTM - let's merge this @DaanHoogland ?

@DaanHoogland

Copy link
Copy Markdown
Contributor

We are not in "freeze" @rohityadavcloud ;)

@zap51

zap51 commented Jul 23, 2023 •

Copy link
Copy Markdown
Contributor

@rohityadavcloud @DaanHoogland A PR has been created on Ceph to include this.

weizhouapache added a commit to weizhouapache/cloudstack that referenced this pull request Oct 5, 2026
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).
weizhouapache added a commit to weizhouapache/cloudstack that referenced this pull request Oct 12, 2026
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).
weizhouapache added a commit that referenced this pull request Nov 25, 2026
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants