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

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

Conversation

girijaasoni
Copy link
Contributor

@girijaasoni girijaasoni commented May 15, 2024

blocked by PR

Described better in the doc
Ready for testing :D

@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

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

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

def new_vm(args = {})
args = parse_args args
args = args.deep_symbolize_keys
args[:scsi_controllers] = [] if !args.key?(:scsi_controllers) && !args[:volumes].empty? && !unassigned_volumes?(args[:volumes])
Copy link
Member

Choose a reason for hiding this comment

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

A comment explaining why do you need to set scsi_controllers to an empty array would be nice here.

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

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