Files
nomad/client/interfaces/client.go
Seth Hoenig 2e1974a574 client: refactor cpuset partitioning (#18371)
* client: refactor cpuset partitioning

This PR updates the way Nomad client manages the split between tasks
that make use of resources.cpus vs. resources.cores.

Previously, each task was explicitly assigned which CPU cores they were
able to run on. Every time a task was started or destroyed, all other
tasks' cpusets would need to be updated. This was inefficient and would
crush the Linux kernel when a client would try to run ~400 or so tasks.

Now, we make use of cgroup heirarchy and cpuset inheritence to efficiently
manage cpusets.

* cr: tweaks for feedback
2023-09-12 09:11:11 -05:00

59 lines
1.8 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package interfaces
import (
"github.com/hashicorp/nomad/client/lib/idset"
"github.com/hashicorp/nomad/client/lib/numalib/hw"
"github.com/hashicorp/nomad/client/lib/proclib"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/plugins/device"
)
type Client interface {
AllocStateHandler
}
// AllocStateHandler exposes a handler to be called when an allocation's state changes
type AllocStateHandler interface {
// AllocStateUpdated is used to emit an updated allocation. This allocation
// is stripped to only include client settable fields.
AllocStateUpdated(alloc *structs.Allocation)
// PutAllocation is used to persist an updated allocation in the local state store.
PutAllocation(*structs.Allocation) error
}
// DeviceStatsReporter gives access to the latest resource usage
// for devices
type DeviceStatsReporter interface {
LatestDeviceResourceStats([]*structs.AllocatedDeviceResource) []*device.DeviceGroupStats
}
// EnvReplacer is an interface which can interpolate environment variables and
// is usually satisfied by taskenv.TaskEnv.
type EnvReplacer interface {
ReplaceEnv(string) string
ClientPath(string, bool) (string, bool)
}
// ArtifactGetter is an interface satisfied by the getter package.
type ArtifactGetter interface {
// Get artifact and put it in the task directory.
Get(EnvReplacer, *structs.TaskArtifact) error
}
// ProcessWranglers is an interface satisfied by the proclib package.
type ProcessWranglers interface {
Setup(proclib.Task) error
Destroy(proclib.Task) error
}
// CPUPartitions is an interface satisfied by the cgroupslib package.
type CPUPartitions interface {
Restore(*idset.Set[hw.CoreID])
Reserve(*idset.Set[hw.CoreID]) error
Release(*idset.Set[hw.CoreID]) error
}