Skip to content

Commit

Permalink
Add WriteVolumeCache API to v1beta2 Volume API group
Browse files Browse the repository at this point in the history
add writevolumecache api to csi-proxy v1beta2 volume API group
  • Loading branch information
jingxu97 committed Oct 9, 2020
1 parent 897abed commit 34e4770
Show file tree
Hide file tree
Showing 16 changed files with 3,661 additions and 0 deletions.
1,313 changes: 1,313 additions & 0 deletions client/api/volume/v1beta2/api.pb.go

Large diffs are not rendered by default.

132 changes: 132 additions & 0 deletions client/api/volume/v1beta2/api.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
syntax = "proto3";

package v1beta2;

option go_package = "github.com/kubernetes-csi/csi-proxy/client/api/volume/v1beta2";

service Volume {
// ListVolumesOnDisk returns the volume IDs (in \\.\Volume{GUID} format) for
// all volumes on a Disk device
rpc ListVolumesOnDisk(ListVolumesOnDiskRequest) returns (ListVolumesOnDiskResponse) {}
// MountVolume mounts the volume at the requested global staging path
rpc MountVolume(MountVolumeRequest) returns (MountVolumeResponse) {}
// DismountVolume gracefully dismounts a volume
rpc DismountVolume(DismountVolumeRequest) returns (DismountVolumeResponse) {}
// IsVolumeFormatted checks if a volume is formatted with NTFS
rpc IsVolumeFormatted(IsVolumeFormattedRequest) returns (IsVolumeFormattedResponse) {}
// FormatVolume formats a volume with the provided file system
rpc FormatVolume(FormatVolumeRequest) returns (FormatVolumeResponse) {}
// ResizeVolume performs resizing of the partition and file system for a block based volume
rpc ResizeVolume(ResizeVolumeRequest) returns (ResizeVolumeResponse) {}
// VolumeStats gathers DiskSize, VolumeSize and VolumeUsedSize for a volume
rpc VolumeStats(VolumeStatsRequest) returns (VolumeStatsResponse) {}
// GetVolumeDiskNumber gets the disk number of the disk where the volume is located
rpc GetVolumeDiskNumber(VolumeDiskNumberRequest) returns (VolumeDiskNumberResponse) {}
// GetVolumeIDFromMount gets the volume id for a given mount
rpc GetVolumeIDFromMount(VolumeIDFromMountRequest) returns (VolumeIDFromMountResponse) {}
// WriteVolumeCache write volume cache to disk
rpc WriteVolumeCache(WriteVolumeCacheRequest) returns (WriteVolumeCacheResponse) {}
}

message ListVolumesOnDiskRequest {
// Disk device ID of the disk to query for volumes
string disk_id = 1;
}

message ListVolumesOnDiskResponse {
// Volume device IDs of volumes on the specified disk
repeated string volume_ids = 1;
}

message MountVolumeRequest {
// Volume device ID of the volume to mount
string volume_id = 1;
// Path in the host's file system where the volume needs to be mounted
string path = 2;
}

message MountVolumeResponse {
// Intentionally empty
}

message DismountVolumeRequest {
// Volume device ID of the volume to dismount
string volume_id = 1;
// Path where the volume has been mounted.
string path = 2;
}

message DismountVolumeResponse {
// Intentionally empty
}

message IsVolumeFormattedRequest {
// Volume device ID of the volume to check
string volume_id = 1;
}

message IsVolumeFormattedResponse {
// Is the volume formatted with NTFS
bool formatted = 1;
}

message FormatVolumeRequest {
// Volume device ID of the volume to format
string volume_id = 1;
}

message FormatVolumeResponse {
// Intentionally empty
}

message ResizeVolumeRequest {
// Volume device ID of the volume to dismount
string volume_id = 1;
// New size of the volume
int64 size = 2;
}

message ResizeVolumeResponse {
// Intentionally empty
}

message VolumeStatsRequest{
// Volume device Id of the volume to get the stats for
string volume_id = 1;
}

message VolumeStatsResponse{
// Capacity of the volume
int64 volumeSize = 1;
// Used bytes
int64 volumeUsedSize = 2;
}

message VolumeDiskNumberRequest{
// Volume device Id of the volume to get the disk number for
string volume_id = 1;
}

message VolumeDiskNumberResponse{
// Corresponding disk number
int64 diskNumber = 1;
}

message VolumeIDFromMountRequest {
// Mount
string mount = 1;
}

message VolumeIDFromMountResponse {
// Mount
string volume_id = 1;
}

message WriteVolumeCacheRequest {
// Volume device ID of the volume to flush the cache
string volume_id = 1;
}

message WriteVolumeCacheResponse {
// Intentionally empty
}
92 changes: 92 additions & 0 deletions client/groups/volume/v1beta2/client_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integrationtests/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ func simpleE2e(t *testing.T) {
if err != nil {
t.Fatalf("Volume id %s mount to path %s failed. Error: %v", volumeID, mountPath, err)
}

// Dismount the volume
dismountVolumeRequest := &v1alpha1.DismountVolumeRequest{
VolumeId: volumeID,
Expand Down
10 changes: 10 additions & 0 deletions internal/os/volume/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ func (VolAPIImplementor) FormatVolume(volumeID string) (err error) {
return nil
}

// WriteVolumeCache - Writes the file system cache to disk with the given volume id
func (VolAPIImplementor) WriteVolumeCache(volumeID string) (err error) {
cmd := fmt.Sprintf("Get-Volume -UniqueId \"%s\" | Write-Volumecache", volumeID)
out, err := runExec(cmd)
if err != nil {
return fmt.Errorf("error writing volume cache. cmd: %s, output: %s, error: %v", cmd, string(out), err)
}
return nil
}

// IsVolumeFormatted - Check if the volume is formatted with the pre specified filesystem(typically ntfs).
func (VolAPIImplementor) IsVolumeFormatted(volumeID string) (bool, error) {
cmd := fmt.Sprintf("(Get-Volume -UniqueId \"%s\" -ErrorAction Stop).FileSystemType", volumeID)
Expand Down
7 changes: 7 additions & 0 deletions internal/server/volume/api_group_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions internal/server/volume/internal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ type FormatVolumeRequest struct {
type FormatVolumeResponse struct {
}

type WriteVolumeCacheRequest struct {
VolumeId string
}

type WriteVolumeCacheResponse struct {
}

type DismountVolumeRequest struct {
VolumeId string
Path string
Expand Down
1 change: 1 addition & 0 deletions internal/server/volume/internal/types_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/server/volume/internal/v1beta2/conversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package v1beta2

// Add manual conversion functions here to override automatic conversion functions
Loading

0 comments on commit 34e4770

Please sign in to comment.