Override memory method to convert KubeVirt format to bytes#186
Override memory method to convert KubeVirt format to bytes#186evgeni merged 1 commit intotheforeman:masterfrom
Conversation
|
Those CI tests are failing seems like unrelated to this change. |
|
Ci failing is unrelated, yes. This makes the edit of a host work for me, but now the "VMs" list on the CR throws |
|
Yes IT breaks on compute resource -> vms as here memory method is overriden and https://github.com/theforeman/foreman_kubevirt/blob/master/app/views/compute_resources_vms/show/_kubevirt.html.erb#L23 here with the current changes we pass the converted memory not the original one(which comes from fog). so technically converting it twice |
ee3d35f to
faf374f
Compare
|
yeah so, |
| # @param memory - The memory of the VM to convert | ||
| # | ||
| def convert_memory_to_bytes(memory) | ||
| return nil if memory.nil? || memory == '' |
There was a problem hiding this comment.
I think if we are completely skipping convert_memory method call here than isn't it better to remove convert_memory_to_bytes method from https://github.com/theforeman/foreman_kubevirt/blob/master/app/views/compute_resources_vms/show/_kubevirt.html.erb#L23 and let @vm.memory handle conversion itself?
faf374f to
ba5f053
Compare
| @@ -310,6 +310,13 @@ def max_memory | |||
| # @param memory - The memory of the VM to convert | |||
| # | |||
| def convert_memory_to_bytes(memory) | |||
There was a problem hiding this comment.
I think no users of convert_memory_to_bytes are left, so we can drop that method alltogether.
| alias_method :fog_memory, :memory | ||
|
|
||
| define_method(:memory) do | ||
| raw_memory = fog_memory |
There was a problem hiding this comment.
What's the reason to create a copy of the value here?
You're not modifying it and Server.memory should already be just accessing an attribute, so there seems to be no performance benefit to store it locally before accessing it?
Not blocking, just curious :)
There was a problem hiding this comment.
Fair point but no strong reason. I initially kept raw_memory for readability while working through the logic and to make debugging thing easier while validating the fallback behavior. but either way it's fine for me, so I simplified it. Thanks for the catch!
|
Tested using Two comments, but neither is blocking. |
ba5f053 to
e75ec0e
Compare
Fixes the host edit form displayed 'NaN MB' for KubeVirt VM memory
e75ec0e to
23bc517
Compare
evgeni
left a comment
There was a problem hiding this comment.
Final round with rubygem-foreman_kubevirt-0.5.1-1.20260218045458190635.pr186.2.g7b7375f.el9.noarch.rpm, still works fine.
Thanks!
Fixes the host edit form displayed 'NaN MB' for KubeVirt VM memory