Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 3436102

Browse files
committed
fix: wrong working dir in initd
1 parent 2f8a243 commit 3436102

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

core/cluster/placement/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ type PlacementResponse struct {
1616
}
1717

1818
func (r PlacementResponse) GetScore() float64 {
19-
cpuUtilization := float64(r.AllocatedAfter.MemoryMB) / float64(r.Allocatable.MemoryMB)
19+
cpuUtilization := float64(r.AllocatedAfter.CpusMHz) / float64(r.Allocatable.CpusMHz)
2020
memoryUtilization := float64(r.AllocatedAfter.MemoryMB) / float64(r.Allocatable.MemoryMB)
2121

22-
idealRatio := float64(r.Allocatable.MemoryMB) / float64(r.Allocatable.MemoryMB)
23-
currentRatio := float64(r.AllocatedAfter.MemoryMB) / float64(r.AllocatedAfter.MemoryMB)
22+
idealRatio := float64(r.Allocatable.MemoryMB) / float64(r.Allocatable.CpusMHz)
23+
currentRatio := float64(r.AllocatedAfter.MemoryMB) / float64(r.AllocatedAfter.CpusMHz)
2424

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

initd/environment/command.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ func buildCommand(cfg initd.Config) (*exec.Cmd, error) {
3737
workingDir = *cfg.ImageConfig.WorkingDir
3838
}
3939

40+
err := os.Chdir(workingDir)
41+
if err != nil {
42+
return nil, fmt.Errorf("error changing working directory: %v", err)
43+
}
44+
4045
lp, err := exec.LookPath(args[0])
4146
if err != nil {
4247
return nil, fmt.Errorf("error searching for executable: %v", err)
@@ -46,7 +51,6 @@ func buildCommand(cfg initd.Config) (*exec.Cmd, error) {
4651
Path: lp,
4752
Args: args,
4853
Env: envars,
49-
Dir: workingDir,
5054
Stdin: os.Stdin,
5155
Stdout: os.Stdout,
5256
Stderr: os.Stderr,

0 commit comments

Comments
 (0)