Skip to content
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

Implement Ceph multiple pools and tests #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GaetanF
Copy link

@GaetanF GaetanF commented Dec 23, 2024

Hello,

Following the issue #162, I have implemented the capability to handle multiple Ceph RBD Pool by using a comma-separated list on the ceph.conf file.

Regarding the Libvirt documentation, the host tag must be in the source tag and not after. I have fix them also.

I have also implemented the tests to handle the Ceph part by using a mock of the File object.

Feel free if you have questions

@@ -346,13 +346,13 @@ def to_xml

volumes.each_with_index do |volume, index|
target_device = "vd#{('a'..'z').to_a[index]}"
if ceph_args && volume.pool_name.include?(ceph_args["libvirt_ceph_pool"])
if ceph_args && ceph_args["libvirt_ceph_pool"]&.split(",")&.include?(volume.pool_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to fix this up in read_ceph_args so you don't do this in a loop. Same below for the monitor. Perhaps also add in .map(&:strip) so you can also use spaces between the values while you're at it.

Another thing is that libvirt_ceph_pools suggests it's singular while so perhaps store the result of that as libvirt_ceph_pools to indicate it's an array?

Copy link
Author

Choose a reason for hiding this comment

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

Ok ! I have updated the branch to move the split and verify keys in the read_ceph_args.

@@ -363,7 +363,7 @@ def to_xml
end
end

xml.target(:dev => target_device, :bus => args["bus_type"] == "virtio" ? "virtio" : "scsi")
xml.target(:dev => target_device, :bus => ceph_args["bus_type"] == "virtio" ? "virtio" : "scsi")
Copy link
Contributor

Choose a reason for hiding this comment

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

I merged this separate so it properly closed the issue. Doing 2 different things (fixing a bug and adding a new feature) in the same commit is something I prefer to avoid.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I haven't seen the fix when I have started to work on it. I will rebase the merge on it.

@ekohl ekohl linked an issue Dec 24, 2024 that may be closed by this pull request
@GaetanF GaetanF force-pushed the feature/handle_multiple_ceph_pools branch from 51d0a00 to cb6c1cb Compare December 24, 2024 10:11
Copy link
Contributor

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I think it would be good to have some fallback code for compatibility. If libvirt_ceph_pools isn't present, check for libvirt_ceph_pool and present it as libvirt_ceph_pools in ceph_args. I'm not sure if there's a deprecation mechanism, but it would be good to consider that too.

end

puts args
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like debug code

value = pair[1]
args[key] = value
key = pair[0].strip
if valid_keys.include?(key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to limit this? Wouldn't it be safe to just parse everything?

Comment on lines +4 to +8
if path == '/etc/foreman/ceph.conf'
return true
else
return RealFile.file(path)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

To remove some RuboCop concerns, perhaps reduce it to

Suggested change
if path == '/etc/foreman/ceph.conf'
return true
else
return RealFile.file(path)
end
path == '/etc/foreman/ceph.conf' || RealFile.file(path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ceph - Libvirt handle multiple pool
2 participants