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

added taking over incomplete volume parameters #359

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

Conversation

libc225so
Copy link

Hi,
I found out that when a new VM is to be created with a request for disks that are not in the ComputeProfile but simply added for example like this ( through hammer ) with: --volume='size=10GB' --volume='size=20GB' the disks do not show up properly in the json.

They show up like this:
"volumes_attributes"=>{
"0"=>{"storage_type"=>"hard_disk", "storage"=>"local-lvm", "controller"=>"virtio", "device"=>"0", "cache"=>"none", "size"=>"19GB", "id"=>"virtio0"},
"1"=>{"size"=>"10GB"},
"2"=>{"size"=>"20GB"}},

As an result disk 1 && 2 are disregarded and only the disk that has been mentioned in the ComputeProfile will get the size requested.

This patch adjusts the json to "copy" the settings from the first disk, into the next ones.

I Hope, you can consider this patch.
Thank you and regards,
Kees

@libc225so
Copy link
Author

Hi,
I tried to work with the comments from the pipeline, but I guess I need a little help here.
The only once that made sense to me were: "Space missing after comma" also it shows no line number so not too clear for me how to solve this.

@Manisha15
Copy link
Contributor

Hi, I tried to work with the comments from the pipeline, but I guess I need a little help here. The only once that made sense to me were: "Space missing after comma" also it shows no line number so not too clear for me how to solve this.

You can check here which lines are affected: https://github.com/theforeman/foreman_fog_proxmox/pull/359/files

value.each do |index, dev_specs|

# Only if this contains only 1 set like: {"size"=>"xxGB"}
if #{index} > 0 && dev_specs.keys.count == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be if index > 0 && dev_specs.keys.count == 1

new_data['volumes_attributes'] = volumes_attributes
end
end
return new_data
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to add return keyword as it is implicit.

Copy link
Author

Choose a reason for hiding this comment

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

Nice, I didn't know that .. This is one of my firsts ruby spinsels ;-)

@libc225so
Copy link
Author

Hi Manisha15, can this be merged into main now ?
Or what is the strategy ?
Thanks !

@Manisha15
Copy link
Contributor

Hi Manisha15, can this be merged into main now ? Or what is the strategy ? Thanks !

I am testing and reviewing it. Then I'll merge it. Can you please squash the commits in one commit and create an issue for it along with appending the commit message with fix: and adding issue no. You can refer to merged PRs for commit message.

@libc225so libc225so force-pushed the fix_extra_non_specified_disks branch from 6182649 to dedf741 Compare October 7, 2024 13:53
@libc225so
Copy link
Author

Hi
As requested, I opened a new issue with title: "Taking over incomplete volume parameters" and squashed all commits into 1 with comment: "fix: Taking over incomplete volume parameters"
I hope this is OK

@Manisha15
Copy link
Contributor

@libc225so There is no specific hammer cli command for proxmox. May I know the commands you used that gave the issue redarding volume attributes?

@libc225so
Copy link
Author

libc225so commented Oct 17, 2024

Hi Manisha15
Hammer is used in Foreman, so when instead of using the web interface and you want to create a new VM, you can issue something like this:
hammer host create --name blah ....

The options for the disk ( configured with --volume ), follow what is configured in the compute profile, but allows posibilities to address for different capacity.

If your compute profile contains 1 disk, then you will get 1 disk.

But there is an option ( simular as to use with VMWare ) to add extra disks, i.e. repeat the "--volume" parameter like this:

--volume="'size=19GB'"
--volume="'size=10GB'"
--volume="'size=20GB'"

So in this example, the 19GB refers to the disk from the compute profile
And the 10 && 20 are extra disks you want which have NO definition in the compute profile

But the parameters from hammer going to Foreman do not allow you to add any other information then just the size ..
The rest of the information comes from the compute profile

So the complete json that in the end is send to fog is this json string for the first disk.

"0"=>{"storage_type"=>"hard_disk", "storage"=>"local-lvm", "controller"=>"virtio", "device"=>"0", "cache"=>"none", "size"=>"19GB", "id"=>"virtio0"},

As said, the parameters for volume do not provide possibilities to add for instance the type / and or storage etc ...

So the only logical thing that happends is, that the json for disk 2 && 3 coming from Foreman to fog only contains the size parameter ( "1"=>{"size"=>"10GB"}, "2"=>{"size"=>"20GB"} )

But when this information is handed to fog, this is insufficient to create the disk in proxmox, because it also needs to know where and how to store that disk.

Normally if you create a second disk, you keep the disks in 1 place, so it makes sense to copy over the information provided in the 1st disk configuration to the requested number 2 and 3.

And that is exactly what the patch does, it fills in the missing parts in the json.

On the other hand, if the information is correct, i.e. you have 2 disks configured in your compute profile, then these will come in simular like that 1st one from above .. and the patch will not touch it, because it only works on the combination for "if index > 0 && dev_specs.keys.count == 1" ..

Hope this helps
Regards,
Kees

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.

2 participants