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

Fixes #34839 - Add support for VMware NVME Controllers #10168

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

girijaasoni
Copy link
Contributor

@girijaasoni girijaasoni commented May 15, 2024

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!

@girijaasoni girijaasoni requested a review from a team as a code owner May 15, 2024 00:51
@github-actions github-actions bot added the UI label May 15, 2024
@girijaasoni girijaasoni marked this pull request as draft May 15, 2024 01:53
@girijaasoni girijaasoni marked this pull request as ready for review May 16, 2024 10:14
@ekohl ekohl changed the title Fixes #34839 - Add support for NVME Controllers Fixes #34839 - Add support for VMware NVME Controllers May 17, 2024
Comment on lines 14 to 15
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") }
Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

@girijaasoni girijaasoni May 30, 2024

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

Screenshot from 2024-05-30 15-46-54

@@ -26,7 +26,18 @@ const initialState = Immutable({
volumes: [],
});

const availableControllerKeys = [1000, 1001, 1002, 1003, 1004];
const availableControllerKeys = [
1000,
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

storage_controller_types?

Copy link
Member

@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.

Test failures look related.

Comment on lines 10 to 13
volumes = {}
ctrls_and_vol[:volumes].each_with_index do |vol, index|
volumes[index.to_s] = vol
end
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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] }

Comment on lines 748 to 750
normalized['nvme_controllers'] = nvme_controllers.map.with_index do |ctrl, idx|
[idx.to_s, ctrl]
end.to_h
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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

@girijaasoni
Copy link
Contributor Author

Test failures look related.

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.

@ekohl
Copy link
Member

ekohl commented Jun 3, 2024

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:

gem 'fog-vsphere', '>= 3.6.4', '< 4.0'

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.

@girijaasoni girijaasoni force-pushed the nvme_controllers branch 5 times, most recently from 4baa998 to 2eb9c33 Compare June 3, 2024 13:46
@girijaasoni girijaasoni force-pushed the nvme_controllers branch 3 times, most recently from f872498 to bef42fa Compare July 17, 2024 13:12
ShimShtein
ShimShtein previously approved these changes Jul 17, 2024
@ShimShtein
Copy link
Member

@ekohl any objections to merging this?

Copy link
Member

@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 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.

@ShimShtein
Copy link
Member

@girijaasoni can you please rebase?

@ekohl as for the delete - I prefer less side effects to the input params. so I am fine with the input remaining there.

@ekohl
Copy link
Member

ekohl commented Jul 22, 2024

@girijaasoni have you investigated the test failure?

@girijaasoni
Copy link
Contributor Author

@girijaasoni have you investigated the test failure?

I don't think the test failure is related

Copy link
Member

@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.

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?

Comment on lines 547 to +548
args = parse_args args
args = args.deep_symbolize_keys
Copy link
Member

Choose a reason for hiding this comment

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

Nit

Suggested change
args = parse_args args
args = args.deep_symbolize_keys
args = parse_args(args).deep_symbolize_keys

Copy link
Member

@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.

Tests are still running, but 👍 once they're green.

@ShimShtein ShimShtein merged commit 175b5f2 into theforeman:develop Jul 24, 2024
64 of 67 checks passed
@ShimShtein
Copy link
Member

Merged, thanks @girijaasoni !

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

Successfully merging this pull request may close these issues.

6 participants