utils

package
v0.3.0-rc Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ControllerRevisionLabelKey is the label key for ModelServing name
	ControllerRevisionLabelKey = workloadv1alpha1.ModelServingNameLabelKey
	// ControllerRevisionRevisionLabelKey is the label key for revision
	ControllerRevisionRevisionLabelKey = workloadv1alpha1.RevisionLabelKey
)
View Source
const (
	Entry = "true"

	// condition status of ModelServingStatus
	AllGroupsIsReady         = "All Serving groups are ready"
	SomeGroupsAreProgressing = "Some groups is progressing"
	SomeGroupsAreUpdated     = "Updated Groups are"
)

Variables

This section is empty.

Functions

func CheckPodRevision

func CheckPodRevision(pod *corev1.Pod, revision string) bool

CheckPodRevision determine if the pod's revision is compliant or not.

func CleanupOldControllerRevisions added in v0.3.0

func CleanupOldControllerRevisions(
	ctx context.Context,
	client kubernetes.Interface,
	ms *workloadv1alpha1.ModelServing,
) error

CleanupOldControllerRevisions deletes old ControllerRevisions that are no longer in use. In ModelServing, we typically have at most two revisions (CurrentRevision and UpdateRevision), so this cleanup removes all revisions except CurrentRevision and UpdateRevision.

func ContainerRestarted

func ContainerRestarted(pod *corev1.Pod) bool

ContainerRestarted return true when there is any container in the pod that gets restarted

func CreateControllerRevision added in v0.3.0

func CreateControllerRevision(ctx context.Context, client kubernetes.Interface, ms *workloadv1alpha1.ModelServing, revision string, templateData interface{}) (*appsv1.ControllerRevision, error)

CreateControllerRevision creates or retrieves a ControllerRevision for a specific revision. In ModelServing, we typically have at most two revisions: CurrentRevision and UpdateRevision.

func CreateHeadlessService

func CreateHeadlessService(ctx context.Context, k8sClient kubernetes.Interface, ms *workloadv1alpha1.ModelServing, serviceSelector map[string]string, groupName, roleLabel string, roleIndex int) error

func DeepHashObject

func DeepHashObject(hasher hash.Hash, objectToWrite interface{})

DeepHashObject writes specified object to hash using the spew library which follows pointers and prints actual values of the nested objects ensuring the hash does not change when a pointer changes.

func ExpectedPodNum

func ExpectedPodNum(ms *workloadv1alpha1.ModelServing) int

func GenerateControllerRevisionName added in v0.3.0

func GenerateControllerRevisionName(msName, revision string) string

func GenerateEntryPod

func GenerateEntryPod(role workloadv1alpha1.Role, ms *workloadv1alpha1.ModelServing, groupName string, roleIndex int, revision string) *corev1.Pod

func GeneratePodName added in v0.3.0

func GeneratePodName(groupName, roleName string, podIndex int) string

func GenerateRoleID

func GenerateRoleID(roleName string, idx int) string

func GenerateServingGroupName

func GenerateServingGroupName(miName string, idx int) string

func GenerateWorkerPod

func GenerateWorkerPod(role workloadv1alpha1.Role, ms *workloadv1alpha1.ModelServing, entryPod *corev1.Pod, groupName string, roleIndex, podIndex int, revision string) *corev1.Pod

func GetControllerRevision added in v0.3.0

func GetControllerRevision(
	ctx context.Context,
	client kubernetes.Interface,
	ms *workloadv1alpha1.ModelServing,
	revision string,
) (*appsv1.ControllerRevision, error)

GetControllerRevision retrieves a ControllerRevision by its revision string

func GetMaxUnavailable added in v0.3.0

func GetMaxUnavailable(mi *workloadv1alpha1.ModelServing) (int, error)

func GetModelServingAndGroupByLabel

func GetModelServingAndGroupByLabel(podLabels map[string]string) (string, string, bool)

func GetNamespaceName

func GetNamespaceName(obj metav1.Object) types.NamespacedName

func GetParentNameAndOrdinal

func GetParentNameAndOrdinal(groupName string) (string, int)

GetParentNameAndOrdinal gets the name of ServingGroup's parent modelServing and ServingGroup's ordinal as extracted from its Name. For example, the Servinggroup name is vllm-sample-0, this function can be used to obtain the modelServing name corresponding to the ServingGroup, which is vllm-sample and the serial number is 0.

func GetRoleID added in v0.3.0

func GetRoleID(resource metav1.Object) string

GetRoleID returns the role id of the resource.

func GetRoleName added in v0.3.0

func GetRoleName(resource metav1.Object) string

GetRoleName returns the role name of the resource.

func GetRolesFromControllerRevision added in v0.3.0

func GetRolesFromControllerRevision(cr *appsv1.ControllerRevision) ([]workloadv1alpha1.Role, error)

GetRolesFromControllerRevision extracts roles template data from a ControllerRevision

func GroupNameIndexFunc

func GroupNameIndexFunc(obj interface{}) ([]string, error)

func IsOwnedByModelServingWithUID added in v0.3.0

func IsOwnedByModelServingWithUID(obj metav1.Object, uid types.UID) bool

IsOwnedByModelServingWithUID returns true when the object is owned by the ModelServing with the provided UID.

func IsPodFailed

func IsPodFailed(pod *corev1.Pod) bool

IsPodFailed returns true if pod has a Phase of PodFailed.

func IsPodRunningAndReady

func IsPodRunningAndReady(pod *corev1.Pod) bool

IsPodRunningAndReady returns true if pod is in the PodRunning Phase, if it has a condition of PodReady.

func IsPodTerminating

func IsPodTerminating(pod *corev1.Pod) bool

IsPodTerminating returns true if pod's DeletionTimestamp has been set

func ObjectRevision added in v0.3.0

func ObjectRevision(obj metav1.Object) string

ObjectRevision returns the revision label of the resource.

func ParseModelServingFromRequest

func ParseModelServingFromRequest(r *http.Request) (*admissionv1.AdmissionReview, *workloadv1alpha1.ModelServing, error)

ParseAdmissionRequest parses the HTTP request and extracts the AdmissionReview and ModelServing.

func RemoveRoleReplicasForRevision

func RemoveRoleReplicasForRevision(ms *workloadv1alpha1.ModelServing) *workloadv1alpha1.ModelServing

RemoveRoleReplicasForRevision remove role.replicas when calculating modelServing revision hash

func Revision

func Revision(obj interface{}) string

Revision calculates the revision of an object using FNV hashing.

func RoleIDIndexFunc

func RoleIDIndexFunc(obj interface{}) ([]string, error)

func SendAdmissionResponse

func SendAdmissionResponse(w http.ResponseWriter, admissionReview *admissionv1.AdmissionReview) error

SendAdmissionResponse sends the AdmissionReview response back to the client

func SetCondition

func SetCondition(ms *workloadv1alpha1.ModelServing, progressingGroups, updatedGroups, currentGroups []int) bool

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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