Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Jan 28, 2025
1 parent d4f73a8 commit e54e858
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion neonvm-daemon/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Check failure on line 105 in neonvm-daemon/cmd/main.go

View workflow job for this annotation

GitHub Actions / golangci-lint

filepathJoin: "/var" contains a path separator (gocritic)
return path, nil
}

Expand Down
14 changes: 14 additions & 0 deletions neonvm-runner/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/vm-secret-sync/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/vm-secret-sync/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e54e858

Please sign in to comment.