Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local-storage: Fix permission #7217

Merged
merged 3 commits into from
May 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions tests/integration/localstorage/localstorage_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ = BeforeSuite(func() {
}
})

var _ = Describe("local storage", func() {
var _ = Describe("local storage", Ordered, func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, that'd help.

BeforeEach(func() {
if testutil.IsExistingServer() && !testutil.ServerArgsPresent(localStorageServerArgs) {
Skip("Test needs k3s server with: " + strings.Join(localStorageServerArgs, " "))
Expand All @@ -39,9 +39,8 @@ var _ = Describe("local storage", func() {
}, "120s", "5s").Should(Succeed())
})
It("creates a new pvc", func() {
result, err := testutil.K3sCmd("kubectl create -f ./testdata/localstorage_pvc.yaml")
Expect(result).To(ContainSubstring("persistentvolumeclaim/local-path-pvc created"))
Expect(err).NotTo(HaveOccurred())
Expect(testutil.K3sCmd("kubectl create -f ./testdata/localstorage_pvc.yaml")).
To(ContainSubstring("persistentvolumeclaim/local-path-pvc created"))
})
It("creates a new pod", func() {
Expect(testutil.K3sCmd("kubectl create -f ./testdata/localstorage_pod.yaml")).
Expand Down Expand Up @@ -73,14 +72,19 @@ var _ = Describe("local storage", func() {
Expect(err).ToNot(HaveOccurred())
Expect(fmt.Sprintf("%04o", fileStat.Mode().Perm())).To(Equal("0777"))

Eventually(func() (string, error) {
fileStat, err = os.Stat(k3sStorage + "/" + volumeName + "/file1")
return "", err
Eventually(func() error {
_, err = os.Stat(k3sStorage + "/" + volumeName + "/file1")
return err
}, "10s", "1s").Should(Succeed())
Expect(testutil.K3sCmd("kubectl --namespace=default exec volume-test -- stat -c %a /data/file1")).
To(Equal("644\n"))

touchResult, err := testutil.K3sCmd("kubectl --namespace=default exec -it volume-test -- touch /data/file2")
Expect(err).ToNot(HaveOccurred())
Expect(touchResult).To(Equal(""))
})
It("allows non-root pods to write to the volume", func() {
Expect(testutil.K3sCmd("kubectl --namespace=default exec volume-test -- touch /data/file2")).
To(BeEmpty())
Expect(testutil.K3sCmd("kubectl --namespace=default exec volume-test -- stat -c %a /data/file2")).
To(Equal("644\n"))
})
It("deletes properly", func() {
Expect(testutil.K3sCmd("kubectl delete --namespace=default --force pod volume-test")).
Expand Down