Skip to content

Commit

Permalink
Initial commit for snapshot functionality (#94)
Browse files Browse the repository at this point in the history
* initial commit for snapshot functionality

Signed-off-by: Meghna Singh <[email protected]>

* Add volume content source

Signed-off-by: Meghna Singh <[email protected]>

* fix fmt failure

Signed-off-by: Meghna Singh <[email protected]>

* fix fmt

Signed-off-by: Meghna Singh <[email protected]>

* fix fmt

Signed-off-by: Meghna Singh <[email protected]>

* edit makefile

Signed-off-by: Meghna Singh <[email protected]>

* edit makefile

Signed-off-by: Meghna Singh <[email protected]>

* edit makefile

Signed-off-by: Meghna Singh <[email protected]>

* fix sanity

Signed-off-by: Meghna Singh <[email protected]>

* address review comments

Signed-off-by: Meghna Singh <[email protected]>

* address review comments

Signed-off-by: Meghna Singh <[email protected]>

* Update dependency

Signed-off-by: Meghna Singh <[email protected]>

* Update dependency

Signed-off-by: Meghna Singh <[email protected]>

Signed-off-by: Meghna Singh <[email protected]>
  • Loading branch information
meghnasiingh authored Sep 22, 2022
1 parent e67ef77 commit 05199f7
Show file tree
Hide file tree
Showing 54 changed files with 1,597 additions and 595 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export GO111MODULE=$(GO111MODULE_FLAG)

export LINT_VERSION="1.45.2"

GOFILES=$(shell find . -type f -name '*.go' -not -path "./vendor/*")

COLOR_YELLOW=\033[0;33m
COLOR_RESET=\033[0m

Expand All @@ -59,21 +61,20 @@ driver: deps buildimage
deps:
echo "Installing dependencies ..."
@if ! which golangci-lint >/dev/null || [[ "$$(golangci-lint --version)" != *${LINT_VERSION}* ]]; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v${LINT_VERSION}; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${LINT_VERSION}; \
fi

.PHONY: fmt
fmt: lint
$(GOPATH)/bin/golangci-lint run --disable-all --enable=gofmt --timeout 600s
@if [ -n "$$($(GOPATH)/bin/golangci-lint run)" ]; then echo 'Please run ${COLOR_YELLOW}make dofmt${COLOR_RESET} on your code.' && exit 1; fi
gofmt -l ${GOFILES}

.PHONY: dofmt
dofmt:
$(GOPATH)/bin/golangci-lint run --disable-all --enable=gofmt --fix --timeout 600s

.PHONY: lint
lint:
$(GOPATH)/bin/golangci-lint run --timeout 600s
hack/verify-golint.sh

.PHONY: build
build:
Expand Down
9 changes: 8 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"time"

cloudProvider "github.com/IBM/ibm-csi-common/pkg/ibmcloudprovider"
nodeInfoManager "github.com/IBM/ibm-csi-common/pkg/metadata"
"github.com/IBM/ibm-csi-common/pkg/metrics"
mountManager "github.com/IBM/ibm-csi-common/pkg/mountmanager"
"github.com/IBM/ibm-csi-common/pkg/utils"
Expand Down Expand Up @@ -103,9 +104,15 @@ func handle(logger *zap.Logger) {
// Get new instance for the Mount Manager
mounter := mountManager.NewNodeMounter()

nodeName := os.Getenv("KUBE_NODE_NAME")

nodeInfo := nodeInfoManager.NodeInfoManager{
NodeName: nodeName,
}

statUtil := &(driver.VolumeStatUtils{})

err = ibmCSIDriver.SetupIBMCSIDriver(ibmcloudProvider, mounter, statUtil, nil, logger, csiConfig.CSIDriverName, vendorVersion)
err = ibmCSIDriver.SetupIBMCSIDriver(ibmcloudProvider, mounter, statUtil, nil, &nodeInfo, logger, csiConfig.CSIDriverName, vendorVersion)
if err != nil {
logger.Fatal("Failed to initialize driver...", zap.Error(err))
}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/kubernetes-sigs/ibm-vpc-block-csi-driver
go 1.18

require (
github.com/IBM/ibm-csi-common v1.0.1-beta7
github.com/IBM/ibmcloud-volume-interface v1.0.1-beta5
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta7
github.com/IBM/ibm-csi-common v1.0.0-beta21
github.com/IBM/ibmcloud-volume-interface v1.0.1-beta7
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta10
github.com/container-storage-interface/spec v1.5.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/google/uuid v1.1.2
Expand All @@ -16,6 +16,7 @@ require (
golang.org/x/net v0.0.0-20211209124913-491a49abca63
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e
google.golang.org/grpc v1.36.1
google.golang.org/protobuf v1.27.1
k8s.io/kubernetes v1.21.0
k8s.io/mount-utils v0.21.0
)
Expand Down Expand Up @@ -78,7 +79,6 @@ require (
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
15 changes: 6 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7 h1:eHgfQl6IeSmzWUyiSi13CvoFYsovoyq
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM/go-sdk-core/v5 v5.9.1 h1:06pXbD9Rgmqqe2HA5YAeQbB4eYRRFgIoOT+Kh3cp1zo=
github.com/IBM/go-sdk-core/v5 v5.9.1/go.mod h1:axE2JrRq79gIJTjKPBwV6gWHswvVptBjbcvvCPIxARM=
github.com/IBM/ibm-csi-common v1.0.1-beta7 h1:phljcQfBBKtG6F2Q/hiqayrWJC+w0EtNvUWCXGsiox0=
github.com/IBM/ibm-csi-common v1.0.1-beta7/go.mod h1:k6IHdSHGnsnGOxzqir3n9kczW+ttL+KcRZh/chLyyuk=
github.com/IBM/ibmcloud-volume-interface v1.0.1-beta5 h1:XPNIrp4g7oEx7QOy6eB98jZs7n1tB6DTsUjEigOhouM=
github.com/IBM/ibmcloud-volume-interface v1.0.1-beta5/go.mod h1:v1aT8G3Tib8pCwdr9VweNFYa94GejBuqIVTysoaVI0g=
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta7 h1:3cQCvlTx9fQhBDYm2bn51nebRrLgZGwfAzLu7Zp/gvc=
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta7/go.mod h1:CFBvpt4SKwf0mQg3u53qkZ5SxZH9gZSfdhWBa8GIP3Y=
github.com/IBM/ibm-csi-common v1.0.0-beta21 h1:nLBcEr9+CRmWRXI3Rst7g7fbe5UCEzmzPVeDx6tqc48=
github.com/IBM/ibm-csi-common v1.0.0-beta21/go.mod h1:RdN1YJT50yxT1BCPMF6czifMva4oXlPCJWRmVIoikNE=
github.com/IBM/ibmcloud-volume-interface v1.0.1-beta7 h1:xnGyxnRiX1yj64rCaYRZ4txlx6lTR6l3BONwKMHH8h0=
github.com/IBM/ibmcloud-volume-interface v1.0.1-beta7/go.mod h1:v1aT8G3Tib8pCwdr9VweNFYa94GejBuqIVTysoaVI0g=
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta10 h1:AB2NN74hdad32FMPubZSwHM7A67OkFqD7PMZETRaixs=
github.com/IBM/ibmcloud-volume-vpc v1.0.1-beta10/go.mod h1:me1rd/j1kVvBAUYestM1HfJaZ/RzT7k9pUd2PsfNtfQ=
github.com/IBM/secret-common-lib v1.0.3 h1:rhhAtAE1ANSuxhA8Nulzzc2IbXWHGE8reoRSr98rRi8=
github.com/IBM/secret-common-lib v1.0.3/go.mod h1:uoYY5M9G1nJVT8ytPIicdTUujcBXKldBw7ijWolU0yU=
github.com/IBM/secret-utils-lib v1.0.2 h1:AdhKHo/bMmFLMz7+ZjnqSUHuU22CMQsG5meddvwKaV8=
Expand Down Expand Up @@ -177,8 +177,6 @@ github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/elazarl/goproxy v0.0.0-20191011121108-aa519ddbe484/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down Expand Up @@ -594,7 +592,6 @@ github.com/quobyte/api v0.1.8/go.mod h1:jL7lIHrmqQ7yh05OJ+eEEdHr0u/kmT1Ff9iHd+4H
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/robfig/cron v1.1.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rubiojr/go-vhd v0.0.0-20200706105327-02e210299021/go.mod h1:DM5xW0nvfNNm2uytzsvhI3OnX8uzaRAg8UX/CnDqbto=
github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
Expand Down
163 changes: 154 additions & 9 deletions pkg/ibmcsidriver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ func (csiCS *CSIControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
return nil, commonError.GetCSIError(ctxLogger, commonError.InternalError, requestID, err)
}

volumeSource := req.GetVolumeContentSource()
if volumeSource != nil {
if _, ok := volumeSource.GetType().(*csi.VolumeContentSource_Snapshot); !ok {
return nil, commonError.GetCSIError(ctxLogger, commonError.UnsupportedVolumeContentSource, requestID, nil)
}
sourceSnapshot := volumeSource.GetSnapshot()
if sourceSnapshot == nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.VolumeInvalidArguments, requestID, nil)
}
requestedVolume.SnapshotID = sourceSnapshot.GetSnapshotId()
}

existingVol, err := checkIfVolumeExists(session, *requestedVolume, ctxLogger)
if existingVol != nil && err == nil {
ctxLogger.Info("Volume already exists", zap.Reflect("ExistingVolume", existingVol))
Expand All @@ -128,6 +140,9 @@ func (csiCS *CSIControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
// Create volume
volumeObj, err := session.CreateVolume(*requestedVolume)
if err != nil {
if providerError.RetrivalFailed == providerError.GetErrorType(err) {
return nil, commonError.GetCSIError(ctxLogger, commonError.ObjectNotFound, requestID, err, "creation")
}
return nil, commonError.GetCSIError(ctxLogger, commonError.InternalError, requestID, err, "creation")
}

Expand Down Expand Up @@ -418,30 +433,160 @@ func (csiCS *CSIControllerServer) ControllerGetCapabilities(ctx context.Context,
func (csiCS *CSIControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {
ctxLogger, requestID := utils.GetContextLogger(ctx, false)
// populate requestID in the context
_ = context.WithValue(ctx, provider.RequestID, requestID)
ctx = context.WithValue(ctx, provider.RequestID, requestID)
ctxLogger.Info("CSIControllerServer-CreateSnapshot... ", zap.Reflect("Request", *req))
defer metrics.UpdateDurationFromStart(ctxLogger, "CreateSnapshot", time.Now())

snapshotName := req.GetName()
if len(snapshotName) == 0 {
return nil, commonError.GetCSIError(ctxLogger, commonError.MissingSnapshotName, requestID, nil)
}

sourceVolumeID := req.GetSourceVolumeId()
if len(sourceVolumeID) == 0 {
return nil, commonError.GetCSIError(ctxLogger, commonError.MissingSourceVolumeID, requestID, nil)
}

ctxLogger.Info("CSIControllerServer-CreateSnapshot", zap.Reflect("Request", *req))
return nil, commonError.GetCSIError(ctxLogger, commonError.MethodUnimplemented, requestID, nil, "CreateSnapshot")
// Validate if volume Already Exists
session, err := csiCS.CSIProvider.GetProviderSession(ctx, ctxLogger)
if err != nil {
if userError.GetUserErrorCode(err) == string(utilReasonCode.EndpointNotReachable) {
return nil, commonError.GetCSIError(ctxLogger, commonError.EndpointNotReachable, requestID, err)
}
if userError.GetUserErrorCode(err) == string(utilReasonCode.Timeout) {
return nil, commonError.GetCSIError(ctxLogger, commonError.Timeout, requestID, err)
}
return nil, commonError.GetCSIError(ctxLogger, commonError.InternalError, requestID, err)
}

snapshot, err := session.GetSnapshotByName(snapshotName)
if snapshot != nil {
if snapshot.VolumeID != sourceVolumeID {
return nil, commonError.GetCSIError(ctxLogger, commonError.SnapshotAlreadyExists, requestID, err, snapshotName, sourceVolumeID)
}
ctxLogger.Info("Snapshot with name already exist for volume", zap.Reflect("SnapshotName", snapshotName), zap.Reflect("VolumeID", sourceVolumeID))
return createCSISnapshotResponse(*snapshot), nil
}
snapshotParameters := provider.SnapshotParameters{}
snapshotParameters.Name = snapshotName
snapshotTags := map[string]string{
"name": snapshotName,
}
snapshotParameters.SnapshotTags = snapshotTags

snapshot, err = session.CreateSnapshot(sourceVolumeID, snapshotParameters)

if err != nil {
return nil, commonError.GetCSIError(ctxLogger, commonError.InternalError, requestID, err, "creation")
}
return createCSISnapshotResponse(*snapshot), nil
}

// DeleteSnapshot ...
func (csiCS *CSIControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) {
ctxLogger, requestID := utils.GetContextLogger(ctx, false)
// populate requestID in the context
_ = context.WithValue(ctx, provider.RequestID, requestID)
ctx = context.WithValue(ctx, provider.RequestID, requestID)
defer metrics.UpdateDurationFromStart(ctxLogger, "DeleteSnapshot", time.Now())
ctxLogger.Info("CSIControllerServer-DeleteSnapshot... ", zap.Reflect("Request", *req))

ctxLogger.Info("CSIControllerServer-DeleteSnapshot", zap.Reflect("Request", *req))
return nil, commonError.GetCSIError(ctxLogger, commonError.MethodUnimplemented, requestID, nil, "DeleteSnapshot")
// Validate arguments
snapshotID := req.GetSnapshotId()
if len(snapshotID) == 0 {
return nil, commonError.GetCSIError(ctxLogger, commonError.EmptySnapshotID, requestID, nil)
}

// get the session
session, err := csiCS.CSIProvider.GetProviderSession(ctx, ctxLogger)
if err != nil {
if userError.GetUserErrorCode(err) == string(utilReasonCode.EndpointNotReachable) {
return nil, commonError.GetCSIError(ctxLogger, commonError.EndpointNotReachable, requestID, err)
}
if userError.GetUserErrorCode(err) == string(utilReasonCode.Timeout) {
return nil, commonError.GetCSIError(ctxLogger, commonError.Timeout, requestID, err)
}
return nil, commonError.GetCSIError(ctxLogger, commonError.InternalError, requestID, err)
}

snapshot := &provider.Snapshot{}
snapshot.SnapshotID = snapshotID
err = session.DeleteSnapshot(snapshot)
if err != nil {
if providerError.RetrivalFailed == providerError.GetErrorType(err) {
ctxLogger.Info("Snapshot not found. Returning success without deletion...")
return &csi.DeleteSnapshotResponse{}, nil
}
return nil, commonError.GetCSIError(ctxLogger, commonError.InternalError, requestID, err)
}
return &csi.DeleteSnapshotResponse{}, nil
}

// ListSnapshots ...
func (csiCS *CSIControllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) {
ctxLogger, requestID := utils.GetContextLogger(ctx, false)
// populate requestID in the context
_ = context.WithValue(ctx, provider.RequestID, requestID)
ctx = context.WithValue(ctx, provider.RequestID, requestID)
ctxLogger.Info("CSIControllerServer-ListSnapshots...", zap.Reflect("Request", *req))
defer metrics.UpdateDurationFromStart(ctxLogger, metrics.FunctionLabel("ListSnapshots"), time.Now())

session, err := csiCS.CSIProvider.GetProviderSession(ctx, ctxLogger)
if err != nil {
if userError.GetUserErrorCode(err) == string(utilReasonCode.EndpointNotReachable) {
return nil, commonError.GetCSIError(ctxLogger, commonError.EndpointNotReachable, requestID, err)
}
if userError.GetUserErrorCode(err) == string(utilReasonCode.Timeout) {
return nil, commonError.GetCSIError(ctxLogger, commonError.Timeout, requestID, err)
}
return nil, commonError.GetCSIError(ctxLogger, commonError.InternalError, requestID, err)
}

ctxLogger.Info("CSIControllerServer-ListSnapshots", zap.Reflect("Request", *req))
return nil, commonError.GetCSIError(ctxLogger, commonError.MethodUnimplemented, requestID, nil, "ListSnapshots")
entries := []*csi.ListSnapshotsResponse_Entry{}
snapshotID := req.GetSnapshotId()
if len(snapshotID) != 0 {
snapshot, err := session.GetSnapshot(snapshotID)
if snapshot == nil {
return &csi.ListSnapshotsResponse{}, nil
}
if providerError.RetrivalFailed == providerError.GetErrorType(err) {
ctxLogger.Info("Snapshot not found. Returning success ...")
return &csi.ListSnapshotsResponse{}, nil
}
return &csi.ListSnapshotsResponse{
Entries: append(entries, &csi.ListSnapshotsResponse_Entry{
Snapshot: createCSISnapshotResponse(*snapshot).Snapshot,
}),
NextToken: "",
}, nil
}

maxEntries := int(req.MaxEntries)
tags := map[string]string{}
sourceVolumeID := req.GetSourceVolumeId()
if len(sourceVolumeID) != 0 {
tags["source_volume.id"] = sourceVolumeID
}
snapshotList, err := session.ListSnapshots(maxEntries, req.StartingToken, tags)
if err != nil {
errCode := err.(providerError.Message).Code
if strings.Contains(errCode, "InvalidListSnapshotLimit") {
return nil, commonError.GetCSIError(ctxLogger, commonError.InvalidParameters, requestID, err)
} else if strings.Contains(errCode, "StartSnapshotIDNotFound") {
return nil, commonError.GetCSIError(ctxLogger, commonError.StartSnapshotIDNotFound, requestID, err, req.StartingToken)
}
return nil, commonError.GetCSIError(ctxLogger, commonError.ListSnapshotsFailed, requestID, err)
}

for _, snap := range snapshotList.Snapshots {
snapObj := createCSISnapshotResponse(*snap)
entries = append(entries, &csi.ListSnapshotsResponse_Entry{
Snapshot: snapObj.Snapshot,
})
}

return &csi.ListSnapshotsResponse{
Entries: entries,
NextToken: snapshotList.Next,
}, nil
}

// getSnapshots ...
Expand Down
27 changes: 27 additions & 0 deletions pkg/ibmcsidriver/controller_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
providerError "github.com/IBM/ibmcloud-volume-interface/lib/utils"
csi "github.com/container-storage-interface/spec/lib/go/csi"
"go.uber.org/zap"
"google.golang.org/protobuf/types/known/timestamppb"
)

// Capacity vs IOPS range for Custom Class
Expand Down Expand Up @@ -414,6 +415,16 @@ func checkIfVolumeExists(session provider.Session, vol provider.Volume, ctxLogge

// createCSIVolumeResponse ...
func createCSIVolumeResponse(vol provider.Volume, capBytes int64, zones []string, clusterID string, region string) *csi.CreateVolumeResponse {
var src *csi.VolumeContentSource
if vol.SnapshotID != "" {
src = &csi.VolumeContentSource{
Type: &csi.VolumeContentSource_Snapshot{
Snapshot: &csi.VolumeContentSource_SnapshotSource{
SnapshotId: vol.SnapshotID,
},
},
}
}
labels := map[string]string{}

// Update labels for PV objects
Expand Down Expand Up @@ -446,10 +457,26 @@ func createCSIVolumeResponse(vol provider.Volume, capBytes int64, zones []string
VolumeId: vol.VolumeID,
VolumeContext: labels,
AccessibleTopology: []*csi.Topology{topology},
ContentSource: src,
},
}
return volResp
}

// createCSISnapshotResponse ...
func createCSISnapshotResponse(snapshot provider.Snapshot) *csi.CreateSnapshotResponse {
ts := timestamppb.New(snapshot.SnapshotCreationTime)
return &csi.CreateSnapshotResponse{
Snapshot: &csi.Snapshot{
SnapshotId: snapshot.SnapshotID,
SourceVolumeId: snapshot.VolumeID,
SizeBytes: snapshot.SnapshotSize,
CreationTime: ts,
ReadyToUse: snapshot.ReadyToUse,
},
}
}

func createControllerPublishVolumeResponse(volumeAttachmentResponse provider.VolumeAttachmentResponse, extraPublishInfo map[string]string) *csi.ControllerPublishVolumeResponse {
publishContext := map[string]string{
PublishInfoVolumeID: volumeAttachmentResponse.VolumeID,
Expand Down
Loading

0 comments on commit 05199f7

Please sign in to comment.