Skip to content

Commit 9299c99

Browse files
naimadswdnDamian Seredyn
andauthored
fix: Fix ACL SAVE when using ACL from PVC (#1645)
Redis always rewrites ACLs (and redis.conf, RDB, AOF) via the same pattern: write a temp file alongside the target, fsync, then rename(2) over the original. Because user.acl is mounted via subPath, Kubernetes turns that single file into its own bind mount. Bind mounts behave like a mini mount point, and Linux forbids rename(2) on a mount target—exactly what Redis tries to do during ACL SAVE (it writes tempfile + rename). The kernel therefore returns EBUSY, which surfaces as “Resource busy”. The PR is fixing this behavior, by mounting the PVC as directory under the /data/redis. Signed-off-by: Damian Seredyn <s-DSeredyn@aras.com> Co-authored-by: Damian Seredyn <s-DSeredyn@aras.com>
1 parent 76d40b0 commit 9299c99

File tree

16 files changed

+147
-36
lines changed

16 files changed

+147
-36
lines changed

api/common/v1beta2/common_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ type ACLConfig struct {
288288
Secret *corev1.SecretVolumeSource `json:"secret,omitempty"`
289289
// PersistentVolumeClaim-based ACL configuration
290290
// Specify the PVC name to mount ACL file from persistent storage
291-
// The operator will automatically mount /etc/redis/user.acl from the PVC
291+
// The operator mounts the PVC at /data/redis so Redis can read and update /data/redis/user.acl
292+
// This feature requires the GenerateConfigInInitContainer feature gate to be enabled.
292293
PersistentVolumeClaim *string `json:"persistentVolumeClaim,omitempty"`
293294
}
294295

charts/redis-operator/crds/crds.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ spec:
117117
description: |-
118118
PersistentVolumeClaim-based ACL configuration
119119
Specify the PVC name to mount ACL file from persistent storage
120-
The operator will automatically mount /etc/redis/user.acl from the PVC
120+
The operator mounts the PVC at /data/redis so Redis can read and update /data/redis/user.acl
121+
This feature requires the GenerateConfigInInitContainer feature gate to be enabled.
121122
type: string
122123
secret:
123124
description: |-
@@ -5544,7 +5545,8 @@ spec:
55445545
description: |-
55455546
PersistentVolumeClaim-based ACL configuration
55465547
Specify the PVC name to mount ACL file from persistent storage
5547-
The operator will automatically mount /etc/redis/user.acl from the PVC
5548+
The operator mounts the PVC at /data/redis so Redis can read and update /data/redis/user.acl
5549+
This feature requires the GenerateConfigInInitContainer feature gate to be enabled.
55485550
type: string
55495551
secret:
55505552
description: |-
@@ -13393,7 +13395,8 @@ spec:
1339313395
description: |-
1339413396
PersistentVolumeClaim-based ACL configuration
1339513397
Specify the PVC name to mount ACL file from persistent storage
13396-
The operator will automatically mount /etc/redis/user.acl from the PVC
13398+
The operator mounts the PVC at /data/redis so Redis can read and update /data/redis/user.acl
13399+
This feature requires the GenerateConfigInInitContainer feature gate to be enabled.
1339713400
type: string
1339813401
secret:
1339913402
description: |-

config/crd/bases/redis.redis.opstreelabs.in_redis.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ spec:
118118
description: |-
119119
PersistentVolumeClaim-based ACL configuration
120120
Specify the PVC name to mount ACL file from persistent storage
121-
The operator will automatically mount /etc/redis/user.acl from the PVC
121+
The operator mounts the PVC at /data/redis so Redis can read and update /data/redis/user.acl
122+
This feature requires the GenerateConfigInInitContainer feature gate to be enabled.
122123
type: string
123124
secret:
124125
description: |-

config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ spec:
146146
description: |-
147147
PersistentVolumeClaim-based ACL configuration
148148
Specify the PVC name to mount ACL file from persistent storage
149-
The operator will automatically mount /etc/redis/user.acl from the PVC
149+
The operator mounts the PVC at /data/redis so Redis can read and update /data/redis/user.acl
150+
This feature requires the GenerateConfigInInitContainer feature gate to be enabled.
150151
type: string
151152
secret:
152153
description: |-

config/crd/bases/redis.redis.opstreelabs.in_redisreplications.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ spec:
124124
description: |-
125125
PersistentVolumeClaim-based ACL configuration
126126
Specify the PVC name to mount ACL file from persistent storage
127-
The operator will automatically mount /etc/redis/user.acl from the PVC
127+
The operator mounts the PVC at /data/redis so Redis can read and update /data/redis/user.acl
128+
This feature requires the GenerateConfigInInitContainer feature gate to be enabled.
128129
type: string
129130
secret:
130131
description: |-

docs/content/en/docs/CRD Reference/API Reference/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ _Appears in:_
4343
| Field | Description | Default | Validation |
4444
| --- | --- | --- | --- |
4545
| `secret` _[SecretVolumeSource](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#secretvolumesource-v1-core)_ | Secret-based ACL configuration.<br />Adapts a Secret into a volume containing ACL rules.<br />The contents of the target Secret's Data field will be presented in a volume<br />as files using the keys in the Data field as the file names.<br />Secret volumes support ownership management and SELinux relabeling. | | |
46-
| `persistentVolumeClaim` _string_ | PersistentVolumeClaim-based ACL configuration<br />Specify the PVC name to mount ACL file from persistent storage<br />The operator will automatically mount /etc/redis/user.acl from the PVC | | |
46+
| `persistentVolumeClaim` _string_ | PersistentVolumeClaim-based ACL configuration<br />Specify the PVC name to mount ACL file from persistent storage<br />The operator mounts the PVC at /data/redis so Redis can read and update /data/redis/user.acl<br />This feature requires the GenerateConfigInInitContainer feature gate to be enabled. | | |
4747

4848

4949
#### AdditionalVolume

example/v1beta2/acl-pvc/cluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
image: quay.io/opstree/redis:latest
1111
imagePullPolicy: IfNotPresent
1212
# ACL configuration from PVC
13-
# The operator will mount /etc/redis/user.acl from the PVC
13+
# The operator mounts the PVC at /data/redis, so Redis reads /data/redis/user.acl
1414
# Make sure the PVC contains a file named "user.acl" with Redis ACL rules
1515
acl:
1616
persistentVolumeClaim: "redis-acl-pvc"

example/v1beta2/acl-pvc/replication.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
image: quay.io/opstree/redis:latest
1111
imagePullPolicy: IfNotPresent
1212
# ACL configuration from PVC
13-
# The operator will mount /etc/redis/user.acl from the PVC
13+
# The operator mounts the PVC at /data/redis, so Redis reads /data/redis/user.acl
1414
# Make sure the PVC contains a file named "user.acl" with Redis ACL rules
1515
acl:
1616
persistentVolumeClaim: "redis-acl-pvc"

example/v1beta2/acl-pvc/standalone.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ spec:
99
image: quay.io/opstree/redis:latest
1010
imagePullPolicy: IfNotPresent
1111
# ACL configuration from PVC
12-
# The operator will mount /etc/redis/user.acl from the PVC
12+
# The operator mounts the PVC at /data/redis, so Redis reads /data/redis/user.acl
1313
# Make sure the PVC contains a file named "user.acl" with Redis ACL rules
1414
acl:
1515
persistentVolumeClaim: "redis-acl-pvc"

internal/agent/bootstrap/redis/config.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func GenerateConfig() error {
4141
nodeport = util.CoalesceEnv1("NODEPORT", "false")
4242
tlsMode = util.CoalesceEnv1("TLS_MODE", "false")
4343
clusterMode = util.CoalesceEnv1("SETUP_MODE", "standalone")
44+
aclMode = util.CoalesceEnv1("ACL_MODE", "")
45+
aclFilePath = util.CoalesceEnv1("ACL_FILE_PATH", "/etc/redis/user.acl")
4446
)
4547

4648
if val, ok := util.CoalesceEnv("REDIS_PASSWORD", ""); ok && val != "" {
@@ -112,8 +114,9 @@ func GenerateConfig() error {
112114
fmt.Println("Running without TLS mode")
113115
}
114116

115-
if aclMode := util.CoalesceEnv1("ACL_MODE", ""); aclMode == "true" {
116-
cfg.Append("aclfile", "/etc/redis/user.acl")
117+
if aclMode == "true" {
118+
fmt.Println("ACL_MODE is true, modifying ACL file path to", aclFilePath)
119+
cfg.Append("aclfile", aclFilePath)
117120
} else {
118121
fmt.Println("ACL_MODE is not true, skipping ACL file modification")
119122
}

0 commit comments

Comments
 (0)