Skip to content

Commit

Permalink
fix: wrong working dir in initd
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-jacques committed Jan 18, 2025
1 parent 2f8a243 commit 3436102
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core/cluster/placement/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ type PlacementResponse struct {
}

func (r PlacementResponse) GetScore() float64 {
cpuUtilization := float64(r.AllocatedAfter.MemoryMB) / float64(r.Allocatable.MemoryMB)
cpuUtilization := float64(r.AllocatedAfter.CpusMHz) / float64(r.Allocatable.CpusMHz)
memoryUtilization := float64(r.AllocatedAfter.MemoryMB) / float64(r.Allocatable.MemoryMB)

idealRatio := float64(r.Allocatable.MemoryMB) / float64(r.Allocatable.MemoryMB)
currentRatio := float64(r.AllocatedAfter.MemoryMB) / float64(r.AllocatedAfter.MemoryMB)
idealRatio := float64(r.Allocatable.MemoryMB) / float64(r.Allocatable.CpusMHz)
currentRatio := float64(r.AllocatedAfter.MemoryMB) / float64(r.AllocatedAfter.CpusMHz)

ratioScore := 1 - (idealRatio-currentRatio)/idealRatio

Expand Down
6 changes: 5 additions & 1 deletion initd/environment/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func buildCommand(cfg initd.Config) (*exec.Cmd, error) {
workingDir = *cfg.ImageConfig.WorkingDir
}

err := os.Chdir(workingDir)
if err != nil {
return nil, fmt.Errorf("error changing working directory: %v", err)
}

lp, err := exec.LookPath(args[0])
if err != nil {
return nil, fmt.Errorf("error searching for executable: %v", err)
Expand All @@ -46,7 +51,6 @@ func buildCommand(cfg initd.Config) (*exec.Cmd, error) {
Path: lp,
Args: args,
Env: envars,
Dir: workingDir,
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,
Expand Down

0 comments on commit 3436102

Please sign in to comment.