Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Feb 3, 2025
1 parent da908b4 commit 26f66b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions neonvm-daemon/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"time"

"go.uber.org/zap"

k8sutil "k8s.io/kubernetes/pkg/volume/util"

vmv1 "github.com/neondatabase/autoscaling/neonvm/apis/neonvm/v1"
Expand Down
22 changes: 10 additions & 12 deletions neonvm-runner/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
vmv1 "github.com/neondatabase/autoscaling/neonvm/apis/neonvm/v1"
"github.com/neondatabase/autoscaling/pkg/util"
"github.com/neondatabase/autoscaling/pkg/util/taskgroup"
corev1 "k8s.io/api/core/v1"
)

const (
Expand Down Expand Up @@ -682,20 +681,18 @@ func monitorFiles(ctx context.Context, logger *zap.Logger, wg *sync.WaitGroup, d
}
defer notify.Close()

secrets := make(map[string][]corev1.KeyToPath)
// watched := make(map[string]string)
watched2 := make(map[string]string)
secrets := make(map[string]string)
for _, disk := range disks {
if disk.Secret != nil && secretNeedsSynchronisation(disk.MountPath) {
rel, _ := filepath.Rel("/var/sync", disk.MountPath)
root := fmt.Sprintf("/vm/mounts%s", disk.MountPath)

if err := notify.Add(filepath.Join(root, "..data")); err != nil {
// secrets are mounted using the atomicwriter utility, which loads the secret directory
// into `..data`.
dataDir := fmt.Sprintf("/vm/mounts%s/..data", disk.MountPath)
if err := notify.Add(dataDir); err != nil {
logger.Error("failed to add file to inotify instance", zap.Error(err))
}
watched2[filepath.Join(root, "..data")] = rel

secrets[root] = disk.Secret.Items
secrets[dataDir] = rel
}
}

Expand All @@ -709,7 +706,7 @@ func monitorFiles(ctx context.Context, logger *zap.Logger, wg *sync.WaitGroup, d
}

success := true
for hostpath, guestpath := range watched2 {
for hostpath, guestpath := range secrets {
if err := sendFilesToNeonvmDaemon(ctx, hostpath, guestpath); err != nil {
success = false
logger.Error("failed to upload file to vm guest", zap.Error(err))
Expand All @@ -728,9 +725,10 @@ func monitorFiles(ctx context.Context, logger *zap.Logger, wg *sync.WaitGroup, d
case <-ctx.Done():
return
case event := <-notify.Events:
guestpath, ok := watched2[event.Name]
guestpath, ok := secrets[event.Name]
if !ok {
// not tracking this file
// this can occur due to recursive file tracking
continue
}

Expand All @@ -751,7 +749,7 @@ func monitorFiles(ctx context.Context, logger *zap.Logger, wg *sync.WaitGroup, d
logger.Error("failed to upload file to vm guest", zap.Error(err))
}
case <-ticker.C:
for hostpath, guestpath := range watched2 {
for hostpath, guestpath := range secrets {
hostsum, err := util.ChecksumFlatDir(hostpath)
if err != nil {
logger.Error("failed to get file checksum from host", zap.Error(err))
Expand Down

0 comments on commit 26f66b5

Please sign in to comment.