models

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultClusterSource = "OnPremise"
	ClusterStatusOnLine  = "online"
	ClusterStatusOffLine = "offline"
	DefaultClusterStatus = ClusterStatusOnLine
)
View Source
const (
	CreatedAt   = "created_at"
	UpdatedAt   = "updated_at"
	Type        = "type"
	ID          = "id"
	FsID        = "fs_id"
	UserName    = "user_name"
	FsName      = "name"
	GrantFsType = "fs"

	TimeFormat = "2006-01-02 15:04:05"
)
View Source
const (
	ConcurrencyPolicySuspend = "suspend"
	ConcurrencyPolicyReplace = "replace"
	ConcurrencyPolicySkip    = "skip"

	ScheduleStatusSuccess    = "success"
	ScheduleStatusRunning    = "running"
	ScheduleStatusFailed     = "failed"
	ScheduleStatusTerminated = "terminated"
)
View Source
const (
	JobTaskTableName = "job_task"
)

Variables

View Source
var ScheduleNotFinalStatusList = []string{
	ScheduleStatusRunning,
}

Functions

func CloseQueue

func CloseQueue(queueName string) error

func CountActiveRunsForSchedule added in v0.14.3

func CountActiveRunsForSchedule(logEntry *log.Entry, scheduleID string) (int64, error)

func CountArtifactEvent

func CountArtifactEvent(logEntry *log.Entry, fsID, artifactPath string) (int64, error)

func CountPipelineVersion added in v0.14.3

func CountPipelineVersion(pipelineID string) (int64, error)

func CountRun added in v0.14.3

func CountRun(logEntry *log.Entry, pk int64, maxKeys int, userFilter, fsFilter, runFilter, nameFilter, statusFilter, scheduleIdFilter []string) (count int64, err error)

func CreateArtifactEvent

func CreateArtifactEvent(logEntry *log.Entry, artifact ArtifactEvent) error

func CreateCluster

func CreateCluster(clusterInfo *ClusterInfo) error

func CreateFlavour

func CreateFlavour(flavour *Flavour) error

CreateFlavour create flavour

func CreateImage

func CreateImage(logEntry *log.Entry, image *Image) error

func CreateJob

func CreateJob(job *Job) error

CreateJob creates a new job

func CreateOrUpdateQueue added in v0.14.3

func CreateOrUpdateQueue(queue *Queue) error

func CreatePipeline

func CreatePipeline(logEntry *log.Entry, ppl *Pipeline, pplVersion *PipelineVersion) (pplID string, pplVersionID string, err error)

func CreateQueue

func CreateQueue(queue *Queue) error

func CreateRun

func CreateRun(logEntry *log.Entry, run *Run) (string, error)

func CreateRunCache

func CreateRunCache(logEntry *log.Entry, cache *RunCache) (string, error)

func CreateRunDag added in v0.14.3

func CreateRunDag(logEntry *log.Entry, runDag *RunDag) (int64, error)

func CreateRunJob added in v0.14.3

func CreateRunJob(logEntry *log.Entry, runJob *RunJob) (int64, error)

func CreateSchedule added in v0.14.3

func CreateSchedule(logEntry *log.Entry, schedule Schedule) (scheduleID string, err error)

func DeepCopyQueue

func DeepCopyQueue(queueSrc Queue, queueDesc *Queue)

DeepCopyQueue returns a deep copy of the queue

func DeleteArtifactEvent

func DeleteArtifactEvent(logEntry *log.Entry, username, fsname, runID, artifactPath string) error

func DeleteCluster

func DeleteCluster(clusterName string) error

func DeleteFlavour

func DeleteFlavour(flavourName string) error

DeleteFlavour delete flavour

func DeleteJob

func DeleteJob(jobID string) error

func DeletePipeline added in v0.14.3

func DeletePipeline(logEntry *log.Entry, id string) error

func DeletePipelineVersion added in v0.14.3

func DeletePipelineVersion(logEntry *log.Entry, pipelineID string, pipelineVersionID string) error

func DeleteQueue

func DeleteQueue(queueName string) error

func DeleteRun

func DeleteRun(logEntry *log.Entry, runID string) error

func DeleteRunCache

func DeleteRunCache(logEntry *log.Entry, cacheID string) error

func DeleteSchedule added in v0.14.3

func DeleteSchedule(logEntry *log.Entry, scheduleID string) error

func GetCacheCount

func GetCacheCount(logEntry *log.Entry, runID string) (int64, error)

func GetJobStatusByID

func GetJobStatusByID(jobID string) (schema.JobStatus, error)

func GetNextGlobalWakeupTime added in v0.14.3

func GetNextGlobalWakeupTime(logEntry *log.Entry) (*time.Time, error)

计算timeout先不加事务,虽然select和 CountActiveRunsForSchedule 是非原子性,因为只影响休眠时间的计算结果

func GetUrlByPFImageID

func GetUrlByPFImageID(logEntry *log.Entry, PFImageID string) (string, error)

func IsLastPipelinePk added in v0.14.3

func IsLastPipelinePk(logEntry *log.Entry, pk int64, userFilter, nameFilter []string) (bool, error)

func IsLastPipelineVersionPk added in v0.14.3

func IsLastPipelineVersionPk(logEntry *log.Entry, pipelineID string, pk int64, fsFilter []string) (bool, error)

func IsLastSchedulePk added in v0.14.3

func IsLastSchedulePk(logEntry *log.Entry, pk int64, pplFilter, pplVersionFilter, userFilter, scheduleFilter, nameFilter, statusFilter []string) (bool, error)

func IsQueueExist

func IsQueueExist(queueName string) bool

func IsQueueInUse

func IsQueueInUse(queueID string) (bool, map[string]schema.JobStatus)

func IsScheduleFinalStatus added in v0.14.3

func IsScheduleFinalStatus(status string) bool

func ListImageIDsByFsID

func ListImageIDsByFsID(logEntry *log.Entry, fsID string) ([]string, error)

func ListJobIDByLabels

func ListJobIDByLabels(labels map[string]string) ([]string, error)

list job process multi label get and result

func ScheduleUsedFsIDs added in v0.14.3

func ScheduleUsedFsIDs() (map[string]bool, error)

func UpdateArtifactEvent

func UpdateArtifactEvent(logEntry *log.Entry, fsID, artifactPath string, artifact ArtifactEvent) error

func UpdateCache

func UpdateCache(logEntry *log.Entry, cacheID string, cache RunCache) error

func UpdateCluster

func UpdateCluster(clusterId string, clusterInfo *ClusterInfo) error

func UpdateFlavour

func UpdateFlavour(flavour *Flavour) error

UpdateFlavour update flavour

func UpdateImage

func UpdateImage(logEntry *log.Entry, PFImageID string, image Image) error

func UpdateJob

func UpdateJob(jobID string, status schema.JobStatus, runtimeInfo, runtimeStatus interface{}, message string) (schema.JobStatus, error)

func UpdateJobConfig

func UpdateJobConfig(jobId string, conf *schema.Conf) error

func UpdateJobStatus

func UpdateJobStatus(jobId, errMessage string, newStatus schema.JobStatus) error

func UpdatePipeline added in v0.14.3

func UpdatePipeline(logEntry *log.Entry, ppl *Pipeline, pplVersion *PipelineVersion) (pplID string, pplVersionID string, err error)

func UpdateQueue

func UpdateQueue(queue *Queue) error

func UpdateQueueInfo added in v0.14.3

func UpdateQueueInfo(name, status string, max, min *resources.Resource) error

func UpdateQueueStatus

func UpdateQueueStatus(queueName string, queueStatus string) error

func UpdateRun

func UpdateRun(logEntry *log.Entry, runID string, run Run) error

func UpdateRunDag added in v0.14.3

func UpdateRunDag(logEntry *log.Entry, pk int64, runDag RunDag) error

func UpdateRunJob

func UpdateRunJob(logEntry *log.Entry, pk int64, runJob RunJob) error

func UpdateRunStatus

func UpdateRunStatus(logEntry *log.Entry, runID, status string) error

func UpdateScheduleStatus added in v0.14.3

func UpdateScheduleStatus(logEntry *log.Entry, scheduleID, status string) error

func UpdateTask

func UpdateTask(task *JobTask) error

func WithTransaction added in v0.14.3

func WithTransaction(tdb *gorm.DB, fn Transaction) (err error)

Types

type ArtifactEvent

type ArtifactEvent struct {
	Pk           int64          `json:"-"                    gorm:"primaryKey;autoIncrement;not null"`
	Md5          string         `json:"-"                    gorm:"type:varchar(32);not null"`
	RunID        string         `json:"runID"                gorm:"type:varchar(60);not null"`
	FsID         string         `json:"-"                    gorm:"type:varchar(60);not null"`
	FsName       string         `json:"fsname"               gorm:"type:varchar(60);not null"`
	UserName     string         `json:"username"             gorm:"type:varchar(60);not null"`
	ArtifactPath string         `json:"artifactPath"         gorm:"type:varchar(256);not null"`
	Step         string         `json:"step"                 gorm:"type:varchar(256);not null"`
	JobID        string         `json:"jobID"                gorm:"type:varchar(60);not null"`
	Type         string         `json:"type"                 gorm:"type:varchar(16);not null"`
	ArtifactName string         `json:"artifactName"         gorm:"type:varchar(32);not null"`
	Meta         string         `json:"meta"                 gorm:"type:text;size:65535"`
	CreateTime   string         `json:"createTime"           gorm:"-"`
	UpdateTime   string         `json:"updateTime,omitempty" gorm:"-"`
	CreatedAt    time.Time      `json:"-"`
	UpdatedAt    time.Time      `json:"-"`
	DeletedAt    gorm.DeletedAt `json:"-"                    gorm:"index"`
}

func GetArtifactEvent

func GetArtifactEvent(logEntry *log.Entry, runID, fsID, artifactPath string) (ArtifactEvent, error)

func GetLastArtifactEvent

func GetLastArtifactEvent(logEntry *log.Entry) (ArtifactEvent, error)

func ListArtifactEvent

func ListArtifactEvent(logEntry *log.Entry, pk int64, maxKeys int, userFilter, fsFilter, runFilter, typeFilter, pathFilter []string) ([]ArtifactEvent, error)

func (ArtifactEvent) TableName

func (ArtifactEvent) TableName() string

type ClusterInfo

type ClusterInfo struct {
	Model            `gorm:"embedded"  json:",inline"`
	Pk               int64    `gorm:"primaryKey;autoIncrement" json:"-"`      // 自增主键
	Name             string   `gorm:"column:name" json:"clusterName"`         // 集群名字
	Description      string   `gorm:"column:description" json:"description"`  // 集群描述
	Endpoint         string   `gorm:"column:endpoint" json:"endpoint"`        // 集群endpoint, 比如 http://10.11.11.47:8080
	Source           string   `gorm:"column:source" json:"source"`            // 来源, 比如 OnPremise (内部部署)、AWS、CCE
	ClusterType      string   `gorm:"column:cluster_type" json:"clusterType"` // 集群类型,比如Kubernetes/Local
	Version          string   `gorm:"column:version" json:"version"`          // 集群版本,比如v1.16
	Status           string   `gorm:"column:status" json:"status"`            // 集群状态,可选值为online, offline
	Credential       string   `gorm:"column:credential" json:"credential"`    // 用于存储集群的凭证信息,比如k8s的kube_config配置
	Setting          string   `gorm:"column:setting" json:"setting"`          // 存储额外配置信息
	RawNamespaceList string   `gorm:"column:namespace_list" json:"-"`         // 命名空间列表,json类型,如["ns1", "ns2"]
	NamespaceList    []string `gorm:"-" json:"namespaceList"`                 // 命名空间列表,json类型,如["ns1", "ns2"]
	DeletedAt        string   `gorm:"column:deleted_at" json:"-"`             // 删除标识,非空表示软删除
}

func ActiveClusters

func ActiveClusters() []ClusterInfo

func GetClusterById

func GetClusterById(clusterId string) (ClusterInfo, error)

func GetClusterByName

func GetClusterByName(clusterName string) (ClusterInfo, error)

func GetLastCluster

func GetLastCluster() (ClusterInfo, error)

func ListCluster

func ListCluster(pk int64, maxKeys int, clusterNameList []string, clusterStatus string) ([]ClusterInfo, error)

func (*ClusterInfo) AfterFind

func (clusterInfo *ClusterInfo) AfterFind(*gorm.DB) error

func (*ClusterInfo) BeforeSave

func (clusterInfo *ClusterInfo) BeforeSave(*gorm.DB) error

func (ClusterInfo) MarshalJSON

func (clusterInfo ClusterInfo) MarshalJSON() ([]byte, error)

func (ClusterInfo) TableName

func (ClusterInfo) TableName() string

type Flavour

type Flavour struct {
	Model              `gorm:"embedded"  json:",inline"`
	Pk                 int64                      `json:"-"           gorm:"primaryKey;autoIncrement"`
	Name               string                     `json:"name"        gorm:"uniqueIndex"`
	ClusterID          string                     `json:"-"   gorm:"column:cluster_id;default:''"`
	ClusterName        string                     `json:"-" gorm:"column:cluster_name;->"`
	CPU                string                     `json:"cpu"         gorm:"column:cpu"`
	Mem                string                     `json:"mem"         gorm:"column:mem"`
	RawScalarResources string                     `json:"-"           gorm:"column:scalar_resources;type:text;default:'{}'"`
	ScalarResources    schema.ScalarResourcesType `json:"scalarResources" gorm:"-"`
	UserName           string                     `json:"-" gorm:"column:user_name"`
	DeletedAt          gorm.DeletedAt             `json:"-" gorm:"index"`
}

Flavour records request resource info for each job

func GetFlavour

func GetFlavour(flavourName string) (Flavour, error)

GetFlavour get flavour

func GetLastFlavour

func GetLastFlavour() (Flavour, error)

GetLastFlavour get last flavour that usually be used for indicating last page

func ListFlavour

func ListFlavour(pk int64, maxKeys int, clusterID, queryKey string) ([]Flavour, error)

ListFlavour all params is nullable, and support fuzzy query of flavour's name by queryKey

func (*Flavour) AfterFind

func (flavour *Flavour) AfterFind(*gorm.DB) error

AfterFind triggered when query sql

func (*Flavour) BeforeSave

func (flavour *Flavour) BeforeSave(*gorm.DB) error

BeforeSave is the callback methods for saving flavour

func (Flavour) MarshalJSON

func (flavour Flavour) MarshalJSON() ([]byte, error)

MarshalJSON decorate format of time

func (Flavour) TableName

func (Flavour) TableName() string

TableName indicate table name of Flavour

type FsConfig added in v0.14.3

type FsConfig struct {
	Username string `json:"username"`
}

func DecodeFsConfig added in v0.14.3

func DecodeFsConfig(strConfig string) (fc FsConfig, err error)

func (*FsConfig) Encode added in v0.14.3

func (fc *FsConfig) Encode(logEntry *log.Entry) (string, error)

type Image

type Image struct {
	Pk        int64          `json:"-"         gorm:"primaryKey;autoIncrement;not null"`
	ID        string         `json:"PFImageID" gorm:"type:varchar(128);not null;uniqueIndex"`
	ImageID   string         `json:"imageID"   gorm:"type:varchar(64)"`
	FsID      string         `json:"fsID"      gorm:"type:varchar(60);not null"`
	Source    string         `json:"source"    gorm:"type:varchar(256);not null"`
	Url       string         `json:"url"       gorm:"type:varchar(256)"`
	CreatedAt time.Time      `json:"-"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `json:"-"         gorm:"index"`
}

func GetImage

func GetImage(logEntry *log.Entry, PFImageID string) (Image, error)

func (Image) TableName

func (Image) TableName() string

type Job

type Job struct {
	Pk                int64               `json:"-" gorm:"primaryKey;autoIncrement"`
	ID                string              `json:"jobID" gorm:"type:varchar(60);index:idx_id,unique;NOT NULL"`
	Name              string              `json:"jobName" gorm:"type:varchar(512);default:''"`
	UserName          string              `json:"userName" gorm:"NOT NULL"`
	QueueID           string              `json:"queueID" gorm:"NOT NULL"`
	Type              string              `json:"type" gorm:"type:varchar(20);NOT NULL"`
	ConfigJson        string              `json:"-" gorm:"column:config;type:text"`
	Config            *schema.Conf        `json:"config" gorm:"-"`
	RuntimeInfoJson   string              `json:"-" gorm:"column:runtime_info;default:'{}'"`
	RuntimeInfo       interface{}         `json:"runtimeInfo" gorm:"-"`
	RuntimeStatusJson string              `json:"-" gorm:"column:runtime_status;default:'{}'"`
	RuntimeStatus     interface{}         `json:"runtimeStatus" gorm:"-"`
	Status            schema.JobStatus    `json:"status" gorm:"type:varchar(32);"`
	Message           string              `json:"message"`
	ResourceJson      string              `json:"-" gorm:"column:resource;type:text;default:'{}'"`
	Resource          *resources.Resource `json:"resource" gorm:"-"`
	Framework         schema.Framework    `json:"framework" gorm:"type:varchar(30)"`
	MembersJson       string              `json:"-" gorm:"column:members;type:text"`
	Members           []Member            `json:"members" gorm:"-"`
	ExtensionTemplate string              `json:"-" gorm:"type:text"`
	ParentJob         string              `json:"-" gorm:"type:varchar(60)"`
	CreatedAt         time.Time           `json:"createTime"`
	ActivatedAt       sql.NullTime        `json:"activateTime"`
	UpdatedAt         time.Time           `json:"updateTime,omitempty"`
	DeletedAt         string              `json:"-" gorm:"index:idx_id"`
}

func GetJobByID

func GetJobByID(jobID string) (Job, error)

func GetJobsByRunID

func GetJobsByRunID(runID string, jobID string) ([]Job, error)

func GetLastJob

func GetLastJob() (Job, error)

func GetUnscopedJobByID

func GetUnscopedJobByID(jobID string) (Job, error)

func ListClusterJob added in v0.14.3

func ListClusterJob(clusterID string, status schema.JobStatus) []Job

func ListJob

func ListJob(pk int64, maxKeys int, queue, status, startTime, timestamp, userFilter string, labels map[string]string) ([]Job, error)

func ListJobByParentID

func ListJobByParentID(parentID string) ([]Job, error)

func ListJobByStatus added in v0.14.3

func ListJobByStatus(status schema.JobStatus) []Job

func ListJobByUpdateTime

func ListJobByUpdateTime(updateTime string) ([]Job, error)

func ListQueueInitJob added in v0.14.3

func ListQueueInitJob(queueID string) []Job

func ListQueueJob

func ListQueueJob(queueID string, status []schema.JobStatus) []Job

func (*Job) AfterFind

func (job *Job) AfterFind(tx *gorm.DB) error

func (*Job) BeforeSave

func (job *Job) BeforeSave(tx *gorm.DB) error

func (Job) TableName

func (Job) TableName() string

type JobLabel

type JobLabel struct {
	Pk        int64  `gorm:"primaryKey;autoIncrement"`
	ID        string `gorm:"type:varchar(36);uniqueIndex"`
	Label     string `gorm:"type:varchar(255);NOT NULL"`
	JobID     string `gorm:"type:varchar(60);NOT NULL"`
	CreatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func (JobLabel) TableName

func (JobLabel) TableName() string

type JobTask

type JobTask struct {
	Pk                   int64             `json:"-" gorm:"primaryKey;autoIncrement"`
	ID                   string            `json:"id" gorm:"type:varchar(64);uniqueIndex"` // k8s:podID
	JobID                string            `json:"jobID" gorm:"type:varchar(60)"`
	Namespace            string            `json:"namespace" gorm:"type:varchar(64)"`
	Name                 string            `json:"name" gorm:"type:varchar(512)"`
	MemberRole           schema.MemberRole `json:"memberRole"`
	Status               schema.TaskStatus `json:"status"`
	Message              string            `json:"message"`
	LogURL               string            `json:"logURL"`
	ExtRuntimeStatusJSON string            `json:"extRuntimeStatus" gorm:"column:ext_runtime_status;default:'{}'"`
	ExtRuntimeStatus     interface{}       `json:"-" gorm:"-"` // k8s:v1.PodStatus
	NodeName             string            `json:"nodeName"`
	CreatedAt            time.Time         `json:"-"`
	StartedAt            sql.NullTime      `json:"-"`
	UpdatedAt            time.Time         `json:"-"`
	DeletedAt            sql.NullTime      `json:"-"`
}

func GetJobTaskByID

func GetJobTaskByID(id string) (JobTask, error)

func ListByJobID

func ListByJobID(jobID string) ([]JobTask, error)

func (*JobTask) AfterFind

func (task *JobTask) AfterFind(*gorm.DB) error

func (*JobTask) BeforeSave

func (task *JobTask) BeforeSave(*gorm.DB) error

func (JobTask) TableName

func (JobTask) TableName() string

type Member

type Member struct {
	ID          string            `json:"id"`
	Replicas    int               `json:"replicas"`
	Role        schema.MemberRole `json:"role"`
	schema.Conf `json:",inline"`
}

type Model

type Model struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(tx *gorm.DB) error

BeforeCreate the function do the operation before creating file system or link

type Pipeline

type Pipeline struct {
	Pk        int64          `json:"-"                    gorm:"primaryKey;autoIncrement;not null"`
	ID        string         `json:"pipelineID"           gorm:"type:varchar(60);not null;index"`
	Name      string         `json:"name"                 gorm:"type:varchar(60);not null;index:idx_fs_name"`
	Desc      string         `json:"desc"                 gorm:"type:varchar(256);not null"`
	UserName  string         `json:"username"             gorm:"type:varchar(60);not null;index:idx_fs_name"`
	CreatedAt time.Time      `json:"-"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `json:"-"`
}

func GetPipeline added in v0.14.3

func GetPipeline(name, userName string) (Pipeline, error)

func GetPipelineByID

func GetPipelineByID(id string) (Pipeline, error)

func ListPipeline

func ListPipeline(pk int64, maxKeys int, userFilter, nameFilter []string) ([]Pipeline, error)

func (Pipeline) TableName

func (Pipeline) TableName() string

type PipelineVersion added in v0.14.3

type PipelineVersion struct {
	Pk           int64          `json:"-"                    gorm:"primaryKey;autoIncrement;not null"`
	ID           string         `json:"pipelineVersionID"    gorm:"type:varchar(60);not null"`
	PipelineID   string         `json:"pipelineID"           gorm:"type:varchar(60);not null"`
	FsID         string         `json:"-"                    gorm:"type:varchar(60);not null"`
	FsName       string         `json:"fsName"               gorm:"type:varchar(60);not null"`
	YamlPath     string         `json:"yamlPath"             gorm:"type:text;size:65535;not null"`
	PipelineYaml string         `json:"pipelineYaml"         gorm:"type:text;size:65535;not null"`
	PipelineMd5  string         `json:"pipelineMd5"          gorm:"type:varchar(32);not null"`
	UserName     string         `json:"username"             gorm:"type:varchar(60);not null"`
	CreatedAt    time.Time      `json:"-"`
	UpdatedAt    time.Time      `json:"-"`
	DeletedAt    gorm.DeletedAt `json:"-"`
}

func GetLastPipelineVersion added in v0.14.3

func GetLastPipelineVersion(pipelineID string) (PipelineVersion, error)

func GetPipelineVersion added in v0.14.3

func GetPipelineVersion(pipelineID string, pipelineVersionID string) (PipelineVersion, error)

func GetPipelineVersions added in v0.14.3

func GetPipelineVersions(pipelineID string) ([]PipelineVersion, error)

func ListPipelineVersion added in v0.14.3

func ListPipelineVersion(pipelineID string, pk int64, maxKeys int, fsFilter []string) ([]PipelineVersion, error)

func (PipelineVersion) TableName added in v0.14.3

func (PipelineVersion) TableName() string

type Queue

type Queue struct {
	Model           `gorm:"embedded"`
	Pk              int64               `json:"-" gorm:"primaryKey;autoIncrement"`
	Name            string              `json:"name" gorm:"uniqueIndex"`
	Namespace       string              `json:"namespace" gorm:"column:"`
	ClusterId       string              `json:"-" gorm:"column:cluster_id"`
	ClusterName     string              `json:"clusterName" gorm:"column:cluster_name;->"`
	QuotaType       string              `json:"quotaType"`
	RawMinResources string              `json:"-" gorm:"column:min_resources;default:'{}'"`
	MinResources    *resources.Resource `json:"minResources" gorm:"-"`
	RawMaxResources string              `json:"-" gorm:"column:max_resources;default:'{}'"`
	MaxResources    *resources.Resource `json:"maxResources" gorm:"-"`
	RawLocation     string              `json:"-" gorm:"column:location;type:text;default:'{}'"`
	Location        map[string]string   `json:"location" gorm:"-"`
	// 任务调度策略
	RawSchedulingPolicy string         `json:"-" gorm:"column:scheduling_policy"`
	SchedulingPolicy    []string       `json:"schedulingPolicy,omitempty" gorm:"-"`
	Status              string         `json:"status"`
	DeletedAt           gorm.DeletedAt `json:"-" gorm:"index"`

	UsedResources *resources.Resource `json:"usedResources,omitempty" gorm:"-"`
	IdleResources *resources.Resource `json:"idleResources,omitempty" gorm:"-"`
}

func GetLastQueue

func GetLastQueue() (Queue, error)

func GetQueueByID

func GetQueueByID(queueID string) (Queue, error)

func GetQueueByName

func GetQueueByName(queueName string) (Queue, error)

func ListQueue

func ListQueue(pk int64, maxKeys int, queueName string, userName string) ([]Queue, error)

func ListQueuesByCluster

func ListQueuesByCluster(clusterID string) []Queue

func (*Queue) AfterFind

func (queue *Queue) AfterFind(*gorm.DB) error

func (*Queue) BeforeSave

func (queue *Queue) BeforeSave(*gorm.DB) error

BeforeSave is the callback methods for saving file system

func (Queue) MarshalJSON

func (queue Queue) MarshalJSON() ([]byte, error)

func (Queue) TableName

func (Queue) TableName() string

type Run

type Run struct {
	Pk             int64                  `gorm:"primaryKey;autoIncrement;not null" json:"-"`
	ID             string                 `gorm:"type:varchar(60);not null"         json:"runID"`
	Name           string                 `gorm:"type:varchar(60);not null"         json:"name"`
	Source         string                 `gorm:"type:varchar(256);not null"        json:"source"` // pipelineID or yamlPath
	UserName       string                 `gorm:"type:varchar(60);not null"         json:"username"`
	FsID           string                 `gorm:"type:varchar(60);not null"         json:"-"`
	FsName         string                 `gorm:"type:varchar(60);not null"         json:"fsName"`
	FsOptions      schema.FsOptions       `gorm:"-"                                 json:"fsOptions"`
	Description    string                 `gorm:"type:text;size:65535;not null"     json:"description"`
	ParametersJson string                 `gorm:"type:text;size:65535;not null"     json:"-"`
	Parameters     map[string]interface{} `gorm:"-"                                 json:"parameters"`
	RunYaml        string                 `gorm:"type:text;size:65535;not null"     json:"runYaml"`
	WorkflowSource schema.WorkflowSource  `gorm:"-"                                 json:"-"` // RunYaml's dynamic struct
	Runtime        schema.RuntimeView     `gorm:"-"                                 json:"runtime"`
	PostProcess    schema.PostProcessView `gorm:"-"                                 json:"postProcess"`
	FailureOptions schema.FailureOptions  `gorm:"-"                                 json:"failureOptions"`
	DockerEnv      string                 `gorm:"type:varchar(128);not null"        json:"dockerEnv"`
	Disabled       string                 `gorm:"type:text;size:65535;not null"     json:"disabled"`
	ScheduleID     string                 `gorm:"type:varchar(60);not null"         json:"scheduleID"`
	Message        string                 `gorm:"type:text;size:65535;not null"     json:"runMsg"`
	Status         string                 `gorm:"type:varchar(32);not null"         json:"status"` // StatusRun%%%
	RunOptions     schema.RunOptions      `gorm:"-"                                 json:"-"`
	RunOptionsJson string                 `gorm:"type:text;size:65535;not null"     json:"-"`
	RunCachedIDs   string                 `gorm:"type:text;size:65535;not null"     json:"runCachedIDs"`
	ScheduledAt    sql.NullTime           `                                         json:"-"`
	CreateTime     string                 `gorm:"-"                                 json:"createTime"`
	ActivateTime   string                 `gorm:"-"                                 json:"activateTime"`
	UpdateTime     string                 `gorm:"-"                                 json:"updateTime,omitempty"`
	CreatedAt      time.Time              `                                         json:"-"`
	ActivatedAt    sql.NullTime           `                                         json:"-"`
	UpdatedAt      time.Time              `                                         json:"-"`
	DeletedAt      gorm.DeletedAt         `                                         json:"-"`
}

func GetLastRun

func GetLastRun(logEntry *log.Entry) (Run, error)

func GetRunByID

func GetRunByID(logEntry *log.Entry, runID string) (Run, error)

func ListRun

func ListRun(logEntry *log.Entry, pk int64, maxKeys int, userFilter, fsFilter, runFilter, nameFilter, statusFilter, scheduleIdFilter []string) ([]Run, error)

func ListRunsByStatus

func ListRunsByStatus(logEntry *log.Entry, statusList []string) ([]Run, error)

func (*Run) Encode

func (r *Run) Encode() error

func (*Run) GetRunCacheIDList

func (r *Run) GetRunCacheIDList() []string

func (*Run) InitRuntime added in v0.14.3

func (r *Run) InitRuntime(jobs []RunJob, dags []RunDag) error

func (*Run) ProcessRuntimeView added in v0.14.3

func (r *Run) ProcessRuntimeView(componentViews map[string][]schema.ComponentView, components map[string]schema.Component) error

补全ComponentView中的Deps

func (*Run) RemoveOuterDagView added in v0.14.3

func (r *Run) RemoveOuterDagView(runtimeView map[string][]schema.ComponentView) map[string][]schema.ComponentView

func (Run) TableName

func (Run) TableName() string

type RunCache

type RunCache struct {
	Pk          int64          `json:"-"                    gorm:"primaryKey;autoIncrement;not null"`
	ID          string         `json:"cacheID"              gorm:"type:varchar(60);not null;index"`
	FirstFp     string         `json:"firstFp"              gorm:"type:varchar(256)"`
	SecondFp    string         `json:"secondFp"             gorm:"type:varchar(256)"`
	RunID       string         `json:"runID"                gorm:"type:varchar(60);not null"`
	Source      string         `json:"source"               gorm:"type:varchar(256);not null"`
	JobID       string         `json:"jobID"                gorm:"type:varchar(60);not null"`
	FsID        string         `json:"-"                    gorm:"type:varchar(60);not null"`
	FsName      string         `json:"fsname"               gorm:"type:varchar(60);not null"`
	UserName    string         `json:"username"             gorm:"type:varchar(60);not null"`
	ExpiredTime string         `json:"expiredTime"          gorm:"type:varchar(64);default:'-1'"`
	Strategy    string         `json:"strategy"             gorm:"type:varchar(16);default:'conservative'"`
	Custom      string         `json:"custom"               gorm:"type:text;size:65535"`
	CreateTime  string         `json:"createTime"           gorm:"-"`
	UpdateTime  string         `json:"updateTime,omitempty" gorm:"-"`
	CreatedAt   time.Time      `json:"-"`
	UpdatedAt   time.Time      `json:"-"`
	DeletedAt   gorm.DeletedAt `json:"-"                    gorm:"index"`
}

func GetLastCacheForRun

func GetLastCacheForRun(logEntry *log.Entry, runID string) (RunCache, error)

func GetLastRunCache

func GetLastRunCache(logEntry *log.Entry) (RunCache, error)

func GetRunCache

func GetRunCache(logEntry *log.Entry, cacheID string) (RunCache, error)

func ListRunCache

func ListRunCache(logEntry *log.Entry, pk int64, maxKeys int, userFilter, fsFilter, runFilter []string) ([]RunCache, error)

func ListRunCacheByFirstFp

func ListRunCacheByFirstFp(logEntry *log.Entry, firstFp, fsID, source string) ([]RunCache, error)

func (RunCache) TableName

func (RunCache) TableName() string

type RunDag added in v0.14.3

type RunDag struct {
	Pk             int64             `gorm:"primaryKey;autoIncrement;not null"  json:"-"`
	ID             string            `gorm:"type:varchar(60);not null"          json:"dagID"`
	RunID          string            `gorm:"type:varchar(60);not null"          json:"runID"`
	ParentDagID    string            `gorm:"type:varchar(60);not null"          json:"parentDagID"`
	Name           string            `gorm:"type:varchar(60);not null"          json:"name"`
	DagName        string            `gorm:"type:varchar(60);not null"          json:"dag_name"`
	Parameters     map[string]string `gorm:"-"                                  json:"parameters"`
	ParametersJson string            `gorm:"type:text;size:65535;not null"      json:"-"`
	Artifacts      schema.Artifacts  `gorm:"-"                                  json:"artifacts"`
	ArtifactsJson  string            `gorm:"type:text;size:65535;not null"      json:"-"`
	LoopSeq        int               `gorm:"type:int;not null"                  json:"-"`
	Status         schema.JobStatus  `gorm:"type:varchar(32);not null"          json:"status"`
	Message        string            `gorm:"type:text;size:65535;not null"      json:"message"`
	CreateTime     string            `gorm:"-"                                  json:"createTime"`
	ActivateTime   string            `gorm:"-"                                  json:"activateTime"`
	UpdateTime     string            `gorm:"-"                                  json:"updateTime,omitempty"`
	CreatedAt      time.Time         `                                          json:"-"`
	ActivatedAt    sql.NullTime      `                                          json:"-"`
	UpdatedAt      time.Time         `                                          json:"-"`
	DeletedAt      gorm.DeletedAt    `gorm:"index"                              json:"-"`
}

func GetRunDagsOfRun added in v0.14.3

func GetRunDagsOfRun(logEntry *log.Entry, runID string) ([]RunDag, error)

func ParseRunDag added in v0.14.3

func ParseRunDag(dagView *schema.DagView) RunDag

func (*RunDag) Encode added in v0.14.3

func (rd *RunDag) Encode() error

func (*RunDag) Trans2DagView added in v0.14.3

func (rd *RunDag) Trans2DagView() schema.DagView

type RunJob

type RunJob struct {
	Pk             int64             `gorm:"primaryKey;autoIncrement;not null"  json:"-"`
	ID             string            `gorm:"type:varchar(60);not null"          json:"jobID"`
	RunID          string            `gorm:"type:varchar(60);not null"          json:"runID"`
	ParentDagID    string            `gorm:"type:varchar(60);not null"          json:"parentDagID"`
	Name           string            `gorm:"type:varchar(60);not null"          json:"name"`
	StepName       string            `gorm:"type:varchar(60);not null"          json:"step_name"`
	Command        string            `gorm:"type:text;size:65535;not null"      json:"command"`
	Parameters     map[string]string `gorm:"-"                                  json:"parameters"`
	ParametersJson string            `gorm:"type:text;size:65535;not null"      json:"-"`
	Artifacts      schema.Artifacts  `gorm:"-"                                  json:"artifacts"`
	ArtifactsJson  string            `gorm:"type:text;size:65535;not null"      json:"-"`
	Env            map[string]string `gorm:"-"                                  json:"env"`
	EnvJson        string            `gorm:"type:text;size:65535;not null"      json:"-"`
	DockerEnv      string            `gorm:"type:varchar(128);not null"         json:"docker_env"`
	LoopSeq        int               `gorm:"type:int;not null"                  json:"-"`
	Status         schema.JobStatus  `gorm:"type:varchar(32);not null"          json:"status"`
	Message        string            `gorm:"type:text;size:65535;not null"      json:"message"`
	Cache          schema.Cache      `gorm:"-"                                  json:"cache"`
	CacheJson      string            `gorm:"type:text;size:65535;not null"      json:"-"`
	CacheRunID     string            `gorm:"type:varchar(60);not null"          json:"cacheRunID"`
	CacheJobID     string            `gorm:"type:varchar(60);not null"          json:"cacheJobID"`
	ExtraFS        []schema.FsMount  `gorm:"-"                                  json:"extraFs"`
	ExtraFSJson    string            `gorm:"type:text;size:65535;not null"      json:"-"`
	CreateTime     string            `gorm:"-"                                  json:"createTime"`
	ActivateTime   string            `gorm:"-"                                  json:"activateTime"`
	UpdateTime     string            `gorm:"-"                                  json:"updateTime,omitempty"`
	CreatedAt      time.Time         `                                          json:"-"`
	ActivatedAt    sql.NullTime      `                                          json:"-"`
	UpdatedAt      time.Time         `                                          json:"-"`
	DeletedAt      gorm.DeletedAt    `gorm:"index"                              json:"-"`
}

func GetRunJob added in v0.14.3

func GetRunJob(logEntry *log.Entry, jobID string) (RunJob, error)

func GetRunJobsOfRun

func GetRunJobsOfRun(logEntry *log.Entry, runID string) ([]RunJob, error)

func ParseRunJob

func ParseRunJob(jobView *schema.JobView) RunJob

func (*RunJob) Encode

func (rj *RunJob) Encode() error

func (*RunJob) ParseJobView

func (rj *RunJob) ParseJobView(step *schema.WorkflowSourceStep) schema.JobView

func (*RunJob) Trans2JobView added in v0.14.3

func (rj *RunJob) Trans2JobView() schema.JobView

type Schedule added in v0.14.3

type Schedule struct {
	Pk                int64          `gorm:"primaryKey;autoIncrement;not null" json:"-"`
	ID                string         `gorm:"type:varchar(60);not null"         json:"scheduleID"`
	Name              string         `gorm:"type:varchar(60);not null"         json:"name"`
	Desc              string         `gorm:"type:varchar(256);not null"       json:"desc"`
	PipelineID        string         `gorm:"type:varchar(60);not null"         json:"pipelineID"`
	PipelineVersionID string         `gorm:"type:varchar(60);not null"         json:"pipelineVersionID"`
	UserName          string         `gorm:"type:varchar(60);not null"         json:"username"`
	FsConfig          string         `gorm:"type:varchar(1024);not null"       json:"fsConfig"`
	Crontab           string         `gorm:"type:varchar(60);not null"         json:"crontab"`
	Options           string         `gorm:"type:text;size:65535;not null"     json:"options"`
	Message           string         `gorm:"type:text;size:65535;not null"     json:"scheduleMsg"`
	Status            string         `gorm:"type:varchar(32);not null"         json:"status"`
	StartAt           sql.NullTime   `                                         json:"-"`
	EndAt             sql.NullTime   `                                         json:"-"`
	NextRunAt         time.Time      `                                         json:"-"`
	CreatedAt         time.Time      `                                         json:"-"`
	UpdatedAt         time.Time      `                                         json:"-"`
	DeletedAt         gorm.DeletedAt `                                         json:"-"`
}

func GetSchedule added in v0.14.3

func GetSchedule(logEntry *log.Entry, scheduleID string) (Schedule, error)

func GetScheduleByName added in v0.14.3

func GetScheduleByName(logEntry *log.Entry, name, userName string) (Schedule, error)

func GetSchedulesByStatus added in v0.14.3

func GetSchedulesByStatus(logEntry *log.Entry, status string) (schedules []Schedule, err error)

func ListSchedule added in v0.14.3

func ListSchedule(logEntry *log.Entry, pk int64, maxKeys int, pplFilter, pplVersionFilter, userFilter, scheduleFilter, nameFilter, statusFilter []string) ([]Schedule, error)

func (Schedule) TableName added in v0.14.3

func (Schedule) TableName() string

type ScheduleOptions added in v0.14.3

type ScheduleOptions struct {
	Catchup           bool   `json:"catchup"`
	ExpireInterval    int    `json:"expireInterval"`
	Concurrency       int    `json:"concurrency"`
	ConcurrencyPolicy string `json:"concurrencyPolicy"`
}

func DecodeScheduleOptions added in v0.14.3

func DecodeScheduleOptions(StrOptions string) (so ScheduleOptions, err error)

func NewScheduleOptions added in v0.14.3

func NewScheduleOptions(logEntry *log.Entry, catchup bool, expireInterval int, concurrency int, concurrencyPolicy string) (so ScheduleOptions, err error)

func (*ScheduleOptions) Encode added in v0.14.3

func (so *ScheduleOptions) Encode(logEntry *log.Entry) (string, error)

type Transaction

type Transaction func(db *gorm.DB) error

Jump to

Keyboard shortcuts

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