sysinfo

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

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

View Source
const (
	StandardDeviceAttributePrefix = "dra.memory/"
)

Variables

View Source
var (
	ErrCGroupV2Missing         = errors.New("cgroup v2 not configured")
	ErrCGroupV2Repeated        = errors.New("cgroup v2 configured multiple times")
	ErrMemoryHugeTLBAccounting = errors.New("memory hugetlb accounting not supported")
)
View Source
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 HugepageSizes

func HugepageSizes(lh logr.Logger, sysRoot string) []string

func ToDevice

func ToDevice(sp types.Span) resourceapi.Device

func Validate

func Validate(lh logr.Logger, procRoot string) error

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 (ds *Discoverer) GetSpanForDevice(lh logr.Logger, devName string) (types.Span, error)

func (*Discoverer) Refresh

func (ds *Discoverer) Refresh(lh logr.Logger) error

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)

type Zone

type Zone struct {
	ID        int             `json:"id"`
	Distances []int           `json:"distances"`
	Memory    *ghwmemory.Area `json:"memory"`
}

func FromNodes

func FromNodes(nodes []*ghwtopology.Node) []Zone

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL