util

package
v0.0.0-...-c099de4 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0, BSD-2-Clause, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Label keys
	RayClusterNameLabelKey            = "ray.io/cluster-name"
	RayClusterUserLabelKey            = "ray.io/user"
	RayClusterVersionLabelKey         = "ray.io/version"
	RayClusterEnvironmentLabelKey     = "ray.io/environment"
	KubernetesApplicationNameLabelKey = "app.kubernetes.io/name"
	KubernetesManagedByLabelKey       = "app.kubernetes.io/managed-by"

	// Annotation keys
	// Role level
	RayClusterComputeTemplateAnnotationKey = "ray.io/compute-template"
	RayClusterImageAnnotationKey           = "ray.io/compute-image"

	RayClusterDefaultImageRepository = "rayproject/ray"
)

TODO: this needs to be revised.

View Source
const (
	// The application name
	ApplicationName = "kuberay"

	// The component name for apiserver
	ComponentName = "kuberay-apiserver"
)
View Source
const (
	API_CODE_NOT_FOUND = 404
)

Variables

This section is empty.

Functions

func ExtractErrorForCLI

func ExtractErrorForCLI(err error, isDebugMode bool) error

func GetContainerByName

func GetContainerByName(containers []corev1.Container, name string) (corev1.Container, int, bool)

func GetNodeHostIP

func GetNodeHostIP(node *corev1.Node) (net.IP, error)

GetNodeHostIP returns the provided node's IP, based on the priority: 1. NodeInternalIP 2. NodeExternalIP

func HasCustomCode

func HasCustomCode(err error, code CustomCode) bool

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns whether an error indicates that a resource was "not found".

func IsUserErrorCodeMatch

func IsUserErrorCodeMatch(err error, code codes.Code) bool

IsUserErrorCodeMatch returns whether the error is a user error with specified code.

func LogError

func LogError(err error)

func NewComputeTemplate

func NewComputeTemplate(runtime *api.ComputeTemplate) (*corev1.ConfigMap, error)

Build compute template

func ParseTimeOrFatal

func ParseTimeOrFatal(value string) time.Time

func TerminateIfError

func TerminateIfError(err error)

TerminateIfError Check if error is nil. Terminate if not.

func UpdateRayServiceWorkerGroupSpecs

func UpdateRayServiceWorkerGroupSpecs(updateSpecs []*api.WorkerGroupUpdateSpec, workerGroupSpecs []rayv1api.WorkerGroupSpec) []rayv1api.WorkerGroupSpec

func Wrap

func Wrap(err error, message string) error

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Types

type APICode

type APICode int

type ClientOptions

type ClientOptions struct {
	QPS   float32
	Burst int
}

ClientOptions contains configuration needed to create a Kubernetes client

type CustomCode

type CustomCode uint32
const (
	CUSTOM_CODE_TRANSIENT CustomCode = 0
	CUSTOM_CODE_PERMANENT CustomCode = 1
	CUSTOM_CODE_NOT_FOUND CustomCode = 2
	CUSTOM_CODE_GENERIC   CustomCode = 3
)

type CustomError

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

func NewCustomError

func NewCustomError(err error, code CustomCode, format string, a ...interface{}) *CustomError

func NewCustomErrorf

func NewCustomErrorf(code CustomCode, format string, a ...interface{}) *CustomError

func (*CustomError) Error

func (e *CustomError) Error() string

type FakeTime

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

func (*FakeTime) Now

func (f *FakeTime) Now() time.Time

type RayCluster

type RayCluster struct {
	*rayv1api.RayCluster
}

func NewRayCluster

func NewRayCluster(apiCluster *api.Cluster, computeTemplateMap map[string]*api.ComputeTemplate) (*RayCluster, error)

NewRayCluster creates a RayCluster. func NewRayCluster(apiCluster *api.Cluster, clusterRuntime *api.ClusterRuntime, computeRuntime *api.ComputeRuntime) *RayCluster {

func (*RayCluster) Get

func (c *RayCluster) Get() *rayv1api.RayCluster

Get converts this object to a rayv1api.Workflow.

func (*RayCluster) SetAnnotationsToAllTemplates

func (c *RayCluster) SetAnnotationsToAllTemplates(key string, value string)

SetAnnotations sets annotations on all templates in a RayCluster

type RayJob

type RayJob struct {
	*rayv1api.RayJob
}

func NewRayJob

func NewRayJob(apiJob *api.RayJob, computeTemplateMap map[string]*api.ComputeTemplate) (*RayJob, error)

NewRayJob creates a RayJob.

func (*RayJob) Get

func (j *RayJob) Get() *rayv1api.RayJob

type RayService

type RayService struct {
	*rayv1api.RayService
}

func NewRayService

func NewRayService(apiService *api.RayService, computeTemplateMap map[string]*api.ComputeTemplate) (*RayService, error)

func (*RayService) Get

func (s *RayService) Get() *rayv1api.RayService

type RealTime

type RealTime struct{}

func (*RealTime) Now

func (r *RealTime) Now() time.Time

type TimeInterface

type TimeInterface interface {
	Now() time.Time
}

func NewFakeTime

func NewFakeTime(now time.Time) TimeInterface

func NewFakeTimeForEpoch

func NewFakeTimeForEpoch() TimeInterface

func NewRealTime

func NewRealTime() TimeInterface

type UserError

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

func NewAlreadyExistError

func NewAlreadyExistError(messageFormat string, a ...interface{}) *UserError

func NewBadRequestError

func NewBadRequestError(err error, externalFormat string, a ...interface{}) *UserError

func NewInternalServerError

func NewInternalServerError(err error, internalMessageFormat string,
	a ...interface{},
) *UserError

func NewInvalidInputError

func NewInvalidInputError(messageFormat string, a ...interface{}) *UserError

func NewInvalidInputErrorWithDetails

func NewInvalidInputErrorWithDetails(err error, externalMessage string) *UserError

func NewNotFoundError

func NewNotFoundError(err error, externalMessageFormat string,
	a ...interface{},
) *UserError

func NewPermissionDeniedError

func NewPermissionDeniedError(err error, externalFormat string, a ...interface{}) *UserError

func NewResourceNotFoundError

func NewResourceNotFoundError(resourceType string, resourceName string) *UserError

func NewResourcesNotFoundError

func NewResourcesNotFoundError(resourceTypesFormat string, resourceNames ...interface{}) *UserError

func NewUnauthenticatedError

func NewUnauthenticatedError(err error, externalFormat string, a ...interface{}) *UserError

func NewUserError

func NewUserError(err error, internalMessage string, externalMessage string) *UserError

func NewUserErrorWithSingleMessage

func NewUserErrorWithSingleMessage(err error, message string) *UserError

func (*UserError) Cause

func (e *UserError) Cause() error

func (*UserError) Error

func (e *UserError) Error() string

func (*UserError) ErrorStringWithoutStackTrace

func (e *UserError) ErrorStringWithoutStackTrace() string

func (*UserError) ExternalMessage

func (e *UserError) ExternalMessage() string

func (*UserError) ExternalStatusCode

func (e *UserError) ExternalStatusCode() codes.Code

func (*UserError) GRPCStatus

func (e *UserError) GRPCStatus() *status.Status

GRPCStatus implements `GRPCStatus` to make sure `FromError` in grpc-go can honor the code. Otherwise, it will always return codes.Unknown(2). https://github.com/grpc/grpc-go/blob/2c0949c22d46095edc579d9e66edcd025192b98c/status/status.go#L91-L92

func (*UserError) Log

func (e *UserError) Log()

func (*UserError) String

func (e *UserError) String() string

Jump to

Keyboard shortcuts

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