Skip to content

Commit

Permalink
feat: allow ovverid backup attribute
Browse files Browse the repository at this point in the history
Some customers prefer having VM backup capabilities.
These changes enable setting backup=1 for the block device.

Signed-off-by: Serge Logvinov <[email protected]>
  • Loading branch information
sergelogvinov committed Jan 23, 2025
1 parent 820cb7e commit 2fada12
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/csi/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ func (d *ControllerService) ControllerPublishVolume(ctx context.Context, request
}

// Temporary workaround for unsafe mount, better to use a VolumeAttributesClass resource
// It should be removed in the future, use backup=true/false in the volume attributes instead
unsafeEnv := os.Getenv("UNSAFEMOUNT")
if unsafeEnv == "true" { // nolint: goconst
params.Backup = nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/csi/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const (
// cfg tags are used to map the struct to the Kubernetes API
type StorageParameters struct {
AIO string `json:"aio,omitempty"`
Backup *bool `json:"backup,omitempty"`
Backup *bool `json:"backup,omitempty" cfg:"backup"`
Cache string `json:"cache,omitempty" cfg:"cache"`
Discard string `json:"discard,omitempty"`
IOThread bool `json:"iothread,omitempty"`
Expand Down
18 changes: 18 additions & 0 deletions pkg/csi/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ func Test_ExtractAndDefaultParameters(t *testing.T) {
IopsWrite: ptr.Ptr(100),
},
},
{
msg: "ovverid disk backup",
params: map[string]string{
csi.StorageIDKey: "local-lvm",
csi.StorageSSDKey: "true",
csi.StorageDiskIOPSKey: "100",
"backup": "true",
},
storage: csi.StorageParameters{
Backup: ptr.Ptr(true),
IOThread: true,
SSD: ptr.Ptr(true),
Discard: "on",
Iops: ptr.Ptr(100),
IopsRead: ptr.Ptr(100),
IopsWrite: ptr.Ptr(100),
},
},
}

for _, testCase := range tests {
Expand Down

0 comments on commit 2fada12

Please sign in to comment.