nvmeof: rearrangement create nvmeof resources#6237
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors NVMe-oF controller setup by moving NVMe-oF–specific parsing/initialization logic into the internal/nvmeof package, reducing controller responsibilities while preserving behavior.
Changes:
- Moved listeners JSON parsing/validation into
nvmeof.SetUpListeners(). - Extracted NVMe-oF volume data initialization into
(*NVMeoFVolumeData).SetNvmeofVolumeData(...). - Simplified controller-side validation and resource creation to call the new helpers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| internal/nvmeof/volume.go | Adds listener parsing/validation helper and a volume-data initialization method. |
| internal/nvmeof/controller/controllerserver.go | Replaces inline listener parsing and struct setup with calls into the nvmeof package. |
nixpanic
left a comment
There was a problem hiding this comment.
The Copilot doc changes are indeed nice improvements.
Left a few other comments as well.
| func validateListenersParameter(listenersJSON string) (uint, error) { | ||
| listeners, err := nvmeof.SetUpListeners(listenersJSON) | ||
| if err != nil { | ||
| return 0, err |
There was a problem hiding this comment.
have the function return an int and return -1 in case of an error? An int should be large enough to count all listeners.
| // SetUpListeners parses the listeners JSON and validates the required fields. | ||
| // It returns a slice of ListenerDetails or an error if the JSON is invalid | ||
| // or if required fields are missing. | ||
| func SetUpListeners(listenersJSON string) ([]ListenerDetails, error) { |
There was a problem hiding this comment.
Setup as one word.
This function can be tested with a unit-test too.
| return listeners, nil | ||
| } | ||
|
|
||
| func (v *NVMeoFVolumeData) SetNvmeofVolumeData(parameters map[string]string) error { |
There was a problem hiding this comment.
maybe call the function SetFromParameters? The double NVMeoF in the struct and function name should be prevented.
|
|
||
| func (v *NVMeoFVolumeData) SetNvmeofVolumeData(parameters map[string]string) error { | ||
| // set subsystem NQN | ||
| v.SubsystemNQN = parameters["subsystemNQN"] |
There was a problem hiding this comment.
Have you considered returning an error for required parameters?
There was a problem hiding this comment.
I thought about it, but at the beginning of CreateVolume() it checks if required parameters exist (in validateCreateVolumeRequest()). So, I thought maybe it is redundant to validate twice.
b059aa5 to
f80b032
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
internal/nvmeof/controller/controllerserver.go:495
- Comment grammar: "it possible" / "Also it possible" should be corrected (e.g., "it is possible" / "It is also possible") to keep inline docs clear and professional.
// validateListenersParameter parses the listeners JSON parameter and validates its contents.
// it possible to have zero listeners if networkMask is provided,
// because in that case the gateway will automatically create listeners
// for all interfaces in the specified network mask.
// Also it possible to have listeners with empty address or port,
// in that case the gateway will listen on all
8b521b5 to
eccf79a
Compare
|
@mergify rebase |
move `SetUpListeners()` to be in nvmeof package. there is no good reason for the controller to do the parsing and assigning. Signed-off-by: gadi-didi <gadi.didi@ibm.com>
Move NVMeoFVolumeData initialization logic from createNVMeoFResources() into a new SetNvmeofVolumeData() method on the struct. This makes createNVMeoFResources() shorter and more readable and maintains separation of concerns between controller operations and data structure initialization. No functional changes.. Signed-off-by: gadi-didi <gadi.didi@ibm.com>
added TestSetupListeners and TestSetFromParameters. Signed-off-by: gadi-didi <gadi.didi@ibm.com>
|
Deprecation notice: This pull request comes from a fork and was rebased using |
eccf79a to
145f5ff
Compare
✅ Branch has been successfully rebased |
|
@mergify queue |
Merge Queue Status🛑 Queue command has been cancelled |
|
/test ci/centos/k8s-e2e-external-storage/1.35 |
|
/test ci/centos/upgrade-tests-cephfs |
|
/test ci/centos/mini-e2e-helm/k8s-1.35 |
|
/test ci/centos/upgrade-tests-rbd |
|
/test ci/centos/mini-e2e/k8s-1.35 |
|
/test ci/centos/k8s-e2e-external-storage/1.34 |
|
/test ci/centos/k8s-e2e-external-storage/1.33 |
|
/test ci/centos/mini-e2e-helm/k8s-1.34 |
|
/test ci/centos/mini-e2e-helm/k8s-1.33 |
|
/test ci/centos/mini-e2e/k8s-1.34 |
|
/test ci/centos/mini-e2e/k8s-1.33 |
|
/retest ci/centos/mini-e2e/k8s-1.35 |
Failed in an unrelated test logs: |
|
/retest ci/centos/mini-e2e/k8s-1.35 |
Jenkins Slave was restarted 😞 |
|
Deprecation notice: This pull request comes from a fork and was queued with |
Merge Queue Status
This pull request spent 43 seconds in the queue, including 9 seconds running CI. Required conditions to merge
|
Clean up NVMe-oF controller code
Moved two chunks of NVMe-oF setup logic out of the controller and into the nvmeof package where they belong.
First commit: Moved listener parsing from controller into nvmeof package. The controller was doing JSON parsing and validation for listeners, which doesn't make sense—that's nvmeof-specific logic. Now the controller just calls nvmeof.SetUpListeners() and gets back the parsed data.
Second commit: Moved volume data initialization into its own method. The controller had a lot of lines of code setting up the
NVMeoFVolumeDatastruct inline. Pulled all that into a new SetNvmeofVolumeData() method on the struct. Controller now just creates an empty struct and calls the setup method.Both changes make the controller code shorter and keep nvmeof-specific stuff in the nvmeof package. No behavior changes, just moving code around.
need to test and check nothing broke.
Checklist:
guidelines in the developer
guide.
Request
notes
updated with breaking and/or notable changes for the next major release.
Show available bot commands
These commands are normally not required, but in case of issues, leave any of
the following bot commands in an otherwise empty comment in this PR:
/retest ci/centos/<job-name>: retest the<job-name>after unrelatedfailure (please report the failure too!)