From a9317335a9bed2c1a8c83a5522acb0a63695b116 Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Tue, 28 Jan 2025 14:36:36 +0000 Subject: [PATCH] fix tests --- neonvm-daemon/cmd/main.go | 3 ++- neonvm-runner/cmd/main.go | 14 ++++++++++++++ tests/e2e/vm-secret-sync/00-assert.yaml | 5 +++-- tests/e2e/vm-secret-sync/01-assert.yaml | 5 +++-- tests/e2e/vm-secret-sync/01-update-secret.yaml | 7 ------- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/neonvm-daemon/cmd/main.go b/neonvm-daemon/cmd/main.go index d7dbcebf5..54a0869f8 100644 --- a/neonvm-daemon/cmd/main.go +++ b/neonvm-daemon/cmd/main.go @@ -102,7 +102,8 @@ func (s *cpuServer) getFile(path string) (string, error) { if !filepath.IsLocal(path) { return "", fmt.Errorf("\"%s\" is not a local path", path) } - path = filepath.Clean(filepath.Join("var", "sync", path)) + //nolint:gocritic // filepathJoin lint wrongly complains about path separators + path = filepath.Clean(filepath.Join("/var/sync", path)) return path, nil } diff --git a/neonvm-runner/cmd/main.go b/neonvm-runner/cmd/main.go index 67c856d96..d28740389 100644 --- a/neonvm-runner/cmd/main.go +++ b/neonvm-runner/cmd/main.go @@ -732,6 +732,20 @@ func monitorFiles(ctx context.Context, logger *zap.Logger, wg *sync.WaitGroup, d // not tracking this file continue } + if event.Op == fsnotify.Chmod { + // not interesting. + continue + } + + // kubernetes secrets are mounted as symbolic links. + // When the link changes, there's no event. We only see the deletion + // of the file the link used to point to. + // This doesn't mean the file was actually deleted though. + if event.Op == fsnotify.Remove { + if err := notify.Add(event.Name); err != nil { + logger.Error("failed to add file to inotify instance", zap.Error(err)) + } + } if err := sendFileToNeonvmDaemon(ctx, event.Name, guestpath); err != nil { logger.Error("failed to upload file to vm guest", zap.Error(err)) diff --git a/tests/e2e/vm-secret-sync/00-assert.yaml b/tests/e2e/vm-secret-sync/00-assert.yaml index 55afba5f8..23d71c8ac 100644 --- a/tests/e2e/vm-secret-sync/00-assert.yaml +++ b/tests/e2e/vm-secret-sync/00-assert.yaml @@ -1,12 +1,13 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert -timeout: 90 +timeout: 70 commands: - script: | set -eux pod="$(kubectl get neonvm -n "$NAMESPACE" example -o jsonpath='{.status.podName}')" + kubectl exec -n "$NAMESPACE" $pod -- grep -q "hello world" /vm/mounts/var/sync/example/foo kubectl exec -n "$NAMESPACE" $pod -- scp guest-vm:/var/sync/example/foo testfile - grep -q "hello world" testfile + kubectl exec -n "$NAMESPACE" $pod -- grep -q "hello world" testfile --- apiVersion: vm.neon.tech/v1 kind: VirtualMachine diff --git a/tests/e2e/vm-secret-sync/01-assert.yaml b/tests/e2e/vm-secret-sync/01-assert.yaml index 2fc4d083c..4bf904533 100644 --- a/tests/e2e/vm-secret-sync/01-assert.yaml +++ b/tests/e2e/vm-secret-sync/01-assert.yaml @@ -1,9 +1,10 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert -timeout: 90 +timeout: 70 commands: - script: | set -eux pod="$(kubectl get neonvm -n "$NAMESPACE" example -o jsonpath='{.status.podName}')" + kubectl exec -n "$NAMESPACE" $pod -- grep -q "goodbye world" /vm/mounts/var/sync/example/foo kubectl exec -n "$NAMESPACE" $pod -- scp guest-vm:/var/sync/example/foo testfile - grep -q "goodbye world" testfile + kubectl exec -n "$NAMESPACE" $pod -- grep -q "goodbye world" testfile diff --git a/tests/e2e/vm-secret-sync/01-update-secret.yaml b/tests/e2e/vm-secret-sync/01-update-secret.yaml index 8aaad414b..5b60678d7 100644 --- a/tests/e2e/vm-secret-sync/01-update-secret.yaml +++ b/tests/e2e/vm-secret-sync/01-update-secret.yaml @@ -1,13 +1,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep unitTest: false -commands: - - script: | - set -eux - pod="$(kubectl get neonvm -n "$NAMESPACE" example -o jsonpath='{.status.podName}')" - new_size=$(( 1 * 1024 * 1024 )) # 1 Gi - mountpoint="/var/db/postgres/compute" - kubectl exec -n "$NAMESPACE" "$pod" -- ssh guest-vm /neonvm/bin/set-disk-quota "$new_size" "$mountpoint" --- apiVersion: v1 kind: Secret