Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions internal/nvmeof/controller/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (cs *Server) CreateVolume(

backend := res.GetVolume()
volumeID := backend.GetVolumeId()

volumeContext := backend.GetVolumeContext()
defer func() {
// skip cleanup if there was no error
if err == nil {
Expand All @@ -141,11 +141,13 @@ func (cs *Server) CreateVolume(
}
}()

rbdImageName := res.GetVolume().GetVolumeContext()["imageName"]
rbdPoolName := res.GetVolume().GetVolumeContext()["pool"]
rbdImageName := volumeContext["imageName"]
rbdPoolName := volumeContext["pool"]
// can be empty. if it was defined in config-map the rbd csi driver would have set it already
rbdRadosNameSpace := res.GetVolume().GetVolumeContext()["radosNamespace"]

// Step 2: Setup NVMe-oF resources
nvmeofData, err := cs.createNVMeoFResources(ctx, req, rbdPoolName, rbdImageName)
nvmeofData, err := cs.createNVMeoFResources(ctx, req, rbdPoolName, rbdRadosNameSpace, rbdImageName)
if err != nil {
log.ErrorLog(ctx, "NVMe-oF resource setup failed for volumeID %s: %v", volumeID, err)

Expand Down Expand Up @@ -628,6 +630,7 @@ func (cs *Server) createNVMeoFResources(
ctx context.Context,
req *csi.CreateVolumeRequest,
rbdPoolName,
rbdRadosNameSpace,
rbdImageName string,
) (*nvmeof.NVMeoFVolumeData, error) {
// Step 1: Extract parameters (already validated)
Expand Down Expand Up @@ -697,7 +700,7 @@ func (cs *Server) createNVMeoFResources(
nvmeofData.ListenerInfo)

// Step 4: Create namespace and set its uuid
nsid, err := gateway.CreateNamespace(ctx, nvmeofData.SubsystemNQN, rbdPoolName, rbdImageName)
nsid, err := gateway.CreateNamespace(ctx, nvmeofData.SubsystemNQN, rbdPoolName, rbdRadosNameSpace, rbdImageName)
if err != nil {
return nil, fmt.Errorf("namespace creation failed: %w", err)
}
Expand Down
9 changes: 7 additions & 2 deletions internal/nvmeof/nvmeof.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ func (c *GatewayRpcClient) Destroy() error {
}

// CreateNamespace creates a namespace in a subsystem.
func (gw *GatewayRpcClient) CreateNamespace(ctx context.Context, subsystemNQN, poolName, imageName string,
func (gw *GatewayRpcClient) CreateNamespace(
ctx context.Context,
subsystemNQN string,
poolName, radosNamespace, imageName string,
) (uint32, error) {
log.DebugLog(ctx, "Creating namespace for RBD %s/%s in subsystem %s",
poolName, imageName, subsystemNQN)
Expand All @@ -125,7 +128,9 @@ func (gw *GatewayRpcClient) CreateNamespace(ctx context.Context, subsystemNQN, p
// DisableAutoResize: nil,
// ReadOnly: nil,
}

if radosNamespace != "" {
req.RadosNamespaceName = &radosNamespace
}
resp, err := gw.client.NamespaceAdd(ctx, req)
switch {
case err != nil:
Expand Down
2 changes: 1 addition & 1 deletion internal/nvmeof/tests/nvmeof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestRealGateway(t *testing.T) {
// Test create namespace
// poolName := "mypool"
// imageName := "test-image"
// nsID, err := client.CreateNamespace(ctx, testNQN, poolName, imageName)
// nsID, err := client.CreateNamespace(ctx, testNQN, poolName, radosNS, imageName)
// require.NoError(t, err)
// require.Greater(t, nsID, uint32(0), "Namespace ID should be greater than 0")

Expand Down
Loading