Skip to content

Commit 64bc17f

Browse files
AleksZiminasergunovduckhawkdenmaloyreb
authored
[csi] Add volumeCleanup (#73)
Signed-off-by: Aleksandr Zimin <[email protected]> Signed-off-by: Anton Sergunov <[email protected]> Signed-off-by: Vasily Oleynikov <[email protected]> Signed-off-by: Denis.Rebenok <[email protected]> Co-authored-by: Anton Sergunov <[email protected]> Co-authored-by: Vasily Oleynikov <[email protected]> Co-authored-by: Denis Rebenok <[email protected]> Co-authored-by: Denis.Rebenok <[email protected]>
1 parent 4785a9d commit 64bc17f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1874
-625
lines changed

.github/workflows/build_dev.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ jobs:
5252
- name: Set vars
5353
id: set-vars
5454
run: |
55-
# Slect edition for build, default EE
55+
# Slect edition for build, default ee
5656
if echo "${{ steps.get-labels.outputs.result }}" | grep -q "edition/ce"; then
57-
echo "MODULE_EDITION=CE" >> "$GITHUB_OUTPUT"
57+
echo "MODULE_EDITION=ce" >> "$GITHUB_OUTPUT"
5858
else
59-
echo "MODULE_EDITION=EE" >> "$GITHUB_OUTPUT"
59+
echo "MODULE_EDITION=ee" >> "$GITHUB_OUTPUT"
6060
fi
6161
6262
dev_setup_build:

.github/workflows/build_prod.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- name: SET VAR
6161
run: |
6262
echo "MODULES_MODULE_SOURCE=$MODULES_REGISTRY/$MODULE_SOURCE_NAME/ee/modules" >> "$GITHUB_ENV"
63-
echo "MODULE_EDITION=EE" >> "$GITHUB_ENV"
63+
echo "MODULE_EDITION=ee" >> "$GITHUB_ENV"
6464
- run: |
6565
echo $MODULES_REGISTRY
6666
echo $MODULES_MODULE_NAME
@@ -95,7 +95,7 @@ jobs:
9595
- name: SET VAR
9696
run: |
9797
echo "MODULES_MODULE_SOURCE=$MODULES_REGISTRY/$MODULE_SOURCE_NAME/fe/modules" >> "$GITHUB_ENV"
98-
echo "MODULE_EDITION=EE" >> "$GITHUB_ENV"
98+
echo "MODULE_EDITION=ee" >> "$GITHUB_ENV"
9999
- run: |
100100
echo $MODULES_REGISTRY
101101
echo $MODULES_MODULE_NAME
@@ -130,7 +130,7 @@ jobs:
130130
- name: SET VAR
131131
run: |
132132
echo "MODULES_MODULE_SOURCE=$MODULES_REGISTRY/$MODULE_SOURCE_NAME/se/modules" >> "$GITHUB_ENV"
133-
echo "MODULE_EDITION=EE" >> "$GITHUB_ENV"
133+
echo "MODULE_EDITION=se" >> "$GITHUB_ENV"
134134
- run: |
135135
echo $MODULES_REGISTRY
136136
echo $MODULES_MODULE_NAME
@@ -165,7 +165,7 @@ jobs:
165165
- name: SET VAR
166166
run: |
167167
echo "MODULES_MODULE_SOURCE=$MODULES_REGISTRY/$MODULE_SOURCE_NAME/se-plus/modules" >> "$GITHUB_ENV"
168-
echo "MODULE_EDITION=EE" >> "$GITHUB_ENV"
168+
echo "MODULE_EDITION=seplus" >> "$GITHUB_ENV"
169169
- run: |
170170
echo $MODULES_REGISTRY
171171
echo $MODULES_MODULE_NAME

.github/workflows/go_lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Go linter for images
22

33
env:
4-
GO_BUILD_TAGS: "EE CE"
4+
GO_BUILD_TAGS: "ee ce se seplus csepro"
55

66
on:
77
pull_request:

.github/workflows/go_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Go tests for images
22

33
env:
4-
GO_BUILD_TAGS: "EE CE"
4+
GO_BUILD_TAGS: "ee ce se seplus csepro"
55

66
on:
77
pull_request:

.werf/choise-edition.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
---
33
image: choise-edition
44
from: {{ $.BASE_ALT_P11 }}
5-
fromCacheVersion: 2025-01-31.1
5+
fromCacheVersion: 2025-02-10.1
66
git:
77
- add: /
88
to: /
@@ -11,5 +11,6 @@ git:
1111
shell:
1212
setup:
1313
- cd /openapi
14-
- cp -v values_{{ .MODULE_EDITION }}.yaml values.yaml
14+
# - cp -v values_{{ .MODULE_EDITION }}.yaml values.yaml
15+
- if [[ {{ .MODULE_EDITION }} == "ce" ]]; then cp -v values_ce.yaml values.yaml; else cp -v values_ee.yaml values.yaml; fi
1516
- rm -rf values_*.yaml

.werf/consts.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# base images
2-
{{- $_ := set . "BASE_GOLANG_1_23" "registry.deckhouse.io/base_images/golang:1.23.4-bookworm@sha256:a9147a48ac5e925a66764afae7cf4b1cfd37a6e94ad7519eca74c1fd8993ae45" }}
2+
{{- $_ := set . "BASE_GOLANG_1_23" "registry.deckhouse.io/base_images/golang:1.23.6-alpine3.20@sha256:3058c63e0e2532881949c4186414baa24a0f9a8f9349b1853daa49be816f42e9" }}
33
{{- $_ := set . "BASE_SCRATCH" "registry.deckhouse.io/base_images/scratch@sha256:653ae76965c98c8cd1c8c9ff7725316d2983986f896655b30e0f44d2f8b2dd7e" }}
4-
{{- $_ := set . "BASE_ALT_P11" "registry.deckhouse.io/base_images/alt:p11@sha256:e47d84424485d3674240cb2f67d3a1801b37d327e6d1eb8cc8d01be8ed3b34f3" }}
4+
{{- $_ := set . "BASE_ALT_P11" "registry.deckhouse.io/base_images/alt:p11@sha256:b630220d83798057e1c67fe6f712a49e9c3abb377f0bd7183bba0ba541fc4081" }}
55
{{- $_ := set . "BASE_ALPINE_3_16" "registry.deckhouse.io/base_images/alpine:3.16.3" }}
66
{{- $_ := set . "BASE_ALPINE_3_20" "registry.deckhouse.io/base_images/alpine:3.20.3@sha256:41628df7c9b935d248f64542634e7a843f9bc7f2252d7f878e77f7b79a947466" }}
77

8-
# Edition module settings, default EE
9-
{{- $_ := set . "MODULE_EDITION" (env "MODULE_EDITION" "EE") }}
8+
# Edition module settings, default ee
9+
{{- $_ := set . "MODULE_EDITION" (env "MODULE_EDITION" "ee") }}
1010

1111
# component versions
1212
{{- $versions := dict }}
@@ -19,4 +19,5 @@
1919
# custom constants
2020
{{- $_ := set $ "DEV_PACKAGES" "make automake pkg-config gcc libtool git curl" }}
2121
{{- $_ := set $ "DECKHOUSE_UID_GID" "64535" }}
22+
{{- $_ := set $ "ALT_BASE_PACKAGES" "openssl libtirpc tzdata" }}
2223
{{- $_ := set $ "ALT_CLEANUP_CMD" "rm -rf /var/lib/apt/lists/* /var/cache/apt/* && mkdir -p /var/lib/apt/lists/partial /var/cache/apt/archives/partial" }}

api/v1alpha1/nfs_storage_class.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type NFSStorageClassSpec struct {
4545
ReclaimPolicy string `json:"reclaimPolicy"`
4646
VolumeBindingMode string `json:"volumeBindingMode"`
4747
WorkloadNodes *NFSStorageClassWorkloadNodes `json:"workloadNodes,omitempty"`
48+
VolumeCleanup string `json:"volumeCleanup,omitempty"`
4849
}
4950

5051
// +k8s:deepcopy-gen=true

crds/doc-ru-nfsstorageclass.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ spec:
7575
matchExpressions:
7676
description: |
7777
Список сложных условий выбора узлов. Каждое условие задаёт ключ, оператор и, при необходимости, значения для фильтрации узлов на основе их меток или других полей.
78+
volumeCleanup:
79+
description: |
80+
**Функция доступна в Enterprise Edition.**
81+
82+
Метод очистки тома после удаления PV.
83+
По умолчанию драйвер NFS CSI удаляет каталог, созданный для PV на сервере NFS, не выполняя никакой очистки данных
84+
Если параметр `volumeCleanup` задан, драйвер удалит каждый файл в каталоге PV.
85+
86+
Допустимые значения параметра:
87+
- **Discard** — используется функция `Discard`(trim) файловой системы для освобождения блоков данных (Эта опция доступна только в том случае, если она поддерживается, например, в NFSv4.2.).
88+
- **RandomFillSinglePass** — перед удалением содержимое каждого файла перезаписывается случайными данными один раз. Реализуется путем вызова утилиты `shred`.
89+
- **RandomFillThreePass** — перед удалением содержимое каждого файла перезаписывается случайными данными три раза. Реализуется путем вызова утилиты `shred`.
7890
status:
7991
properties:
8092
phase:

crds/nfsstorageclass.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ spec:
3939
- connection
4040
- reclaimPolicy
4141
- volumeBindingMode
42+
x-kubernetes-validations:
43+
- rule: "self.reclaimPolicy != 'Retain' || !has(self.volumeCleanup)"
44+
message: "If reclaimPolicy is 'Retain', volumeCleanup must be omitted."
45+
- rule: "self.connection.nfsVersion == '4.2' || !has(self.volumeCleanup)|| self.volumeCleanup != 'Discard'"
46+
message: "Discard mode is only available when connection.nfsVersion is '4.2'."
4247
properties:
4348
connection:
4449
type: object
@@ -191,6 +196,24 @@ spec:
191196
type: array
192197
items:
193198
type: string
199+
volumeCleanup:
200+
type: string
201+
x-doc-d8editions: [ee,fe]
202+
description: |
203+
**This feature is available in Enterprise Edition.**
204+
205+
Specifies the cleanup method to be applied to the PV’s subdirectory content before deletion.
206+
By default, the NFS CSI driver simply deletes the directory created for the Persistent Volume (PV) on the NFS server without performing any data cleanup.
207+
When volumeCleanup is enabled, the driver will erase each file in the PV directory.
208+
209+
Valid options are:
210+
- **Discard**: Uses the filesystem’s discard (trim) functionality to free data blocks. (This option is available only when supported, for example with NFSv4.2.)
211+
- **RandomFillSinglePass**: Overwrites the content of each file once with random data before deletion. This is implemented by invoking the utility `shred`.
212+
- **RandomFillThreePass**: Overwrites the content of each file three times with random data before deletion. This is implemented by invoking the utility `shred`.
213+
enum:
214+
- Discard
215+
- RandomFillSinglePass
216+
- RandomFillThreePass
194217
status:
195218
type: object
196219
description: |

docs/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,49 @@ A directory `<directory from share>/<PV name>` will be created for each PV.
8181
### Checking module health
8282

8383
You can verify the functionality of the module using the instructions [in FAQ](./faq.html#how-to-check-module-health).
84+
85+
### Selects the method to clean the volume before deleting the PV
86+
87+
Files with user data may remain on the volume to be deleted. These files will be deleted and will not be accessible to other users via NFS.
88+
89+
However, the deleted files' data may be available to other clients if the server grants block-level access to its storage.
90+
91+
The `volumeCleanup` parameter will help you choose how to clean the volume before deleting it.
92+
93+
> **Caution.** This option does not affect files already deleted by the client application.
94+
95+
> **Caution.** This option affects only commands sent via the NFS protocol. The server-side execution of these commands is defined by:
96+
>
97+
> - NFS server service;
98+
> - the file system;
99+
> - the level of block devices and their virtualization (e.g. LVM);
100+
> - the physical devices themselves.
101+
>
102+
> Make sure the server is trusted. Do not send sensitive data to servers that you are not sure of.
103+
104+
#### `SinglePass` method
105+
106+
Used if `volumeCleanup` is set to `RandomFillSinglePass`.
107+
108+
The contents of the files are overwritten with a random sequence before deletion. The random sequence is transmitted over the network.
109+
110+
#### `ThreePass` method
111+
112+
Used if `volumeCleanup` is set to `RandomFillThreePass`.
113+
114+
The contents of the files are overwritten three times with a random sequence before deletion. The three random sequences are transmitted over the network.
115+
116+
#### `Discard` method
117+
118+
Used if `volumeCleanup` is set to `Discard`.
119+
120+
Many file systems implement support for solid-state drives, allowing the space occupied by a file to be freed at the block level without writing new data to extend the life of the solid-state drive. However, not all solid-state drives guarantee that the freed block data is inaccessible.
121+
122+
If `volumeCleanup` is set to `Discard`, file contents are marked as free via the `falloc` system call with the `FALLOC_FL_PUNCH_HOLE` flag. The file system will free the blocks fully used by the file, via the `blkdiscard` call, and the remaining space will be overwritten with zeros.
123+
124+
Advantages of this method:
125+
126+
- the amount of traffic does not depend on the size of the files, only on the number of files;
127+
- the method can make old data unavailable in some server configurations;
128+
- works for both hard disks and SSDs;
129+
- can maximize SSD lifetime.

0 commit comments

Comments
 (0)