inventory

package
v0.16.1-rc0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 63 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagAPITimeout          = "api-timeout"
	FlagQueryTimeout        = "query-timeout"
	FlagRESTPort            = "rest-port"
	FlagGRPCPort            = "grpc-port"
	FlagPodName             = "pod-name"
	FlagPodNamespace        = "pod-namespace"
	FlagConfig              = "config"
	FlagProviderConfigsURL  = "provider-configs-url"
	FlagPciDbURL            = "provider-pcidb-url"
	FlagRegistryQueryPeriod = "registry-query-period"
	FlagDiscoveryImage      = "discovery-image"
)
View Source
const (
	CtxKeyRookClientSet    = fromctx.Key("rook-clientset")
	CtxKeyStorage          = fromctx.Key("storage")
	CtxKeyFeatureDiscovery = fromctx.Key("feature-discovery")
	CtxKeyInformersFactory = fromctx.Key("informers-factory")
	CtxKeyHwInfo           = fromctx.Key("hardware-info")
	CtxKeyClusterState     = fromctx.Key("cluster-state")
	CtxKeyConfig           = fromctx.Key("config")
)
View Source
const DefaultInterconnectResourcePattern = "rdma/rdma_shared_device_*"

DefaultInterconnectResourcePattern matches the `rdma/rdma_shared_device_*` extended resources the Mellanox / NVIDIA k8s-rdma-shared-device-plugin publishes (e.g. `rdma/rdma_shared_device_ib` for InfiniBand-pinned plugins, `rdma/rdma_shared_device_eth` for RoCE). Used when the operator's `interconnect.resource_patterns` config list is empty so the rc4 hardcoded behavior keeps working out of the box.

AKT-493: an operator running a non-Mellanox plugin (Broadcom bnxt RDMA, Intel E810 iwarp, etc.) can override this with one or more patterns under `interconnect.resource_patterns` in provider.yaml.

View Source
const InfinibandSysfsPath = "/host/sys/class/infiniband"

InfinibandSysfsPath is where the operator's hardware-discovery DaemonSet pod mounts the host's `/sys/class/infiniband` directory. Each entry under it is a symlink to a Mellanox/NVIDIA HCA device (typically `mlx5_0`, `mlx5_1`, ...).

Variables

View Source
var (
	ErrMetricsUnsupportedRequest = errors.New("unsupported request method")
)

Functions

func Cmd

func Cmd() *cobra.Command

func InformKubeObjects

func InformKubeObjects(ctx context.Context, pub pubsub.Publisher, informer cache.SharedIndexInformer, topic string)

func InformersFactoryFromCtx

func InformersFactoryFromCtx(ctx context.Context) informers.SharedInformerFactory

func RookClientFromCtx

func RookClientFromCtx(ctx context.Context) *rookclientset.Clientset

Types

type Config

type Config struct {
	Version        semver.Version     `json:"version" yaml:"version"`
	ClusterStorage []string           `json:"cluster_storage" yaml:"cluster_storage"`
	Exclude        Exclude            `json:"exclude" yaml:"exclude"`
	Interconnect   ConfigInterconnect `json:"interconnect" yaml:"interconnect"`
	// contains filtered or unexported fields
}

func ConfigFromCtx

func ConfigFromCtx(ctx context.Context) Config

func (*Config) Copy

func (cfg *Config) Copy() Config

func (*Config) FilterOutStorageClasses

func (cfg *Config) FilterOutStorageClasses(available []string)

func (*Config) HasStorageClass

func (cfg *Config) HasStorageClass(name string) bool

func (*Config) StorageClassesForNode

func (cfg *Config) StorageClassesForNode(name string) []string

func (*Config) UnmarshalYAML

func (cfg *Config) UnmarshalYAML(node *yaml.Node) error

type ConfigInterconnect added in v0.16.0

type ConfigInterconnect struct {
	// ResourcePatterns is the list of glob patterns the inventory
	// operator matches kubelet's extended-resource names against to find
	// the interconnect HCA pool. A bare string with no glob metacharacter
	// is treated as a literal prefix match (preserves rc4 behavior).
	ResourcePatterns []string `json:"resource_patterns" yaml:"resource_patterns"`
}

ConfigInterconnect holds tunables for GPU-interconnect discovery on the inventory operator. The defaults match the Mellanox/NVIDIA k8s-rdma-shared-device-plugin (the only one supported pre-rc5), so an operator who doesn't set anything continues to work unchanged.

AKT-493: providers running a non-Mellanox device plugin (e.g. Broadcom's bnxt RDMA plugin, Intel E810 iwarp plugin) publish their HCAs under vendor-specific extended-resource names like `broadcom.com/rdma` or `intel.com/iwarp_shared`. The hardcoded `rdma/rdma_shared_device_` prefix used to miss those entirely. ResourcePatterns accepts an arbitrary list of glob patterns (or bare strings, which match as a prefix or exact name); the first kubelet resource that matches any pattern wins.

func (*ConfigInterconnect) Copy added in v0.16.0

type ConfigNodes

type ConfigNodes struct {
	Exclude ExcludeRules `json:"exclude" yaml:"exclude"`
}

type ConfigStorage

type ConfigStorage struct {
	Exclude ExcludeRules `json:"exclude" yaml:"exclude"`
}

type Exclude

type Exclude struct {
	Nodes       ExcludeRules        `json:"nodes" yaml:"nodes"`
	NodeStorage ExcludeNodesStorage `json:"node_storage" yaml:"node_storage"`
}

func (*Exclude) Copy

func (nd *Exclude) Copy() Exclude

func (*Exclude) IsNodeExcluded

func (nd *Exclude) IsNodeExcluded(name string) bool

func (*Exclude) IsStorageNodeExcluded

func (nd *Exclude) IsStorageNodeExcluded(name string, class string) bool

type ExcludeNodeStorage

type ExcludeNodeStorage struct {
	NodeFilter *regexp.Regexp `json:"node_filter" yaml:"node_filter"`
	Classes    []string       `json:"classes" yaml:"classes"`
}

func (*ExcludeNodeStorage) Copy

func (*ExcludeNodeStorage) UnmarshalYAML

func (nd *ExcludeNodeStorage) UnmarshalYAML(node *yaml.Node) error

type ExcludeNodesStorage

type ExcludeNodesStorage []ExcludeNodeStorage

func (*ExcludeNodesStorage) Copy

type ExcludeRules

type ExcludeRules []*regexp.Regexp

func (*ExcludeRules) Copy

func (nd *ExcludeRules) Copy() ExcludeRules

func (*ExcludeRules) UnmarshalYAML

func (nd *ExcludeRules) UnmarshalYAML(node *yaml.Node) error

type IBDiscovery added in v0.16.0

type IBDiscovery struct {
	// NCCLIBHCAPrefixes is every distinct HCA device-name family present
	// under /sys/class/infiniband — e.g. ["mlx5"] on a uniform Mellanox
	// host or ["mlx5","bnxt_re"] on a mixed-vendor node. Empty when no
	// devices are present. Surfaced into the provider as
	// NodeCapabilities.NCCLHCAPrefixes and joined with `,` by the
	// workload builder as NCCL_IB_HCA (NCCL accepts comma-separated
	// device prefixes natively).
	NCCLIBHCAPrefixes []string `json:"nccl_ib_hca_prefixes"`

	// Fabric is "infiniband" or "roce", read from the link_layer of port 1
	// on the first detected device. Empty when no devices are present.
	// Surfaced into the provider as NodeCapabilities.InterconnectFabric and used
	// by the inventory client to gate fabric-pinned bids.
	Fabric string `json:"fabric"`
}

IBDiscovery is the JSON payload the psutil HTTP server returns for `/infiniband`. Both fields are empty when the host has no IB devices or when the DaemonSet pod was started without the sysfs mount.

func DiscoverInfinibandFromSysfs added in v0.16.0

func DiscoverInfinibandFromSysfs() IBDiscovery

DiscoverInfinibandFromSysfs walks `/sys/class/infiniband` on the host (via the InfinibandSysfsPath mount) and produces the IBDiscovery payload. Returns a zero-value IBDiscovery when sysfs is absent or unreadable; that is the natural state for non-interconnect nodes and the caller treats it as "this node has no interconnect capability." Errors are reserved for unexpected I/O conditions.

type QuerierCluster

type QuerierCluster interface {
	Query(ctx context.Context) (inventory.Cluster, error)
}

func ClusterStateFromCtx

func ClusterStateFromCtx(ctx context.Context) QuerierCluster

type QuerierNodes

type QuerierNodes interface {
	Query(ctx context.Context) (inventory.Nodes, error)
}

func FeatureDiscoveryFromCtx

func FeatureDiscoveryFromCtx(ctx context.Context) QuerierNodes

type QuerierStorage

type QuerierStorage interface{}

func NewCeph

func NewCeph(ctx context.Context) (QuerierStorage, error)

func NewRancher

func NewRancher(ctx context.Context) (QuerierStorage, error)

func StorageFromCtx

func StorageFromCtx(ctx context.Context) []QuerierStorage

type RegistryGPUDevice

type RegistryGPUDevice struct {
	Name       string `json:"name"`
	Interface  string `json:"interface"`
	MemorySize string `json:"memory_size"`
}

type RegistryGPUDevices

type RegistryGPUDevices map[string]RegistryGPUDevice

type RegistryGPUVendor

type RegistryGPUVendor struct {
	Name    string             `json:"name"`
	Devices RegistryGPUDevices `json:"devices"`
}

type RegistryGPUVendors

type RegistryGPUVendors map[string]RegistryGPUVendor

type RemotePodCommandExecutor

type RemotePodCommandExecutor interface {
	ExecWithOptions(ctx context.Context, options rookexec.ExecOptions) (string, string, error)
	ExecCommandInContainerWithFullOutput(ctx context.Context, appLabel, containerName, namespace string, cmd ...string) (string, string, error)
	// ExecCommandInContainerWithFullOutputWithTimeout uses 15s hard-coded timeout
	ExecCommandInContainerWithFullOutputWithTimeout(ctx context.Context, appLabel, containerName, namespace string, cmd ...string) (string, string, error)
}

func NewRemotePodCommandExecutor

func NewRemotePodCommandExecutor(restcfg *rest.Config, clientset kubernetes.Interface) RemotePodCommandExecutor

type Watcher

type Watcher interface {
	Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
}

Jump to

Keyboard shortcuts

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