utils

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 8 more Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TruncateLen = 31
)

constants used in this package

Variables

View Source
var (
	//DefaultDialOptions contains default dial options used in grpc dial
	DefaultDialOptions = []grpc.DialOption{grpc.WithInsecure(), grpc.WithDialer(UnixDial), grpc.WithBlock()}
)

Functions

func CreateDockerClient

func CreateDockerClient(endpoint string) libdocker.Interface

func GetCheckpointData

func GetCheckpointData(devicePluginPath string) (*types.Checkpoint, error)

func GetContainerIndexByName

func GetContainerIndexByName(pod *v1.Pod, containerName string) (int, error)

func GetGPUData

func GetGPUData(annotations map[string]string) (gpuUtil int64, gpuMemory int64, deviceNames []string)

GetGPUData get cores, memory and device names from annotations

func GetGPUMinorID

func GetGPUMinorID(path string) (int, error)

GetGPUMinorID returns id in Nvidia GPU device path

func GetGPUResourceOfContainer

func GetGPUResourceOfContainer(container *v1.Container, resourceName v1.ResourceName) uint

func GetGPUResourceOfPod

func GetGPUResourceOfPod(pod *v1.Pod, resourceName v1.ResourceName) uint

func GetPredicateTimeOfPod

func GetPredicateTimeOfPod(pod *v1.Pod) (predicateTime uint64)

func IsGPUAssignedPod

func IsGPUAssignedPod(pod *v1.Pod) bool

Check if pod has already been assigned

func IsGPUPredicatedPod

func IsGPUPredicatedPod(pod *v1.Pod) (predicated bool)

func IsGPURequiredContainer

func IsGPURequiredContainer(c *v1.Container) bool

func IsGPURequiredPod

func IsGPURequiredPod(pod *v1.Pod) bool

func IsStringSliceEqual

func IsStringSliceEqual(a, b []string) bool

func IsValidGPUPath

func IsValidGPUPath(path string) bool

IsValidGPUPath checks if path is valid Nvidia GPU device path

func MakeContainerNamePrefix

func MakeContainerNamePrefix(containerName string) string

func NewCgroupProcs

func NewCgroupProcs(cgroupMountPoint, cgroupDriver string) *linuxCgroupProcs

func NewFSWatcher

func NewFSWatcher(files ...string) (*fsnotify.Watcher, error)

NewFSWatcher returns a file watcher created by fsnotify.NewWatcher

func ShouldDelete

func ShouldDelete(pod *v1.Pod) bool

func ShouldRetry

func ShouldRetry(err error) bool

func TruncateContainerName

func TruncateContainerName(name string) string

TruncateContainerName truncate container names to name[:TruncateLen] if len(name) > TruncateLen

func UnixDial

func UnixDial(addr string, timeout time.Duration) (net.Conn, error)

UnixDial dials to a unix socket using net.DialTimeout

func WaitForServer

func WaitForServer(socket string) error

WaitForServer checks if grpc server is alive by making grpc blocking connection to the server socket

Types

type CgroupProcsReader

type CgroupProcsReader interface {
	Read(cgroupParent, containerID string) []int
}

type CgroupProcsWriter

type CgroupProcsWriter interface {
	Write(cgroupParent, containerID string, pids []int) error
}

Jump to

Keyboard shortcuts

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