-
Notifications
You must be signed in to change notification settings - Fork 991
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
Fixes #34839 - Add support for VMware NVME Controllers #10168
Conversation
2b0d314
to
15201f1
Compare
15201f1
to
7b1d6ae
Compare
7b1d6ae
to
267a5f4
Compare
attrs["nvme_controllers"] = ctrls_and_vol[:controllers]&.select { |controller| controller[:type].include?("VirtualNVMEController") } | ||
attrs["scsi_controllers"] = ctrls_and_vol[:controllers]&.select { |controller| !controller[:type].include?("VirtualNVMEController") } |
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.
You can use #split
method to divide the controllers
part
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 have used #partition
instead, wasn't able to understand the use case #split
@@ -484,7 +485,7 @@ def parse_args(args) | |||
|
|||
# see #26402 - consume scsi_controller_type from hammer as a default scsi type | |||
scsi_type = args.delete(:scsi_controller_type) |
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.
We will need to create a generic option for Hammer too here: instead of scsi_controller_type
it would become controller_type
. Plus we will need to deprecate the older scsi_controller_type
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.
scsi_controller_type has been removed from compute attributes in this commit Its best we remove this part all together as we use scsi_controller
attribute to pass the type and the key
@@ -26,7 +26,18 @@ const initialState = Immutable({ | |||
volumes: [], | |||
}); | |||
|
|||
const availableControllerKeys = [1000, 1001, 1002, 1003, 1004]; | |||
const availableControllerKeys = [ | |||
1000, |
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.
Can you please give me a bit more details about this array and the meaning of the items in it?
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.
This is to assign the keys to scsi or nvme controllers. We can have max of 4 controllers each so the total number of available keys are 8.
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.
When I was in university my professor would reduce your grade if you used magic values. Anything other than 0, 1 or 2 needed to be a constant that described what the magic value actually was.
In Foreman that rule isn't strictly applied, but another way to write this would be:
Array.from({length: 8}, (value, index) => 1000 + index);
I'm not sure if it's that much clearer, but as I read the code it's a list of 8 numbers where the base number is 1000.
Having said that, how do you prevent a user from assigning 8 nvme controllers or 8 scsi controllers?
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.
That is handled by Rbvmomi. We dont place any restrictions from the UI or the api or hammer
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.
Since controller is ambiguos, I'd suggest to be a bit more explicit and name it something like normalize_vmware_storage_controller_attributes.rb
@@ -192,12 +192,13 @@ def nictypes | |||
} | |||
end | |||
|
|||
def scsi_controller_types | |||
def controller_types |
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.
storage_controller_types
?
267a5f4
to
28c3277
Compare
d4dfa53
to
d4c33a1
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.
Test failures look related.
volumes = {} | ||
ctrls_and_vol[:volumes].each_with_index do |vol, index| | ||
volumes[index.to_s] = vol | ||
end |
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.
volumes = {} | |
ctrls_and_vol[:volumes].each_with_index do |vol, index| | |
volumes[index.to_s] = vol | |
end | |
volumes = ctrls_and_vol[:volumes].each_with_index.to_h { |vol, index| [index.to_s, vol] } |
normalized['nvme_controllers'] = nvme_controllers.map.with_index do |ctrl, idx| | ||
[idx.to_s, ctrl] | ||
end.to_h |
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.
normalized['nvme_controllers'] = nvme_controllers.map.with_index do |ctrl, idx| | |
[idx.to_s, ctrl] | |
end.to_h | |
normalized['nvme_controllers'] = nvme_controllers.with_index.to_h do |ctrl, idx| | |
[idx.to_s, ctrl] | |
end |
Test cases are related to changes in the fog-vpshere. They all pass on my local and we can re-trigger them once the fog-vsphere changes are in. |
You can change this line here: Line 2 in 89a3f5f
If you point that to your git branch (using https://bundler.io/guides/git.html) then you can run CI here. Once a release of fog-vsphere it out, you can change the line to require that specific release which includes the feature. That way our packaging will either fail or pick it up properly. We have some automation in that area. |
4baa998
to
2eb9c33
Compare
f872498
to
bef42fa
Compare
@ekohl any objections to merging this? |
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 still think https://github.com/theforeman/foreman/pull/10168/files#r1624514222 is valid, but don't consider it blocking.
I'd prefer to rebase this because the fog-libvirt issues should be resolved. That should tell us if the host_js_test.rb
failure is relevant or not.
@girijaasoni can you please rebase? @ekohl as for the |
bef42fa
to
49fc393
Compare
@girijaasoni have you investigated the test failure? |
I don't think the test failure is related |
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.
We don't see the error in develop and it is explicitly about VMs so that makes me think the error is related. Could you provide a bit more reasoning why you think it's not related?
args = parse_args args | ||
args = args.deep_symbolize_keys |
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.
Nit
args = parse_args args | |
args = args.deep_symbolize_keys | |
args = parse_args(args).deep_symbolize_keys |
aa356e3
to
321c4ce
Compare
321c4ce
to
fe01eaa
Compare
fe01eaa
to
aa5a1ac
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.
Tests are still running, but 👍 once they're green.
Merged, thanks @girijaasoni ! |
blocked by PR
hammer doc PR
I put together a document for better understanding. Please feel free to go through it and provide suggestions/improvisations.
Ready for testing :D
Test cases need the fog-vsphere PR merge. They pass on my local and we can trigger them again after the merge of fog-vpshere PR!