Skip to content

Commit 2fada12

Browse files
committed
feat: allow ovverid backup attribute
Some customers prefer having VM backup capabilities. These changes enable setting backup=1 for the block device. Signed-off-by: Serge Logvinov <[email protected]>
1 parent 820cb7e commit 2fada12

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

pkg/csi/controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ func (d *ControllerService) ControllerPublishVolume(ctx context.Context, request
370370
}
371371

372372
// Temporary workaround for unsafe mount, better to use a VolumeAttributesClass resource
373+
// It should be removed in the future, use backup=true/false in the volume attributes instead
373374
unsafeEnv := os.Getenv("UNSAFEMOUNT")
374375
if unsafeEnv == "true" { // nolint: goconst
375376
params.Backup = nil

pkg/csi/parameters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const (
5050
// cfg tags are used to map the struct to the Kubernetes API
5151
type StorageParameters struct {
5252
AIO string `json:"aio,omitempty"`
53-
Backup *bool `json:"backup,omitempty"`
53+
Backup *bool `json:"backup,omitempty" cfg:"backup"`
5454
Cache string `json:"cache,omitempty" cfg:"cache"`
5555
Discard string `json:"discard,omitempty"`
5656
IOThread bool `json:"iothread,omitempty"`

pkg/csi/parameters_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ func Test_ExtractAndDefaultParameters(t *testing.T) {
7676
IopsWrite: ptr.Ptr(100),
7777
},
7878
},
79+
{
80+
msg: "ovverid disk backup",
81+
params: map[string]string{
82+
csi.StorageIDKey: "local-lvm",
83+
csi.StorageSSDKey: "true",
84+
csi.StorageDiskIOPSKey: "100",
85+
"backup": "true",
86+
},
87+
storage: csi.StorageParameters{
88+
Backup: ptr.Ptr(true),
89+
IOThread: true,
90+
SSD: ptr.Ptr(true),
91+
Discard: "on",
92+
Iops: ptr.Ptr(100),
93+
IopsRead: ptr.Ptr(100),
94+
IopsWrite: ptr.Ptr(100),
95+
},
96+
},
7997
}
8098

8199
for _, testCase := range tests {

0 commit comments

Comments
 (0)