Documentation
¶
Overview ¶
* Copyright 2025 The Kubernetes Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- Constants
- Variables
- func HugepageSizes(lh logr.Logger, sysRoot string) []string
- func MakeAttributes(sp types.Span) map[resourceapi.QualifiedName]resourceapi.DeviceAttribute
- func MakeCapacity(sp types.Span) map[resourceapi.QualifiedName]resourceapi.DeviceCapacity
- func ToDevice(sp types.Span) resourceapi.Device
- func Validate(lh logr.Logger, procRoot string) error
- type Discoverer
- func (ds *Discoverer) AllResourceNames() sets.Set[string]
- func (ds *Discoverer) GetCachedMachineData() MachineData
- func (ds *Discoverer) GetFreshMachineData(lh logr.Logger) (MachineData, error)
- func (ds *Discoverer) GetSpanForDevice(lh logr.Logger, devName string) (types.Span, error)
- func (ds *Discoverer) Refresh(lh logr.Logger) error
- func (ds *Discoverer) ResourceSlices() []resourceslice.Slice
- type GetMachineDataFunc
- type MachineData
- type Zone
Constants ¶
const (
StandardDeviceAttributePrefix = "dra.memory/"
)
Variables ¶
var ( ErrCGroupV2Missing = errors.New("cgroup v2 not configured") ErrCGroupV2Repeated = errors.New("cgroup v2 configured multiple times") ErrMemoryHugeTLBAccounting = errors.New("memory hugetlb accounting not supported") )
var MakeDeviceName = func(devName string) string { return strings.ToLower(devName) + "-" + k8srand.String(6) }
MakeDeviceName creates a unique short device name from the base device name ("memory", "hugepages-2m") We use a random part because the device name is not really that relevant, as long as it's unique. We can very much construct it concatenating nodeName and NUMAZoneID, that would be unique and equally valid as we expose plenty of low-level details like the NUMAZoneID anyway, but the concern is that we would need more validation, e.g, translating the nodeName (dots->dashes) and so on. Since users are expected to select memory devices by attribute and not by name, we just use a random suffix for the time being and move on.
Functions ¶
func MakeAttributes ¶
func MakeAttributes(sp types.Span) map[resourceapi.QualifiedName]resourceapi.DeviceAttribute
func MakeCapacity ¶
func MakeCapacity(sp types.Span) map[resourceapi.QualifiedName]resourceapi.DeviceCapacity
Types ¶
type Discoverer ¶
type Discoverer struct {
// GetMachineData is overridable to enable testing.
// We expect the vast majority of cases to be fine with default.
GetMachineData GetMachineDataFunc
// contains filtered or unexported fields
}
func NewDiscoverer ¶
func NewDiscoverer(sysRoot string) *Discoverer
func (*Discoverer) AllResourceNames ¶
func (ds *Discoverer) AllResourceNames() sets.Set[string]
func (*Discoverer) GetCachedMachineData ¶
func (ds *Discoverer) GetCachedMachineData() MachineData
func (*Discoverer) GetFreshMachineData ¶
func (ds *Discoverer) GetFreshMachineData(lh logr.Logger) (MachineData, error)
func (*Discoverer) GetSpanForDevice ¶
func (*Discoverer) ResourceSlices ¶
func (ds *Discoverer) ResourceSlices() []resourceslice.Slice
type GetMachineDataFunc ¶
type GetMachineDataFunc func(logr.Logger, string) (MachineData, error)
type MachineData ¶
type MachineData struct {
Pagesize uint64 `json:"page_size"`
Hugepagesizes []uint64 `json:"huge_page_sizes"`
Zones []Zone `json:"zones"`
}
func GetMachineData ¶
func GetMachineData(lh logr.Logger, sysRoot string) (MachineData, error)