Documentation ¶
Index ¶
- Constants
- Variables
- func AbnormalPodState(pod *v1.Pod) bool
- func AbnormalPodStateOfGodel(pod *v1.Pod, schedulerName string) bool
- func AssumedPod(pod *v1.Pod) bool
- func AssumedPodOfGodel(pod *v1.Pod, schedulerName string) bool
- func BoundPod(pod *v1.Pod) bool
- func CanPodBePreempted(pod *v1.Pod) int
- func CleanupPodAnnotations(client clientset.Interface, pod *v1.Pod) error
- func ConstructReservationAccordingToPod(pod *v1.Pod, defaultTTL int64) (res *schedulingv1alpha1.Reservation, err error)
- func ConvertReservationToPod(res *schedulingv1alpha1.Reservation) *v1.Pod
- func ConvertToPod(obj interface{}) (*v1.Pod, error)
- func CreateReservationFakePod(pod *v1.Pod) *v1.Pod
- func CreateReservationFakePodForAssume(pod *v1.Pod) *v1.Pod
- func DispatchedPod(pod *v1.Pod) bool
- func DispatchedPodOfGodel(pod *v1.Pod, schedulerName string) bool
- func DispatchedPodOfOtherScheduler(pod *v1.Pod, schedulerID string) bool
- func DispatchedPodOfThisScheduler(pod *v1.Pod, schedulerID string) bool
- func FilteringUpdate(filterFn func(*v1.Pod) bool, addFunc func(*v1.Pod) error, ...)
- func FindPort(pod *v1.Pod, svcPort *v1.ServicePort) (int, error)
- func GeneratePodKey(pod *v1.Pod) string
- func GetBestEffortPodAppName(pod *v1.Pod) string
- func GetContainerStatus(statuses []v1.ContainerStatus, name string) (v1.ContainerStatus, bool)
- func GetDefaultPriorityForGodelPod(pod *v1.Pod) int32
- func GetExistingContainerStatus(statuses []v1.ContainerStatus, name string) v1.ContainerStatus
- func GetFailedSchedulersNames(pod *v1.Pod) sets.String
- func GetMatchedReservationPlaceholderPod(pod *v1.Pod) string
- func GetMovementNameFromPod(pod *v1.Pod) string
- func GetOwnerInfo(pod *v1.Pod) (string, string)
- func GetOwnerInfoKey(ownerInfo *schedulingv1a1.OwnerInfo) string
- func GetPlaceholderFromReservation(res *schedulingv1alpha1.Reservation) string
- func GetPodAlignedResources(pod *v1.Pod) ([]string, bool)
- func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)
- func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)
- func GetPodFullKey(namespace, name, uid string) string
- func GetPodGroupName(pod *v1.Pod) string
- func GetPodGroupOwnerInfo(pod *v1.Pod) *schedulingv1a1.OwnerInfo
- func GetPodKey(pod *v1.Pod) string
- func GetPodOwner(pod *v1.Pod) string
- func GetPodOwnerInfo(pod *v1.Pod) *schedulingv1a1.OwnerInfo
- func GetPodOwnerInfoKey(pod *v1.Pod) string
- func GetPodPriority(pod *v1.Pod) int32
- func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition
- func GetPodRequest(pod *v1.Pod, resourceType v1.ResourceName, format resource.Format) *resource.Quantity
- func GetPodRequests(pod *v1.Pod) map[string]*resource.Quantity
- func GetPodReservationTimeoutPeriod(pod *v1.Pod) int64
- func GetPodTemplateKey(pod *v1.Pod) string
- func GetPodUID(pod *v1.Pod) (string, error)
- func GetProtectionDuration(objectKey string, annotations map[string]string) (int64, bool)
- func GetQoSLevelForPod(pod *v1.Pod) util.QoSLevel
- func GetRSFromPod(pod *v1.Pod) (string, error)
- func GetReservationIndex(pod *v1.Pod) string
- func GetReservationKey(res *schedulingv1alpha1.Reservation) string
- func GetReservationPlaceholder(pod *v1.Pod) string
- func GetSchedulerNameForPod(pod *v1.Pod) string
- func GetSelectedNodeOfLpv(pvcLister corelisters.PersistentVolumeClaimLister, pod *v1.Pod) (nodename string)
- func GetUIDFromPodFullKey(key string) string
- func HasMatchedReservationPlaceholder(pod *v1.Pod) bool
- func HasReservationRequirement(pod *v1.Pod) bool
- func IgnorePodsLimit(pod *v1.Pod) bool
- func IsLongRunningTask(pod *v1.Pod) bool
- func IsPlaceholderPod(p *v1.Pod) bool
- func IsPodAvailable(pod *v1.Pod, minReadySeconds int32, now metav1.Time) bool
- func IsPodEligibleForPreemption(pod *v1.Pod) bool
- func IsPodReady(pod *v1.Pod) bool
- func IsPodReadyConditionTrue(status v1.PodStatus) bool
- func IsPvcVolumeLocalPV(pvcLister corelisters.PersistentVolumeClaimLister, pvc string, pod *v1.Pod) (bool, string)
- func IsReservationPlaceholderPod(pod *v1.Pod) bool
- func IsSharedCores(pod *v1.Pod) bool
- func LegalPodResourceTypeAndLauncher(pod *v1.Pod) bool
- func NodeExists(nodeName string, nodeLister lister.NodeLister, ...) (bool, error)
- func ParsePodKey(str string) (string, string, types.UID, error)
- func PendingPod(pod *v1.Pod) bool
- func PendingPodOfGodel(pod *v1.Pod, schedulerName string) bool
- func PodHasDaemonSetOwnerReference(pod *v1.Pod) bool
- func SchedulerExists(schedulerName string, schedulerLister schedulerv1alpha1.SchedulerLister) (bool, error)
- func ShouldOccupyResources(res *schedulingv1alpha1.Reservation) bool
- func UpdatePodCondition(status *v1.PodStatus, condition *v1.PodCondition) bool
- func VisitContainers(podSpec *v1.PodSpec, mask ContainerType, visitor ContainerVisitor) bool
- func VisitPodConfigmapNames(pod *v1.Pod, visitor Visitor) bool
- func VisitPodSecretNames(pod *v1.Pod, visitor Visitor) bool
- type ContainerType
- type ContainerVisitor
- type PodLauncher
- type PodResourceType
- type PodState
- type Visitor
Constants ¶
const ( // PodStateAnnotationKey is a pod annotation key, value is the pod state PodStateAnnotationKey = "godel.bytedance.com/pod-state" // SchedulerAnnotationKey is a pod annotation key, value is the scheduler id who is responsible for scheduling this pod SchedulerAnnotationKey = "godel.bytedance.com/selected-scheduler" // FailedSchedulersAnnotationKey is a pod annotation key, value is schedulers who have already tried and failed to schedule the pod // this is used only when Node Partition is physical FailedSchedulersAnnotationKey = "godel.bytedance.com/failed-schedulers" // TraceContext represents the span context for the pod TraceContext = "trace-context" // AssumedNodeAnnotationKey is a pod annotation key, value is the assumed node name chosen by one scheduler // the scheduler will reserve the allocated resource for the pod. TODO: should all schedulers be aware of this ? // TODO: figure out if we can return multiple nodes ? if so how to deal with scheduler cache ? AssumedNodeAnnotationKey = "godel.bytedance.com/assumed-node" // TODO: figure out how to define cross node constraint and whether we need this annotation // AssumedCrossNodeAnnotationKey is a pod annotation key, value is the assumed node name chosen by one scheduler // the scheduler will reserve the allocated resource for the pod. // Pod need to resolve cross node constraint AssumedCrossNodeAnnotationKey = "godel.bytedance.com/assumed-cross-node" // PodGroupNameAnnotationKey is pod annotation key, the value is name of PodGroup custom resource. PodGroupNameAnnotationKey = "godel.bytedance.com/pod-group-name" // PotentialVictimsAnnotationKey is a pod annotation key, value is the victims chosen by dispatcher // this is used for best effort application pods // values can be like: [{queue: queue1, application: app1}, {queue: queue2, application: app2}]... PotentialVictimsAnnotationKey = "godel.bytedance.com/potential-victims" // NominatedNodeAnnotationKey is a pod annotation key, // value is the node name chosen by scheduler for placing the pending pod by evicting others // value can be like: {node: node1, victims: pod1, pod2...} // the scheduler will reserve the allocated resource for the pod. TODO: should all schedulers be aware of this ? // TODO: figure out if we can return multiple nodes ? if so how to deal with scheduler cache ? NominatedNodeAnnotationKey = "godel.bytedance.com/nominated-node" // ATTENTION: This annotation key will be DEPRECATED in the future and REPLACED by `QoSLevelKey=katalyst.kubewharf.io/qos_level`. // PodResourceTypeAnnotationKey is a pod annotation key, value is the pod resource type (guaranteed or best-effort) PodResourceTypeAnnotationKey = "godel.bytedance.com/pod-resource-type" // PodLauncherAnnotationKey is a pod annotation key, value is the launcher of this pod (kubelet or node-manager) PodLauncherAnnotationKey = "godel.bytedance.com/pod-launcher" // InitialHandledTimestampAnnotationKey is a pod annotation key, value is the timestamp when the pod is first handled by Godel Scheduler InitialHandledTimestampAnnotationKey = "godel.bytedance.com/initial-handled-timestamp" // MicroTopologyKey is an annotation key for pod micro topology assigned by scheduler&binder MicroTopologyKey = "godel.bytedance.com/micro-topology" IgnorePodsLimitAnnotationKey = "godel.bytedance.com/ignore-pods-limit" ProtectionDurationFromPreemptionKey = "godel.bytedance.com/protection-duration-from-preemption" UnitScheduledIndexAnnotationKey = "godel.bytedance.com/scheduled-index-in-scheduling-unit" // E2EExcludedPodAnnotationKey is a pod annotation key, pods with this annotation will be excluded when calculating e2e latency E2EExcludedPodAnnotationKey = "godel.bytedance.com/e2e-excluded" IncreasePercentageOfNodesToScoreAnnotationKey = "godel.bytedance.com/increase-percentage-of-nodes-to-score" IncreasePercentageOfNodesToScore = "true" MovementNameKey = "godel.bytedance.com/movement-name" // Pods with same request template share the same requirements. PodRequestTemplateAnnotationKey = "godel.bytedance.com/request-template" // reservation related MatchedReservationPlaceholderKey = "godel.bytedance.com/matched-reservation-placeholder" ReservationTTLKey = "godel.bytedance.com/reservation-ttl" )
const ( GuaranteedPod PodResourceType = "guaranteed" BestEffortPod PodResourceType = "best-effort" // UndefinedPod only used in metrics label UndefinedPod PodResourceType = "undefined" // Default priority values for pods with different resource types DefaultPriorityValueForGuaranteedPod int32 = 100 DefaultPriorityValueForBestEffortPod int32 = 40 )
const ( ReplicaSetKind = "ReplicaSet" StatefulSetKind = "StatefulSet" StatefulSetExtension = "StatefulSetExtension" RequestClassKind = "RequestClass" PodGroupKind = "PodGroup" DaemonSetKind = "DaemonSet" RequestTemplateKind = "RequestTemplate" KeySeperator string = "/" )
const ( PodResourceReservationAnnotationForGodel = "godel.bytedance.com/reservation" PodHasReservationRequirement = "true" PodResourceReservationAnnotation = "pod.tce.kubernetes.io/reservation" // In memory object annotation for reservation placeholderPod. ReservationPlaceHolderPodAnnotation = "godel.bytedance.com/reservation-placeholder" IsReservationPlaceHolderPods = "true" ReservationIndexAnnotation = "godel.bytedance.com/reservation-index" PlaceholderPodUIDAnno = "godel.bytedance.com/placeholder-uid" ReservationOwnerTypeAnno = "godel.bytedance.com/reservation-owner-type" ReservationOwnerNameAnno = "godel.bytedance.com/reservation-owner" ReservationOriginalPodNameAnno = "godel.bytedance.com/reservation-original-pod" )
const (
AlignedResources = "godel.bytedance.com/aligned-resources"
)
const AllContainers = InitContainers | Containers | EphemeralContainers
AllContainers specifies that all containers be visited
const PodKeySeperator string = "/"
const RSKind = "ReplicaSet"
const ReservationPlaceholderPostFix = "-placeholder"
Variables ¶
var ( PodLauncherUnsupportError = fmt.Errorf("pod launcher only allow %v", []PodLauncher{Kubelet, NodeManager}) PodLauncherMissedError = fmt.Errorf("missing pod launcher") )
var ( PodResourceTypeUnsupportError = fmt.Errorf("pod resource type only allow %v", []PodResourceType{GuaranteedPod, BestEffortPod}) PodResourceTypeMissedError = fmt.Errorf("missing pod resource type") )
Functions ¶
func AbnormalPodState ¶
AbnormalPodState checks if the given pod is in abnormal state
func AssumedPod ¶
AssumedPod checks if the given pod is in assumed state
func CanPodBePreempted ¶
CanPodBePreempted indicates whether the pod can be preempted -1: not pass 0: not sure 1: pass
func CleanupPodAnnotations ¶
func ConstructReservationAccordingToPod ¶
func ConstructReservationAccordingToPod(pod *v1.Pod, defaultTTL int64) (res *schedulingv1alpha1.Reservation, err error)
TODO: make Reservation & fakepod relationship simple & clean.
func ConvertReservationToPod ¶
func ConvertReservationToPod(res *schedulingv1alpha1.Reservation) *v1.Pod
func ConvertToPod ¶
func DispatchedPod ¶
DispatchedPod checks if the given pod is in dispatched state
func FilteringUpdate ¶
func FindPort ¶
FindPort locates the container port for the given pod and portName. If the targetPort is a number, use that. If the targetPort is a string, look that string up in all named ports in all containers in the target pod. If no match is found, fail.
func GeneratePodKey ¶
func GetBestEffortPodAppName ¶
func GetContainerStatus ¶
func GetContainerStatus(statuses []v1.ContainerStatus, name string) (v1.ContainerStatus, bool)
GetContainerStatus extracts the status of container "name" from "statuses". It also returns if "name" exists.
func GetDefaultPriorityForGodelPod ¶
GetDefaultPriorityForGodelPod return the default priority. used by unit creation
func GetExistingContainerStatus ¶
func GetExistingContainerStatus(statuses []v1.ContainerStatus, name string) v1.ContainerStatus
GetExistingContainerStatus extracts the status of container "name" from "statuses", It also returns if "name" exists.
func GetFailedSchedulersNames ¶
GetFailedSchedulersNames return failed schedulers of the given pod, from annotation failedSchedulers, in the format of sets.String
func GetMovementNameFromPod ¶
func GetOwnerInfoKey ¶
func GetOwnerInfoKey(ownerInfo *schedulingv1a1.OwnerInfo) string
func GetPlaceholderFromReservation ¶
func GetPlaceholderFromReservation(res *schedulingv1alpha1.Reservation) string
func GetPodCondition ¶
func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)
GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.
func GetPodConditionFromList ¶
func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)
GetPodConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.
func GetPodFullKey ¶
func GetPodGroupName ¶
GetPodGroupName return pod group name
func GetPodGroupOwnerInfo ¶
func GetPodGroupOwnerInfo(pod *v1.Pod) *schedulingv1a1.OwnerInfo
func GetPodOwner ¶
TODO: Convergence related function calls. GetPodOwner will consider PodGroup as well.
func GetPodOwnerInfo ¶
func GetPodOwnerInfo(pod *v1.Pod) *schedulingv1a1.OwnerInfo
func GetPodOwnerInfoKey ¶
func GetPodPriority ¶
GetPodPriority returns priority of the given pod.
func GetPodReadyCondition ¶
func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition
GetPodReadyCondition extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.
func GetPodRequest ¶
func GetPodTemplateKey ¶
func GetProtectionDuration ¶
func GetReservationIndex ¶
func GetReservationKey ¶
func GetReservationKey(res *schedulingv1alpha1.Reservation) string
func GetReservationPlaceholder ¶
TODO: re-implement this, can not get deployment name from annotation
func GetSchedulerNameForPod ¶
func GetSelectedNodeOfLpv ¶
func GetSelectedNodeOfLpv(pvcLister corelisters.PersistentVolumeClaimLister, pod *v1.Pod) (nodename string)
func GetUIDFromPodFullKey ¶
func IgnorePodsLimit ¶
func IsLongRunningTask ¶
IsLongRunningTask checks if this pod is long-running task
func IsPlaceholderPod ¶
func IsPodAvailable ¶
IsPodAvailable returns true if a pod is available; false otherwise. Precondition for an available pod is that it must be ready. On top of that, there are two cases when a pod can be considered available: 1. minReadySeconds == 0, or 2. LastTransitionTime (is set) + minReadySeconds < current time
func IsPodEligibleForPreemption ¶
IsPodEligibleForPreemption returns false if a pod never preempts; true otherwise.
func IsPodReady ¶
IsPodReady returns true if a pod is ready; false otherwise.
func IsPodReadyConditionTrue ¶
IsPodReadyConditionTrue returns true if a pod is ready; false otherwise.
func IsPvcVolumeLocalPV ¶
func IsPvcVolumeLocalPV(pvcLister corelisters.PersistentVolumeClaimLister, pvc string, pod *v1.Pod) (bool, string)
func IsSharedCores ¶
func NodeExists ¶
func NodeExists(nodeName string, nodeLister lister.NodeLister, nmNodeLister nodelister.NMNodeLister) (bool, error)
NodeExists checks if the given node exists
func PendingPod ¶
PendingPod checks if the given pod is in pending state
func PodHasDaemonSetOwnerReference ¶
TODO: revisit this.
func SchedulerExists ¶
func SchedulerExists(schedulerName string, schedulerLister schedulerv1alpha1.SchedulerLister) (bool, error)
SchedulerExists checks if the given scheduler exists
func ShouldOccupyResources ¶
func ShouldOccupyResources(res *schedulingv1alpha1.Reservation) bool
func UpdatePodCondition ¶
func UpdatePodCondition(status *v1.PodStatus, condition *v1.PodCondition) bool
UpdatePodCondition updates existing pod condition or creates a new one. Sets LastTransitionTime to now if the status has changed. Returns true if pod condition has changed or has been added.
func VisitContainers ¶
func VisitContainers(podSpec *v1.PodSpec, mask ContainerType, visitor ContainerVisitor) bool
VisitContainers invokes the visitor function with a pointer to every container spec in the given pod spec with type set in mask. If visitor returns false, visiting is short-circuited. VisitContainers returns true if visiting completes, false if visiting was short-circuited.
func VisitPodConfigmapNames ¶
VisitPodConfigmapNames invokes the visitor function with the name of every configmap referenced by the pod spec. If visitor returns false, visiting is short-circuited. Transitive references (e.g. pod -> pvc -> pv -> secret) are not visited. Returns true if visiting completed, false if visiting was short-circuited.
func VisitPodSecretNames ¶
VisitPodSecretNames invokes the visitor function with the name of every secret referenced by the pod spec. If visitor returns false, visiting is short-circuited. Transitive references (e.g. pod -> pvc -> pv -> secret) are not visited. Returns true if visiting completed, false if visiting was short-circuited.
Types ¶
type ContainerType ¶
type ContainerType int
ContainerType signifies container type
const ( // Containers is for normal containers Containers ContainerType = 1 << iota // InitContainers is for init containers InitContainers // EphemeralContainers is for ephemeral containers EphemeralContainers )
func AllFeatureEnabledContainers ¶
func AllFeatureEnabledContainers() ContainerType
AllFeatureEnabledContainers returns a ContainerType mask which includes all container types except for the ones guarded by feature gate.
type ContainerVisitor ¶
type ContainerVisitor func(container *v1.Container, containerType ContainerType) (shouldContinue bool)
ContainerVisitor is called with each container spec, and returns true if visiting should continue.
type PodLauncher ¶
type PodLauncher string
const ( Kubelet PodLauncher = "kubelet" NodeManager PodLauncher = "node-manager" )
func GetPodLauncher ¶
func GetPodLauncher(pod *v1.Pod) (PodLauncher, error)
GetPodLauncher return the launcher of the given pod, only kubelet and node-manager are allowed.
type PodResourceType ¶
type PodResourceType string
func GetPodResourceType ¶
func GetPodResourceType(pod *v1.Pod) (PodResourceType, error)
GetPodResourceType return the resource type of the given pod only Guaranteed and BestEffort are allowed.
func GetResourceTypeFromQoS ¶
func GetResourceTypeFromQoS(qosLevel string) PodResourceType