handlers

package
v0.0.0-...-14354aa Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: Apache-2.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodesourceConfigMapName     = "kubedl-codesource-config"
	CodesourceConfigMapKey      = "codesource"
	CodesourceSecretGitUsername = "git_username"
	CodesourceSecretGitPassword = "git_password"
)
View Source
const (
	ResourceGPU   = "nvidia.com/gpu"
	IndexNodeName = "spec.nodeName"
	IndexPhase    = "status.phase"
	GPUType       = "aliyun.accelerator/nvidia_name"
)
View Source
const (
	DatasourceConfigMapName = "kubedl-datasource-config"
	DatasourceConfigMapKey  = "datasource"
)
View Source
const (
	Notebook_Type_Jupyter = "Jupyter"
	Notebook_Type_VSCOde  = "VSCode"

	Notebook_Type_Label = "notebook-type"
)
View Source
const (
	Day = 24 * time.Hour
)

Variables

This section is empty.

Functions

func GetArmsInfo

func GetArmsInfo() (model.ArmsInfo, error)

get arms config for query data

func GetNotebookResource

func GetNotebookResource(data NotebookSubmitData) (*v1.Notebook, error)

Types

type CodeSourceHandler

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

func NewCodeSourceHandler

func NewCodeSourceHandler() *CodeSourceHandler

func (*CodeSourceHandler) DeleteCodeSourceFromConfigMap

func (ov *CodeSourceHandler) DeleteCodeSourceFromConfigMap(userName, name string) error

delete

func (*CodeSourceHandler) GetCodeSourceFromConfigMap

func (ov *CodeSourceHandler) GetCodeSourceFromConfigMap(userName, name string) (model.CodeSource, error)

get

func (*CodeSourceHandler) ListCodeSourceFromConfigMap

func (ov *CodeSourceHandler) ListCodeSourceFromConfigMap(userName string) (model.CodeSourceMap, error)

get all

func (*CodeSourceHandler) PostCodeSourceToConfigMap

func (ov *CodeSourceHandler) PostCodeSourceToConfigMap(userName string, codeSource model.CodeSource) error

post

func (*CodeSourceHandler) PutCodeSourceToConfigMap

func (ov *CodeSourceHandler) PutCodeSourceToConfigMap(userName string, codeSource model.CodeSource) error

put

type CompareData

type CompareData struct {
	Names      []string                 `json:"names"`
	Namespaces []string                 `json:"namespaces"`
	Metrics    map[string][]interface{} `json:"metrics"`
}

type ConditionsSorted

type ConditionsSorted []corev1.PodCondition

func (ConditionsSorted) Len

func (c ConditionsSorted) Len() int

func (ConditionsSorted) Less

func (c ConditionsSorted) Less(i, j int) bool

func (ConditionsSorted) Swap

func (c ConditionsSorted) Swap(i, j int)

type CronHandler

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

func NewCronHandler

func NewCronHandler(objStorage string, clientTypeName string) (*CronHandler, error)

func (*CronHandler) DeleteCron

func (cj *CronHandler) DeleteCron(userName, namespace, name string) error

func (*CronHandler) GetCron

func (cj *CronHandler) GetCron(userName, namespace, name string) (model.CronInfo, error)

func (*CronHandler) ListCron

func (cj *CronHandler) ListCron(query *backends.CronQuery) ([]model.CronInfo, error)

func (*CronHandler) ListCronHistory

func (cj *CronHandler) ListCronHistory(userName, namespace, name, jobName, jobStatus string) ([]model.JobInfo, error)

func (*CronHandler) ResumeCron

func (cj *CronHandler) ResumeCron(userName, namespace, name string) error

func (*CronHandler) StopCron

func (cj *CronHandler) StopCron(userName, namespace, name string) error

func (*CronHandler) SuspendCron

func (cj *CronHandler) SuspendCron(userName, namespace, name string) error

type DLCCommonConfig

type DLCCommonConfig struct {
	Namespace        string   `json:"namespace"`
	TFCpuImages      []string `json:"default-tf-cpu-images"`
	TFGpuImages      []string `json:"default-tf-gpu-images"`
	PytorchGpuImages []string `json:"default-pytorch-gpu-images"`
	ClusterID        string   `json:"clusterId,omitempty"`
	Version          string   `json:"version,omitempty"`
}

type DLCHandler

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

func NewDLCHandler

func NewDLCHandler() *DLCHandler

func (*DLCHandler) DetectJobsInNS

func (h *DLCHandler) DetectJobsInNS(userName, ns, kind string) bool

func (*DLCHandler) GetDLCConfig

func (h *DLCHandler) GetDLCConfig() (*DLCCommonConfig, error)

func (*DLCHandler) ListAvailableNamespaces

func (h *DLCHandler) ListAvailableNamespaces(userName string) ([]string, error)

type DataHandler

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

func NewDataHandler

func NewDataHandler() *DataHandler

func (*DataHandler) GetClusterNodeInfos

func (ov *DataHandler) GetClusterNodeInfos(searchParam string) (model.ClusterNodeInfoList, error)

sum all pods allocatable and request resource(cpu/memory/gpu) in a node

func (*DataHandler) GetClusterRequestResource

func (ov *DataHandler) GetClusterRequestResource(podPhase string) (model.ClusterRequestResource, error)

sum all pods request resource(cpu/memory/gpu)

func (*DataHandler) GetClusterTotalResource

func (ov *DataHandler) GetClusterTotalResource() (model.ClusterTotalResource, error)

sum all nodes allocatable resource(cpu/memory/gpu)

func (*DataHandler) QueryRange

func (ov *DataHandler) QueryRange(query, start, end, step string) (prommodel.Value, error)

query data from prometheus(arms) prometheus Range Vector Selectors https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries

type DataSourceHandler

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

func NewDataSourceHandler

func NewDataSourceHandler() *DataSourceHandler

func (*DataSourceHandler) DeleteDataSourceFromConfigMap

func (ov *DataSourceHandler) DeleteDataSourceFromConfigMap(userName string, name string) error

delete

func (*DataSourceHandler) GetDataSourceFromConfigMap

func (ov *DataSourceHandler) GetDataSourceFromConfigMap(userName string, name string) (model.DataSource, error)

get

func (*DataSourceHandler) ListDataSourceFromConfigMap

func (ov *DataSourceHandler) ListDataSourceFromConfigMap(userName string) (model.DataSourceMap, error)

get all

func (*DataSourceHandler) PostDataSourceToConfigMap

func (ov *DataSourceHandler) PostDataSourceToConfigMap(userName string, dataSource model.DataSource) error

post

func (*DataSourceHandler) PutDataSourceToConfigMap

func (ov *DataSourceHandler) PutDataSourceToConfigMap(userName string, dataSource model.DataSource) error

put

type EvaluateHandler

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

func NewEvaluateHandler

func NewEvaluateHandler(objStorage string, clientTypeName string) (*EvaluateHandler, error)

func (*EvaluateHandler) CompareEvaluateJobs

func (eh *EvaluateHandler) CompareEvaluateJobs(array SearchArray) (CompareData, error)

func (*EvaluateHandler) DeleteEvaluateJobFromCluster

func (eh *EvaluateHandler) DeleteEvaluateJobFromCluster(userName, ns, name string) error

func (*EvaluateHandler) GetEvaluateJobData

func (eh *EvaluateHandler) GetEvaluateJobData(ns, name, jobID string) (*model.EvaluateJobInfo, error)

func (*EvaluateHandler) ListEvaluateJobsFromBackend

func (eh *EvaluateHandler) ListEvaluateJobsFromBackend(query *backends.EvaluateJobQuery) ([]model.EvaluateJobInfo, error)

func (*EvaluateHandler) SubmitEvaluateJob

func (eh *EvaluateHandler) SubmitEvaluateJob(userName string, data []byte) error

type JobHandler

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

func NewJobHandler

func NewJobHandler(objStorage, clientTypeName string, logHandler *LogHandler) (*JobHandler, error)

func (*JobHandler) DeleteJobFromStorage

func (jh *JobHandler) DeleteJobFromStorage(userName, ns, name, jobID, kind, region string) error

func (*JobHandler) GetDetailedJobFromBackend

func (jh *JobHandler) GetDetailedJobFromBackend(userName, ns, name, jobID, kind, region string) (model.JobInfo, error)

func (*JobHandler) GetJobFromBackend

func (jh *JobHandler) GetJobFromBackend(userName, ns, jobId, jobName, kind, region string) (model.JobInfo, error)

func (*JobHandler) GetJobJsonData

func (jh *JobHandler) GetJobJsonData(userName, ns, name, kind string) ([]byte, error)

func (*JobHandler) GetJobStatisticsFromBackend

func (jh *JobHandler) GetJobStatisticsFromBackend(query *backends.Query) (model.JobStatistics, error)

func (*JobHandler) GetJobYamlData

func (jh *JobHandler) GetJobYamlData(userId, ns, name, kind string) ([]byte, error)

func (*JobHandler) GetRunningJobsFromBackend

func (jh *JobHandler) GetRunningJobsFromBackend(query *backends.Query) ([]model.JobInfo, error)

func (*JobHandler) ListJobsFromBackend

func (jh *JobHandler) ListJobsFromBackend(query *backends.Query) ([]model.JobInfo, error)

func (*JobHandler) ListPVC

func (jh *JobHandler) ListPVC(ns string) ([]string, error)

func (*JobHandler) StopJob

func (jh *JobHandler) StopJob(userName, ns, name, jobID, kind, region string) error

func (*JobHandler) SubmitJob

func (jh *JobHandler) SubmitJob(userName string, jobInfo *dmo.SubmitJobInfo) error

func (*JobHandler) SubmitJobWithKind

func (jh *JobHandler) SubmitJobWithKind(userName string, data []byte, kind string) error

type KubeAuthInfo

type KubeAuthInfo struct {
	User clientcmdapi.AuthInfo `json:"user"`
	Name string                `json:"name"`
}

type KubeCluster

type KubeCluster struct {
	Cluster clientcmdapi.Cluster `json:"cluster"`
	Name    string               `json:"name"`
}

type KubeConfig

type KubeConfig struct {
	Kind           string                   `json:"kind,omitempty"`
	APIVersion     string                   `json:"apiVersion,omitempty"`
	Preferences    clientcmdapi.Preferences `json:"preferences"`
	Clusters       []KubeCluster            `json:"clusters"`
	AuthInfos      []KubeAuthInfo           `json:"users"`
	Contexts       []KubeContext            `json:"contexts"`
	CurrentContext string                   `json:"current-context"`
}

type KubeContext

type KubeContext struct {
	Context clientcmdapi.Context `json:"context"`
	Name    string               `json:"name"`
}

type LogHandler

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

func NewLogHandler

func NewLogHandler(eventStorage string) (*LogHandler, error)

func (*LogHandler) DownloadLogs

func (lh *LogHandler) DownloadLogs(namespace, jobKind, jobName, podName, userName string, from, to time.Time) ([]byte, error)

func (*LogHandler) GetEvents

func (lh *LogHandler) GetEvents(namespace, objName, userId string, from, to time.Time) ([]string, error)

func (*LogHandler) GetLogs

func (lh *LogHandler) GetLogs(namespace, jobKind, jobName, podName, userName string, from, to time.Time) ([]string, error)

type MetricsItem

type MetricsItem struct {
	SearchItem
	Metrics map[string]interface{} `json:"metrics"`
}

type ModelsHandler

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

func NewModelsHandler

func NewModelsHandler(objStorage string) (*ModelsHandler, error)

func (*ModelsHandler) CreateModel

func (mh *ModelsHandler) CreateModel(data []byte) error

func (*ModelsHandler) DeleteModel

func (mh *ModelsHandler) DeleteModel(modelID string) error

func (*ModelsHandler) GetModelDetails

func (mh *ModelsHandler) GetModelDetails(modelID string) (dmo.Model, error)

func (*ModelsHandler) GetModelsList

func (mh *ModelsHandler) GetModelsList(query *backends.ModelsQuery) ([]dmo.Model, error)

type NotebookHandler

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

func NewNotebookHandler

func NewNotebookHandler(objStorage string) (*NotebookHandler, error)

func (*NotebookHandler) CompatibleNotebook

func (nh *NotebookHandler) CompatibleNotebook(namespace string) error

func (*NotebookHandler) DeleteNotebook

func (nh *NotebookHandler) DeleteNotebook(name, namespace string) error

func (*NotebookHandler) GetMaxGpuNumbers

func (nh *NotebookHandler) GetMaxGpuNumbers() (int64, error)

func (*NotebookHandler) GetNotebookPodConnection

func (nh *NotebookHandler) GetNotebookPodConnection(namespace, name string) (string, error)

func (*NotebookHandler) GetNotebookServiceConnection

func (nh *NotebookHandler) GetNotebookServiceConnection(namespace, name string) (string, error)

func (*NotebookHandler) ListEvents

func (nh *NotebookHandler) ListEvents(namespace string) (map[string]string, error)

func (*NotebookHandler) ListNotebook

func (nh *NotebookHandler) ListNotebook(namespace string) ([]NotebookMessage, error)

func (*NotebookHandler) ListNotebookFromStorage

func (nh *NotebookHandler) ListNotebookFromStorage(namespace, userName, userId string, c *gin.Context) ([]NotebookMessage, error)

func (*NotebookHandler) ListPVC

func (nh *NotebookHandler) ListPVC(ns string) ([]PVCObject, error)

func (*NotebookHandler) ListSVC

func (nh *NotebookHandler) ListSVC(ns string) (map[string]string, error)

func (*NotebookHandler) PersistentVolumeClaimFilter

func (nh *NotebookHandler) PersistentVolumeClaimFilter(list corev1.PersistentVolumeClaimList, namespace string) []PVCObject

func (*NotebookHandler) SubmitNotebookByData

func (nh *NotebookHandler) SubmitNotebookByData(data NotebookSubmitData) error

func (*NotebookHandler) SyncNotebook

func (nh *NotebookHandler) SyncNotebook(notebook *v1.Notebook) error

type NotebookMessage

type NotebookMessage struct {
	Name       string   `json:"name"`
	Namespace  string   `json:"namespace"`
	Image      string   `json:"image"`
	Volumes    []string `json:"volumes"`
	Age        string   `json:"age"`
	AccessPath string   `json:"accessPath"`
	Cpus       string   `json:"cpus"`
	Gpus       string   `json:"gpus"`
	Memory     string   `json:"memory"`
	Status     string   `json:"status"`
	Event      string   `json:"event"`
	Token      string   `json:"token"`
	ErrMessage string   `json:"errMessage"`
	UserName   string   `json:"userName"`
}

type NotebookMessages

type NotebookMessages []NotebookMessage

func (NotebookMessages) Len

func (nb NotebookMessages) Len() int

func (NotebookMessages) Less

func (nb NotebookMessages) Less(i, j int) bool

func (NotebookMessages) Swap

func (nb NotebookMessages) Swap(i, j int)

type NotebookStatus

type NotebookStatus string
const (
	Running  NotebookStatus = "Running"
	Stopped  NotebookStatus = "Stopped"
	Deleted  NotebookStatus = "Deleted"
	Starting NotebookStatus = "Starting"
)

type NotebookSubmitData

type NotebookSubmitData struct {
	Name             string                        `json:"name"`
	Namespace        string                        `json:"namespace"`
	Image            string                        `json:"image"`
	Volumes          []VolumeData                  `json:"volumes"`
	ImagePullPolicy  string                        `json:"imagePullPolicy"`
	Cpus             string                        `json:"cpus"`
	Gpus             string                        `json:"gpus"`
	Memory           string                        `json:"memory"`
	UserId           string                        `json:"userId"`
	UserName         string                        `json:"userName"`
	Token            string                        `json:"token"`
	NotebookType     string                        `json:"NotebookType"`
	ImagePullSecrets []string                      `json:"imagePullSecrets"`
	NodeSelectors    map[string]string             `json:"nodeSelectors"`
	Annotations      map[string]string             `json:"annotations"`
	Labels           map[string]string             `json:"labels"`
	Tolerates        map[string]dmo.TolerationData `json:"tolerates"`
}

type PVCObject

type PVCObject struct {
	Name    string `json:"name"`
	Isbound bool   `json:"isBound"`
}

type SearchArray

type SearchArray []SearchItem

type SearchItem

type SearchItem struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	ID        string `json:"id"`
}

type SecretHandler

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

func NewSecretHandler

func NewSecretHandler() *SecretHandler

type VolumeData

type VolumeData struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

Jump to

Keyboard shortcuts

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