Skip to content

Commit

Permalink
local-storage: Fix permission
Browse files Browse the repository at this point in the history
/var/lib/rancher/k3s/storage/ should be 700
/var/lib/rancher/k3s/storage/* should be 777

Fixes #2348

Signed-off-by: Boleyn Su <[email protected]>
  • Loading branch information
BoleynSu committed Apr 5, 2023
1 parent 12091fc commit 55b6af7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifests/local-storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ data:
esac
done
mkdir -m 0777 -p ${absolutePath}
chmod 701 ${absolutePath}/..
chmod 700 ${absolutePath}/..
teardown: |-
#!/bin/sh
while getopts "m:s:p:" opt
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/zz_generated_bindata.go

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

5 changes: 4 additions & 1 deletion tests/integration/localstorage/localstorage_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var _ = Describe("local storage", func() {
var k3sStorage = "/var/lib/rancher/k3s/storage"
fileStat, err := os.Stat(k3sStorage)
Expect(err).ToNot(HaveOccurred())
Expect(fmt.Sprintf("%04o", fileStat.Mode().Perm())).To(Equal("0701"))
Expect(fmt.Sprintf("%04o", fileStat.Mode().Perm())).To(Equal("0700"))

pvResult, err := testutil.K3sCmd("kubectl get --namespace=default pv")
Expect(err).ToNot(HaveOccurred())
Expand All @@ -72,6 +72,9 @@ var _ = Describe("local storage", func() {
fileStat, err = os.Stat(k3sStorage + "/" + volumeName)
Expect(err).ToNot(HaveOccurred())
Expect(fmt.Sprintf("%04o", fileStat.Mode().Perm())).To(Equal("0777"))

touchResult, err := testutil.K3sCmd("kubectl --namespace=default exec -it volume-test -- touch /data/file")
Expect(err).ToNot(HaveOccurred())
})
It("deletes properly", func() {
Expect(testutil.K3sCmd("kubectl delete --namespace=default --force pod volume-test")).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ metadata:
spec:
containers:
- name: volume-test
image: nginx:stable-alpine
image: busybox:stable
imagePullPolicy: IfNotPresent
commands:
- sleep
- infinity
volumeMounts:
- name: volv
mountPath: /data
Expand Down

0 comments on commit 55b6af7

Please sign in to comment.