Skip to content
Merged
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
6 changes: 3 additions & 3 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Project's application can be found under `cmd` directory:
### Plugin
Required CSI interfaces are implemented in `controller`, `node` and `ìdentity` packages.
Plugin's gRPC server uses these packages to expose endpoints described in following interfaces:
- [csi.IdentityServer](https://pkg.go.dev/github.com/container-storage-interface/spec@v1.6.0/lib/go/csi#IdentityServer)
- [csi.ControllerServer](https://pkg.go.dev/github.com/container-storage-interface/spec@v1.6.0/lib/go/csi#ControllerServer)
- [csi.NodeServer](https://pkg.go.dev/github.com/container-storage-interface/spec@v1.6.0/lib/go/csi#NodeServer)
- [csi.IdentityServer](https://pkg.go.dev/github.com/container-storage-interface/spec@v1.12.0/lib/go/csi#IdentityServer)
- [csi.ControllerServer](https://pkg.go.dev/github.com/container-storage-interface/spec@v1.12.0/lib/go/csi#ControllerServer)
- [csi.NodeServer](https://pkg.go.dev/github.com/container-storage-interface/spec@v1.12.0/lib/go/csi#NodeServer)


## Testing
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/upcloud-tools/upcloud-csi
go 1.26

require (
github.com/container-storage-interface/spec v1.11.0
github.com/container-storage-interface/spec v1.12.0
github.com/golang/protobuf v1.5.4
github.com/google/uuid v1.6.0
github.com/onsi/ginkgo/v2 v2.32.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/container-storage-interface/spec v1.6.0/go.mod h1:8K96oQNkJ7pFcC2R9Z1ynGGBB1I93kcS6PGg3SsOk8s=
github.com/container-storage-interface/spec v1.11.0 h1:H/YKTOeUZwHtyPOr9raR+HgFmGluGCklulxDYxSdVNM=
github.com/container-storage-interface/spec v1.11.0/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI=
github.com/container-storage-interface/spec v1.12.0 h1:zrFOEqpR5AghNaaDG4qyedwPBqU2fU0dWjLQMP/azK0=
github.com/container-storage-interface/spec v1.12.0/go.mod h1:txsm+MA2B2WDa5kW69jNbqPnvTtfvZma7T/zsAZ9qX8=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
28 changes: 27 additions & 1 deletion internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var supportedCapabilities = []csi.ControllerServiceCapability_RPC_Type{ //nolint
csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS,
csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
csi.ControllerServiceCapability_RPC_CLONE_VOLUME,
csi.ControllerServiceCapability_RPC_GET_SNAPSHOT,
}

type Controller struct {
Expand Down Expand Up @@ -572,9 +573,34 @@ func (c *Controller) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRe
}, nil
}

// GetSnapshot returns a specific snapshot by ID.
// Returns ErrNotFound if no matching snapshot exists.
func (c *Controller) GetSnapshot(ctx context.Context, req *csi.GetSnapshotRequest) (*csi.GetSnapshotResponse, error) {
if req.GetSnapshotId() == "" {
return nil, status.Error(codes.InvalidArgument, "snapshot ID must be provided")
}

snap, err := c.svc.GetStorageByUUID(ctx, req.GetSnapshotId())
if err != nil {
if errors.Is(err, service.ErrStorageNotFound) {
return nil, status.Error(codes.NotFound, err.Error())
}
return nil, status.Error(codes.Internal, err.Error())
}

return &csi.GetSnapshotResponse{
Snapshot: &csi.Snapshot{
SizeBytes: int64(snap.Size) * giB,
SnapshotId: snap.UUID,
SourceVolumeId: snap.Origin,
CreationTime: timestamppb.New(snap.Created),
ReadyToUse: snap.State == upcloud.StorageStateOnline,
},
}, nil
}

// ControllerExpandVolume is called from the resizer to increase the volume size.
//

func (c *Controller) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
volumeID := req.GetVolumeId()

Expand Down