Skip to content
Open
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
35 changes: 22 additions & 13 deletions pkg/driver/controller_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,15 @@ func (driver *Driver) createVolume(
status.Error(codes.InvalidArgument,
fmt.Sprintf("Requested volume filesystem %s cannot be different than snapshot's parent volume filesystem %s", filesystem, parentVolFsType))
}

// CON-4206: Always inherit provisioning_type from parent volume when restoring from snapshot
// This ensures clone has same provisioning type as the original volume
if existingParentVolume.Config != nil {
if parentProvType, exists := existingParentVolume.Config["provisioning_type"]; exists {
createOptions["provisioning_type"] = parentProvType
}
}

// Create a clone from another volume
log.Infof("About to create a new clone '%s' from snapshot %s with options %+v", name, existingSnap.ID, createOptions)
volume, err := storageProvider.CloneVolume(name, description, "", existingSnap.ID, size, createOptions)
Expand Down Expand Up @@ -576,7 +585,7 @@ func (driver *Driver) createVolume(
}
log.Tracef("Found parent volume: %+v", existingParentVolume)

// CON-3010 If requested size for clone volume is less than parent volume size
// CON-3010 If requested size for clone volume is less than parent volume size
// then report error
if size < existingParentVolume.Size {
return nil,
Expand Down Expand Up @@ -910,21 +919,21 @@ func (driver *Driver) controllerPublishVolume(
existingNode, err := storageProvider.GetNodeContext(node.UUID)
if err != nil {
log.Errorf("Error retrieving the node info from the CSP. err: %s", err.Error())
return nil, status.Error(codes.Unavailable,
fmt.Sprintf("Error retrieving the node info for ID %s from the CSP, err: %s", node.UUID, err.Error()))
return nil, status.Error(codes.Unavailable,
fmt.Sprintf("Error retrieving the node info for ID %s from the CSP, err: %s", node.UUID, err.Error()))
}

// Configure access protocol defaulting to iSCSI when unspecified
var requestedAccessProtocol = volumeContext[accessProtocolKey]
if requestedAccessProtocol == "" {
// by default when no protocol specified make iscsi as default
requestedAccessProtocol = iscsi
log.Tracef("Defaulting to access protocol %s", requestedAccessProtocol)
} else if requestedAccessProtocol == "iscsi" {
requestedAccessProtocol = iscsi
} else if requestedAccessProtocol == "fc" {
requestedAccessProtocol = fc
}
var requestedAccessProtocol = volumeContext[accessProtocolKey]
if requestedAccessProtocol == "" {
// by default when no protocol specified make iscsi as default
requestedAccessProtocol = iscsi
log.Tracef("Defaulting to access protocol %s", requestedAccessProtocol)
} else if requestedAccessProtocol == "iscsi" {
requestedAccessProtocol = iscsi
} else if requestedAccessProtocol == "fc" {
requestedAccessProtocol = fc
}

if existingNode != nil {
log.Tracef("CSP has already been notified about the node with ID %s and UUID %s", existingNode.ID, existingNode.UUID)
Expand Down
13 changes: 13 additions & 0 deletions pkg/flavor/kubernetes/flavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hpe-storage/common-host-libs/chapi"
log "github.com/hpe-storage/common-host-libs/logger"
"github.com/hpe-storage/common-host-libs/model"
"github.com/hpe-storage/common-host-libs/util"
crd_v1 "github.com/hpe-storage/k8s-custom-resources/pkg/apis/hpestorage/v1"
crd_client "github.com/hpe-storage/k8s-custom-resources/pkg/client/clientset/versioned"
v1beta1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
Expand Down Expand Up @@ -557,6 +558,18 @@ func (flavor *Flavor) getClaimOverrideOptions(claim *v1.PersistentVolumeClaim, o
continue
}
}

// Convert override key to snake_case to check for snake_case variant
snakeCaseKey := util.ToSnakeCase(override)
if snakeCaseKey != override {
// If the snake_case variant is different from the override key,
// remove it to prevent conflicts after snake_case conversion
if _, exists := optionsMap[snakeCaseKey]; exists {
delete(optionsMap, snakeCaseKey)
}
}

// Apply the override
log.Infof("adding key: %v with override value: %v", override, annotation)
optionsMap[override] = annotation
}
Expand Down