Closed cdfmlr closed 2 weeks ago
@cdfmlr Thanks for the contribution and good PR description.
I will have a look as soon as I get a chance. In the mean time, would you mind documenting breaking changes (disks, ports) in docs/upgrades_notes.rst
?
would you mind documenting breaking changes (disks, ports) in
docs/upgrades_notes.rst
?
Sure, I will add it recently.
Attention: Patch coverage is 36.79245%
with 134 lines
in your changes are missing coverage. Please review.
Project coverage is 83.25%. Comparing base (
6f1f83d
) to head (0b07480
).
@cdfmlr Thanks.
I had a look again. It mostly looks good, but there are a couple of improvements which can be made:
_create_node()
functionality could be refactored into multiple smaller methods. Right now the method is very large and complex.@Kami Thank you for the review. Indeed, the create_node()
looks clumsy. I've actually started refactoring it, but recent higher priority tasks have delayed its completion.
Also, at the moment, I'm unable to add more test cases due to these priority. However, there are some existing test cases for _deep_merge_dict
and _memory_in_MB
that I believe were copied from our other projects. I plan to incorporate these tests soon.
Despite the problems with code readability and test coverage, we've been using this code in a production environment for several months. It has been performing well and handling a considerable number of situations that aren't covered by the test cases.
@cdfmlr Thanks.
Do you happen to have any ETA when you will be to add some more tests + refactor the code a bit? Since I'm planning to do a v3.9.0 release this week.
@Kami sorry for my delay.
I have added more tests covering the helper functions (_deep_merge_dict
and _memory_in_MB
) and some typical unhappy code paths. The _create_node()
method has been refactored into smaller functions as well. Meanwhile, a useful new feature to set cpu/mem requests and limits separately is introduced and tested.
@cdfmlr Thanks for adding those changes.
I added a couple of more comments. It's mostly a couple of small things, plus the potential security issue with possible YAML injection in case the pub key or password is supplied by the end user and not sanitized before being passed to the Libcloud code.
Merged into trunk. Thanks.
Enhance
KubeVirtNodeDriver
Compute DriverDescription
This pull request brings several improvements to the
create_node
method and related functions within theKubeVirtNodeDriver
(libcloud/compute/drivers/kubevirt.py
).Features added to
KubeVirtNodeDriver.create_node
:NodeDriver
class:size: NodeSize
parameter, while retaining legacy compatibility withex_cpu
andex_memory
.auth: NodeAuthSSHKey|NodeAuthPassword
parameter.deploy_node
):KubeVirtNodeDriver
now supports node deployment automatically, benefiting from the above compatibility changes.ex_disks
parameter to align with the related KubeVirt API, making it compatible with any volume types rather than hardcoded support for limited volume or disk types (previously onlypersistentVolumeClaim
was supported).ex_template
parameter, allowing users to customize the entire Kubernetes object declaring the virtual machine. This is particularly useful for:Fixes:
_to_node
: Improved the logic for parsing memory, eliminating crashes on virtual machines with more than 1 GiB RAM.create_node
: (==Breaking change==) Renamed the parameter fromports
toex_ports
.Addressed various bugs in thecreate_node
method, which were eliminated during the refactor and implementation of new features.Other Changes:
libcloud/compute/drivers/kubevirt.py
:KubeVirtNodeSize
function to assist in constructingNodeSize
instances forKubeVirtNodeDriver
.KubeVirtNodeImage
function to help constructNodeImage
instances forKubeVirtNodeDriver
.DISK_TYPES
out of thecreate_node
and exported it, enabling users to access a list of supported disk types.libcloud/test/compute/test_kubevirt.py
:create_node
method: This method was not tested previously.Status
Checklist (tick everything that applies)