Skip to content

Commit

Permalink
PWX-37650: Supports adding the pod name as a locator label for clone/…
Browse files Browse the repository at this point in the history
…snap restore

Signed-off-by: Adam Krpan <[email protected]>
  • Loading branch information
Pure-AdamuKaapan committed Jun 14, 2024
1 parent c0c3096 commit 5f9e92a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 8 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,14 @@ func (v *VolumeSpec) IsNFSProxyVolume() bool {
return v.GetProxySpec() != nil && v.GetProxySpec().NfsSpec != nil
}

// GetFADAPodName returns the FlashArray Pod name specified in the Pure Block spec, or empty if any fields are unspecified
func (v *VolumeSpec) GetFADAPodName() string {
if v.GetProxySpec() != nil && v.GetProxySpec().PureBlockSpec != nil {
return v.GetProxySpec().PureBlockSpec.PodName
}
return ""
}

// GetCloneCreatorOwnership returns the appropriate ownership for the
// new snapshot and if an update is required
func (v *VolumeSpec) GetCloneCreatorOwnership(ctx context.Context) (*Ownership, bool) {
Expand Down
6 changes: 4 additions & 2 deletions api/server/sdk/volume_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ func (s *VolumeServer) create(

// Create a snapshot from the parent
id, err = s.driver(ctx).Snapshot(ctx, parent.GetId(), false, &api.VolumeLocator{
Name: volName,
Name: volName,
VolumeLabels: locator.GetVolumeLabels(),
}, false)
if err != nil {
if err == kvdb.ErrNotFound {
Expand Down Expand Up @@ -335,7 +336,8 @@ func (s *VolumeServer) Clone(
}

locator := &api.VolumeLocator{
Name: req.GetName(),
Name: req.GetName(),
VolumeLabels: req.GetAdditionalLabels(),
}
source := &api.Source{
Parent: req.GetParentId(),
Expand Down
9 changes: 8 additions & 1 deletion csi/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const (
csiPVCNameKey = "csi.storage.k8s.io/pvc/name"
csiPVCNamespaceKey = "csi.storage.k8s.io/pvc/namespace"

// FADAPodLabelKey is a label added to volume locators in the case of FADA volume clone/snap restore
FADAPodLabelKey = "pure-pod-name" // Used to plumb in the pod name for volume cloning

volumeCapabilityMessageMultinodeVolume = "Volume is a multinode volume"
volumeCapabilityMessageNotMultinodeVolume = "Volume is not a multinode volume"
volumeCapabilityMessageReadOnlyVolume = "Volume is read only"
Expand Down Expand Up @@ -614,10 +617,14 @@ func (s *OsdCsiServer) CreateVolume(
}
newVolumeId = createResp.VolumeId
} else {
clonedMetadata := getClonedPVCMetadata(locator)
if spec.GetFADAPodName() != "" {
clonedMetadata[FADAPodLabelKey] = spec.GetFADAPodName()
}
cloneResp, err := volumes.Clone(ctx, &api.SdkVolumeCloneRequest{
Name: req.GetName(),
ParentId: source.Parent,
AdditionalLabels: getClonedPVCMetadata(locator),
AdditionalLabels: clonedMetadata,
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 5f9e92a

Please sign in to comment.