Skip to content

Commit

Permalink
fix where creating the mount dir takes place
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Feb 3, 2025
1 parent d885222 commit c272e69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
26 changes: 1 addition & 25 deletions neonvm-daemon/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,10 @@ func (s *cpuServer) handleSetCPUStatus(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}

func (s *cpuServer) getMountDir(path string) (string, error) {
return fmt.Sprintf("/%s", path), nil
}

func (s *cpuServer) handleGetFileChecksum(w http.ResponseWriter, path string) {
s.fileOperationsMutex.Lock()
defer s.fileOperationsMutex.Unlock()

path, err := s.getMountDir(path)
if err != nil {
s.logger.Error("invalid file path", zap.Error(err))
w.WriteHeader(http.StatusBadRequest)
return
}

dir := filepath.Join(path, "..data")
checksum, err := util.ChecksumFlatDir(dir)
if err != nil {
Expand All @@ -140,13 +129,6 @@ func (s *cpuServer) handleUploadFile(w http.ResponseWriter, r *http.Request, pat
s.fileOperationsMutex.Lock()
defer s.fileOperationsMutex.Unlock()

path, err := s.getMountDir(path)
if err != nil {
s.logger.Error("invalid file path", zap.Error(err))
w.WriteHeader(http.StatusBadRequest)
return
}

if r.Body == nil {
s.logger.Error("no body")
w.WriteHeader(http.StatusBadRequest)
Expand Down Expand Up @@ -185,12 +167,6 @@ func (s *cpuServer) handleUploadFile(w http.ResponseWriter, r *http.Request, pat
}
}

if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
s.logger.Error("could not create directory", zap.Error(err))
w.WriteHeader(http.StatusInternalServerError)
return
}

aw, err := k8sutil.NewAtomicWriter(path, "neonvm-daemon")
if err != nil {
s.logger.Error("could not create writer", zap.Error(err))
Expand Down Expand Up @@ -222,7 +198,7 @@ func (s *cpuServer) run(addr string) {
}
})
mux.HandleFunc("/files/{path...}", func(w http.ResponseWriter, r *http.Request) {
path := r.PathValue("path")
path := fmt.Sprintf("/%s", r.PathValue("path"))
if r.Method == http.MethodGet {
s.handleGetFileChecksum(w, path)
return
Expand Down
6 changes: 3 additions & 3 deletions neonvm-runner/cmd/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ func createISO9660runtime(

if len(disks) != 0 {
for _, disk := range disks {
if disk.MountPath != "" {
mounts = append(mounts, fmt.Sprintf(`/neonvm/bin/mkdir -p %s`, disk.MountPath))
}
if diskNeedsSynchronisation(disk) {
// do nothing as we will mount it into the VM via neonvm-daemon later
continue
}
if disk.MountPath != "" {
mounts = append(mounts, fmt.Sprintf(`/neonvm/bin/mkdir -p %s`, disk.MountPath))
}
switch {
case disk.EmptyDisk != nil:
opts := ""
Expand Down

0 comments on commit c272e69

Please sign in to comment.