utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert2Pod

func Convert2Pod(obj interface{}) (*v1.Pod, error)

func FindAppTaskGroup

func FindAppTaskGroup(appTaskGroups []*v1alpha1.TaskGroup, groupName string) (*v1alpha1.TaskGroup, error)

func GeneralPodFilter

func GeneralPodFilter(pod *v1.Pod) bool

func GeneratePlaceholderName

func GeneratePlaceholderName(taskGroupName, appID string, index int32) string

the placeholder name is the pod name, pod name can not be longer than 63 chars, taskGroup name and appID will be truncated if they go over 20/28 chars respectively, each taskGroup is assigned with an incremental index starting from 0.

func GetApplicationIDFromPod

func GetApplicationIDFromPod(pod *v1.Pod) (string, error)

func GetNamespaceQuotaFromAnnotation

func GetNamespaceQuotaFromAnnotation(namespaceObj *v1.Namespace) *si.Resource

func GetPlaceholderFlagFromPodSpec

func GetPlaceholderFlagFromPodSpec(pod *v1.Pod) bool

func GetPlaceholderResourceRequest

func GetPlaceholderResourceRequest(resources map[string]resource.Quantity) v1.ResourceList

func GetQueueNameFromPod

func GetQueueNameFromPod(pod *v1.Pod) string

func GetSchedulingPolicyParam

func GetSchedulingPolicyParam(pod *v1.Pod) *interfaces.SchedulingPolicyParameters

func GetTaskGroupFromPodSpec

func GetTaskGroupFromPodSpec(pod *v1.Pod) string

func GetTaskGroupsFromAnnotation

func GetTaskGroupsFromAnnotation(pod *v1.Pod) ([]v1alpha1.TaskGroup, error)

func GetUserFromPod

func GetUserFromPod(pod *v1.Pod) string

find user name from pod label

func IsAssignedPod

func IsAssignedPod(pod *v1.Pod) bool

assignedPod selects pods that are assigned (scheduled and running).

func IsPodRunning

func IsPodRunning(pod *v1.Pod) bool

func IsPodTerminated

func IsPodTerminated(pod *v1.Pod) bool

func MergeMaps

func MergeMaps(first, second map[string]string) map[string]string

merge two string maps if the same key defined in the first and second maps the value will be set by the second map

func NeedRecovery

func NeedRecovery(pod *v1.Pod) bool

func NewK8sResourceList

func NewK8sResourceList(resources ...K8sResource) map[v1.ResourceName]resource.Quantity

func NodeForTest

func NodeForTest(nodeID, memory, cpu string) *v1.Node

func PodForTest

func PodForTest(podName, memory, cpu string) *v1.Pod

func PodUnderCondition

func PodUnderCondition(pod *v1.Pod, condition *v1.PodCondition) bool

compare the existing pod condition with the given one, return true if the pod condition remains not changed. return false if pod has no condition set yet, or condition has changed.

func WaitForCondition

func WaitForCondition(eval func() bool, interval time.Duration, timeout time.Duration) error

Types

type K8sResource

type K8sResource struct {
	ResourceName v1.ResourceName
	Value        int64
}

type TaskGroupInstanceCountMap

type TaskGroupInstanceCountMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTaskGroupInstanceCountMap

func NewTaskGroupInstanceCountMap() *TaskGroupInstanceCountMap

func (*TaskGroupInstanceCountMap) Add

func (t *TaskGroupInstanceCountMap) Add(taskGroupName string, num int32)

func (*TaskGroupInstanceCountMap) AddOne

func (t *TaskGroupInstanceCountMap) AddOne(taskGroupName string)

func (*TaskGroupInstanceCountMap) DeleteOne

func (t *TaskGroupInstanceCountMap) DeleteOne(taskGroupName string)

func (*TaskGroupInstanceCountMap) Equals

func (*TaskGroupInstanceCountMap) GetTaskGroupInstanceCount

func (t *TaskGroupInstanceCountMap) GetTaskGroupInstanceCount(groupName string) int32

func (*TaskGroupInstanceCountMap) Size

func (t *TaskGroupInstanceCountMap) Size() int

Jump to

Keyboard shortcuts

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