Skip to content

Commit

Permalink
fix(frontend): do not allow npi controller for subsys with hostnqn
Browse files Browse the repository at this point in the history
Signed-off-by: Artsiom Koltun <artsiom.koltun@intel.com>
  • Loading branch information
artek-koltun authored and intelfisz committed Oct 9, 2023
1 parent 9ae3c2a commit 1be2642
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/frontend/nvme.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ func (c nvmeNpiTransport) Params(ctrlr *pb.NvmeController, subsys *pb.NvmeSubsys
errors.New("only physical_function 0 is supported")
}

if subsys.GetSpec().GetHostnqn() != "" {
return spdk.NvmfSubsystemAddListenerParams{},
errors.New("hostnqn for subsystem is not supported for npi")
}

result := spdk.NvmfSubsystemAddListenerParams{}
result.Nqn = subsys.GetSpec().GetNqn()
result.ListenAddress.Trtype = "npi"
Expand Down
25 changes: 24 additions & 1 deletion pkg/frontend/nvme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TestFrontEnd_CreateNvmeController(t *testing.T) {
errCode codes.Code
errMsg string
existingController *pb.NvmeController
hostnqn string
}{
"max_limit rw_iops_kiops is not supported": {
in: &pb.NvmeController{
Expand Down Expand Up @@ -510,14 +511,36 @@ func TestFrontEnd_CreateNvmeController(t *testing.T) {
errMsg: "only physical_function 0 is supported",
existingController: nil,
},
"non-empty hostnqn": {
in: &pb.NvmeController{
Spec: &pb.NvmeControllerSpec{
Endpoint: &pb.NvmeControllerSpec_PcieId{
PcieId: &pb.PciEndpoint{
PortId: wrapperspb.Int32(0),
PhysicalFunction: wrapperspb.Int32(0),
VirtualFunction: wrapperspb.Int32(0),
},
},
Trtype: pb.NvmeTransportType_NVME_TRANSPORT_PCIE,
NvmeControllerId: proto.Int32(1),
},
},
out: nil,
spdk: []string{},
errCode: codes.InvalidArgument,
errMsg: "hostnqn for subsystem is not supported for npi",
existingController: nil,
hostnqn: "nqn.2014-08.org.nvmexpress:uuid:feb98abe-d51f-40c8-b348-2753f3571d3c",
},
}

for testName, tt := range tests {
t.Run(testName, func(t *testing.T) {
tt.in = utils.ProtoClone(tt.in)
testEnv := createTestEnvironment(tt.spdk)
defer testEnv.Close()
testEnv.opiSpdkServer.nvme.Subsystems[testSubsystem.Name] = &testSubsystem
testEnv.opiSpdkServer.nvme.Subsystems[testSubsystem.Name] = utils.ProtoClone(&testSubsystem)
testEnv.opiSpdkServer.nvme.Subsystems[testSubsystem.Name].Spec.Hostnqn = tt.hostnqn
if tt.existingController != nil {
tt.existingController = utils.ProtoClone(tt.existingController)
tt.existingController.Name = testControllerName
Expand Down

0 comments on commit 1be2642

Please sign in to comment.