Skip to content

Commit

Permalink
feat(hatchery/k8s): add option to disable pod limit (#6530)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsamin committed Apr 6, 2023
1 parent f43efd0 commit 90b4eaa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
20 changes: 15 additions & 5 deletions engine/hatchery/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ func (h *HatcheryKubernetes) SpawnWorker(ctx context.Context, spawnArgs hatchery
},
})

var limits apiv1.ResourceList
if h.Config.DisableCPULimit {
limits = apiv1.ResourceList{
apiv1.ResourceMemory: *resource.NewScaledQuantity(memory, resource.Mega),
apiv1.ResourceEphemeralStorage: resource.MustParse(ephemeralStorage),
}
} else {
limits = apiv1.ResourceList{
apiv1.ResourceCPU: resource.MustParse(cpu),
apiv1.ResourceMemory: *resource.NewScaledQuantity(memory, resource.Mega),
apiv1.ResourceEphemeralStorage: resource.MustParse(ephemeralStorage),
}
}

var gracePeriodSecs int64
podSchema := apiv1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -312,11 +326,7 @@ func (h *HatcheryKubernetes) SpawnWorker(ctx context.Context, spawnArgs hatchery
apiv1.ResourceMemory: *resource.NewScaledQuantity(memory, resource.Mega),
apiv1.ResourceEphemeralStorage: resource.MustParse(ephemeralStorage),
},
Limits: apiv1.ResourceList{
apiv1.ResourceCPU: resource.MustParse(cpu),
apiv1.ResourceMemory: *resource.NewScaledQuantity(memory, resource.Mega),
apiv1.ResourceEphemeralStorage: resource.MustParse(ephemeralStorage),
},
Limits: limits,
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion engine/hatchery/kubernetes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var containerServiceNameRegexp = regexp.MustCompile(`service-([0-9]+)-(.*)`)
type HatcheryConfiguration struct {
service.HatcheryCommonConfiguration `mapstructure:"commonConfiguration" toml:"commonConfiguration" json:"commonConfiguration"`
// DefaultCPU Worker default CPU
DefaultCPU string `mapstructure:"defaultCPU" toml:"defaultCPU" default:"500m" commented:"false" comment:"Worker default CPU" json:"defaultCPU"`
DefaultCPU string `mapstructure:"defaultCPU" toml:"defaultCPU" default:"500m" commented:"false" comment:"Worker default CPU" json:"defaultCPU"`
DisableCPULimit bool `mapstructure:"disableCPULimit" toml:"disableCPULimit" default:"false" commented:"false" comment:"Disable Worker default CPU" json:"disableCPULimit"`
// DefaultMemory Worker default memory
DefaultMemory int `mapstructure:"defaultMemory" toml:"defaultMemory" default:"1024" commented:"false" comment:"Worker default memory in Mo" json:"defaultMemory"`
// DefaultEphemeralStorage Worker default ephemeral storage size
Expand Down

0 comments on commit 90b4eaa

Please sign in to comment.