-
Notifications
You must be signed in to change notification settings - Fork 55
Create libvirt pool and volume on KVM host & libvirt config map update #499
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
Conversation
Hi @Saripalli-lavanya. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
95a4394
to
f7d6a28
Compare
f7d6a28
to
6756335
Compare
config/peerpods/peerpodssecret.yaml
Outdated
@@ -8,7 +8,6 @@ stringData: | |||
#CLOUD_PROVIDER: "libvirt" | |||
#LIBVIRT_URI: "qemu+ssh://[email protected]/system?no_verify=1" | |||
#LIBVIRT_NET: "default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LIBVIRT_NET also can be moved to peer-pods-cm right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review @bpradipt, Moved LIBVIRT_NET also into peer-pods-cm. Also updated description with some test outputs.
6756335
to
a62b470
Compare
/retest |
// libvirt ConfigMap Keys | ||
libvirtConfigMapKeys := []string{"CLOUD_PROVIDER"} | ||
libvirtConfigMapKeys := []string{"CLOUD_PROVIDER", "LIBVIRT_POOL", "LIBVIRT_VOL_NAME", "LIBVIRT_DIR_NAME"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
nit: typo in commit message s/udpate/update
Looks like the prow bot takes lgtm for the whole PR and not just for individual commit. I need to remove it so that it accidentally doesn't get merged before all reviews are done |
a62b470
to
b6927d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks, sorry for the late review
LGTM overall, I added a small logic suggestion, would be nice if considered IMHO :)
|| error_exit "Failed to start libvirt pool '${LIBVIRT_POOL}'." | ||
fi | ||
|
||
virsh -d 0 -c "${LIBVIRT_URI}" vol-create-as --pool "${LIBVIRT_POOL}" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is failing at this stage (as example, also the pool-start), means there will be a leftover pool which is not cleaned (and unusable) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @snir911, Thank you for review & suggestions, have updated code to clean up pool upon volume creation failure.
virsh -d 0 -c "${LIBVIRT_URI}" pool-destroy "${LIBVIRT_POOL}" || | ||
# Delete the libvirt volume | ||
virsh -d 0 -c "${LIBVIRT_URI}" vol-delete --pool "${LIBVIRT_POOL}" "${LIBVIRT_VOL_NAME}" || | ||
error_exit "Failed to delete volume '${LIBVIRT_VOL_NAME}' from pool '${LIBVIRT_POOL}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it fail here? or should it keep and try to delete the pool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added clean up
virsh -d 0 -c "${LIBVIRT_URI}" pool-undefine "${LIBVIRT_POOL}" || | ||
echo "Pool '${LIBVIRT_POOL}' destroyed successfully." | ||
|
||
virsh -d 0 -c "${LIBVIRT_URI}" pool-undefine "${LIBVIRT_POOL}" || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If pool exist we may destroy pool & volumes that was not created by the code.
Would it make sense to do the following:
If user didn't set LIBVIRT_VOL & LIBVIRT_POOL ->
create pool & vol named based on the cluster id e.g. vol_ab12ac ->
set the values to the configMap
This is similar to the approach we take when we create images
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user misses setting LIBVIRT_VOL and LIBVIRT_POOL, the controller will give an error and will not proceed further. However, as a preventive measure, we have added default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the defaults can be removed if we will create the pool/volume with specific naming, doing that will prevent accidental modification of unrelated volume/pools that are in use by other libvirtd clients
b6927d4
to
a22af99
Compare
New changes are detected. LGTM label has been removed. |
a22af99
to
ba5e6d1
Compare
Moving LIBVIRT_POOL, LIBVIRT_VOL_NAME & LIBVIRT_DIR_NAME variables into config map instead of secrets Signed-off-by: Saripalli Lavanya <[email protected]>
Added code to check if Libvirt pool and volume exists if not creating them through handler Signed-off-by: Saripalli Lavanya <[email protected]>
ba5e6d1
to
78a163c
Compare
@Saripalli-lavanya: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM , thanks, also pls see my comment for consideration as future change
Added script to Automatically create libvirt pool and volume on KVM host - Enhance the usability of the Libvirt provider for confidential container administrators #435
Adding some test log results :
If pool and volume already exsist:
Deleting test log result :