From e54e85829a3cf427dba36ed8232c1e42840bcfe5 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 | 2 +- neonvm-runner/cmd/main.go | 14 ++++++++++++++ tests/e2e/vm-secret-sync/00-assert.yaml | 5 +++-- tests/e2e/vm-secret-sync/01-assert.yaml | 5 +++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/neonvm-daemon/cmd/main.go b/neonvm-daemon/cmd/main.go index d7dbcebf5..3fe279c8e 100644 --- a/neonvm-daemon/cmd/main.go +++ b/neonvm-daemon/cmd/main.go @@ -102,7 +102,7 @@ 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)) + 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