utils

package
v0.0.0-...-e9ffd63 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MulanPSL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceNamePrefix    = "unifiedbus.com"
	URMAResource          = "ub_net_device"
	MaxResourceNameLength = 63
	ResourceName          = ResourceNamePrefix + "/" + URMAResource

	KubeletCheckpoint = "/var/lib/kubelet/device-plugins/kubelet_internal_checkpoint"
	RuntimeSock       = "/run/containerd/containerd.sock"

	TidDevicePath = "/dev/ummu/tid"
	UBCorePath    = "/dev/ubcore/ubcore"
	Permission    = 0666

	GrpcTimeOut = 30 * time.Second
)

Variables

This section is empty.

Functions

func EnsureDevicePermission

func EnsureDevicePermission(path string, perm int) error

func GetAllDeviceIdsFromKubeletCheckpoint

func GetAllDeviceIdsFromKubeletCheckpoint(filePath string) ([]string, error)

func GetPodUIDByDeviceID

func GetPodUIDByDeviceID(deviceID string, filePath string) (string, error)

func GetSandboxPid

func GetSandboxPid(ctx context.Context, client cri.RuntimeService, sandboxId string) (string, error)

func GetSandboxes

func GetSandboxes(ctx context.Context, client cri.RuntimeService, podUid string) ([]*runtimeapi.PodSandbox, error)

Types

type DataV1

type DataV1 struct {
	PodDeviceEntries []PodDeviceEntryV1 `json:"PodDeviceEntries"`
}

type DataV2

type DataV2 struct {
	PodDeviceEntries []PodDeviceEntryV2 `json:"PodDeviceEntries"`
}

type FakeFileInfo

type FakeFileInfo struct {
	// contains filtered or unexported fields
}

func (*FakeFileInfo) IsDir

func (f *FakeFileInfo) IsDir() bool

func (*FakeFileInfo) ModTime

func (f *FakeFileInfo) ModTime() time.Time

func (*FakeFileInfo) Mode

func (f *FakeFileInfo) Mode() fs.FileMode

func (*FakeFileInfo) Name

func (f *FakeFileInfo) Name() string

func (*FakeFileInfo) Size

func (f *FakeFileInfo) Size() int64

func (*FakeFileInfo) Sys

func (f *FakeFileInfo) Sys() any

type FileContentV1

type FileContentV1 struct {
	Data     DataV1 `json:"Data"`
	Checksum int    `json:"Checksum"`
}

type FileContentV2

type FileContentV2 struct {
	Data     DataV2 `json:"Data"`
	Checksum int    `json:"Checksum"`
}

type MockUtils

type MockUtils struct {
	StatPatches                    *gomonkey.Patches
	ChmodPatches                   *gomonkey.Patches
	GetPodUIDByDeviceIDPatches     *gomonkey.Patches
	NewRemoteRuntimeServicePatches *gomonkey.Patches
	GetSandboxesPatches            *gomonkey.Patches
	GetSandboxPidPatches           *gomonkey.Patches
	CombinedOutputPatches          *gomonkey.Patches

	ResetFunc []func()
	// contains filtered or unexported fields
}

func (*MockUtils) MockCombinedOutput

func (m *MockUtils) MockCombinedOutput(name string)

func (*MockUtils) MockGetPodUIDByDeviceID

func (m *MockUtils) MockGetPodUIDByDeviceID()

func (*MockUtils) MockGetSandboxPid

func (m *MockUtils) MockGetSandboxPid()

func (*MockUtils) MockGetSandboxes

func (m *MockUtils) MockGetSandboxes()

func (*MockUtils) MockNewRemoteRuntimeService

func (m *MockUtils) MockNewRemoteRuntimeService()

func (*MockUtils) Reset

func (m *MockUtils) Reset()

type PodDeviceEntryV1

type PodDeviceEntryV1 struct {
	PodUID        string   `json:"PodUID"`
	ContainerName string   `json:"ContainerName"`
	ResourceName  string   `json:"ResourceName"`
	DeviceIDs     []string `json:"DeviceIDs"`
	AllocResp     string   `json:"AllocResp"`
}

In Kubernetes versions 1.19 and earlier, the DevicesIDs field is of type []string.

type PodDeviceEntryV2

type PodDeviceEntryV2 struct {
	PodUID        string             `json:"PodUID"`
	ContainerName string             `json:"ContainerName"`
	ResourceName  string             `json:"ResourceName"`
	DeviceIDs     map[int64][]string `json:"DeviceIDs"`
	AllocResp     string             `json:"AllocResp"`
}

In Kubernetes versions 1.20 and later, the DevicesIDs field is of type map[int64][]string.

Source Files

  • consts.go
  • mock_utils.go
  • utils.go