Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteOldJobs(db *sql.DB, batchSizeLimit int, cutoff time.Time) error
- func GlobSearchOrExact(field exp.IdentifierExpression, pattern string) goqu.Expression
- func NewNullString(s string) sql.NullString
- func ParseNullBool(nullBool sql.NullBool) bool
- func ParseNullFloat(nullFloat sql.NullFloat64) float64
- func ParseNullInt(nullInt sql.NullInt64) int64
- func ParseNullTimeDefault(nullTime sql.NullTime) time.Time
- func StartsWith(field exp.IdentifierExpression, pattern string) goqu.Expression
- func ToUTC(t time.Time) time.Time
- type JobRecorder
- type JobRepository
- type JobRow
- type JobState
- type SQLJobRepository
- func (r *SQLJobRepository) GetJobSetInfos(ctx context.Context, opts *lookout.GetJobSetsRequest) ([]*lookout.JobSetInfo, error)
- func (r *SQLJobRepository) GetJobs(ctx context.Context, opts *lookout.GetJobsRequest) ([]*lookout.JobInfo, error)
- func (r *SQLJobRepository) GetQueueInfos(ctx context.Context) ([]*lookout.QueueInfo, error)
- type SQLJobStore
- func (r *SQLJobStore) MarkCancelled(event *api.JobCancelledEvent) error
- func (r *SQLJobStore) RecordJob(job *api.Job, timestamp time.Time) error
- func (r *SQLJobStore) RecordJobDuplicate(event *api.JobDuplicateFoundEvent) error
- func (r *SQLJobStore) RecordJobFailed(event *api.JobFailedEvent) error
- func (r *SQLJobStore) RecordJobPending(event *api.JobPendingEvent) error
- func (r *SQLJobStore) RecordJobReprioritized(event *api.JobReprioritizedEvent) error
- func (r *SQLJobStore) RecordJobRunning(event *api.JobRunningEvent) error
- func (r *SQLJobStore) RecordJobSucceeded(event *api.JobSucceededEvent) error
- func (r *SQLJobStore) RecordJobTerminated(event *api.JobTerminatedEvent) error
- func (r *SQLJobStore) RecordJobUnableToSchedule(event *api.JobUnableToScheduleEvent) error
- type SqlHealth
Constants ¶
const ( JobQueued JobState = "QUEUED" JobPending JobState = "PENDING" JobRunning JobState = "RUNNING" JobSucceeded JobState = "SUCCEEDED" JobFailed JobState = "FAILED" JobCancelled JobState = "CANCELLED" JobDuplicate JobState = "DUPLICATE" JobQueuedOrdinal = 1 JobPendingOrdinal = 2 JobRunningOrdinal = 3 JobSucceededOrdinal = 4 JobFailedOrdinal = 5 JobCancelledOrdinal = 6 JobDuplicateOrdinal = 7 )
const ( SearchWildcard string = "*" SQLLikeWildcard string = "%" )
Variables ¶
var AllJobStates = []JobState{ JobQueued, JobPending, JobRunning, JobSucceeded, JobFailed, JobCancelled, JobDuplicate, }
var IntToJobStateMap = map[int]JobState{ JobQueuedOrdinal: JobQueued, JobPendingOrdinal: JobPending, JobRunningOrdinal: JobRunning, JobSucceededOrdinal: JobSucceeded, JobFailedOrdinal: JobFailed, JobCancelledOrdinal: JobCancelled, JobDuplicateOrdinal: JobDuplicate, }
var JobStateToIntMap = map[JobState]int{ JobQueued: JobQueuedOrdinal, JobPending: JobPendingOrdinal, JobRunning: JobRunningOrdinal, JobSucceeded: JobSucceededOrdinal, JobFailed: JobFailedOrdinal, JobCancelled: JobCancelledOrdinal, JobDuplicate: JobDuplicateOrdinal, }
Functions ¶
func DeleteOldJobs ¶
DeleteOldJobs deletes jobs from the database that were submitted before cutoff. The jobs are deleted in batches with the maximum number of jobs being deleted in each batch being given by batchSizeLimit. The tables from which the jobs wil be deleted are: * user_annotation_lookup * job_run_container * job_run * job This function returns nil if the operation succeeded and an error otherwise. Note that For performance reasons we don't use a transaction here and so an error may indicate that Some jobs were deleted.
func GlobSearchOrExact ¶
func GlobSearchOrExact(field exp.IdentifierExpression, pattern string) goqu.Expression
Do a glob (sql like) search if the pattern contains any * characters, otherwise do an exact match.
func NewNullString ¶
func NewNullString(s string) sql.NullString
func ParseNullBool ¶
func ParseNullFloat ¶
func ParseNullFloat(nullFloat sql.NullFloat64) float64
func ParseNullInt ¶
func StartsWith ¶
func StartsWith(field exp.IdentifierExpression, pattern string) goqu.Expression
Types ¶
type JobRecorder ¶
type JobRecorder interface { RecordJob(job *api.Job, timestamp time.Time) error MarkCancelled(*api.JobCancelledEvent) error RecordJobPending(event *api.JobPendingEvent) error RecordJobRunning(event *api.JobRunningEvent) error RecordJobSucceeded(event *api.JobSucceededEvent) error RecordJobFailed(event *api.JobFailedEvent) error RecordJobUnableToSchedule(event *api.JobUnableToScheduleEvent) error RecordJobDuplicate(event *api.JobDuplicateFoundEvent) error RecordJobTerminated(event *api.JobTerminatedEvent) error RecordJobReprioritized(event *api.JobReprioritizedEvent) error }
type JobRepository ¶
type JobRow ¶
type JobRow struct { JobId sql.NullString `db:"job_id"` Queue sql.NullString `db:"queue"` Owner sql.NullString `db:"owner"` JobSet sql.NullString `db:"jobset"` Priority sql.NullFloat64 `db:"priority"` Submitted sql.NullTime `db:"submitted"` Cancelled sql.NullTime `db:"cancelled"` Preempted sql.NullTime `db:"preempted"` OrigJobSpec []byte `db:"orig_job_spec"` State sql.NullInt64 `db:"state"` RunId sql.NullString `db:"run_id"` PodNumber sql.NullInt64 `db:"pod_number"` Cluster sql.NullString `db:"cluster"` Node sql.NullString `db:"node"` Created sql.NullTime `db:"created"` Started sql.NullTime `db:"started"` Finished sql.NullTime `db:"finished"` Succeeded sql.NullBool `db:"succeeded"` Error sql.NullString `db:"error"` }
type JobState ¶
type JobState string
Emulates JobStates enum can't use protobuf enums because gogoproto + grpc-gateway is hard with K8s specific messages
type SQLJobRepository ¶
type SQLJobRepository struct {
// contains filtered or unexported fields
}
func NewSQLJobRepository ¶
func NewSQLJobRepository(db *goqu.Database, clock util.Clock) *SQLJobRepository
func (*SQLJobRepository) GetJobSetInfos ¶
func (r *SQLJobRepository) GetJobSetInfos(ctx context.Context, opts *lookout.GetJobSetsRequest) ([]*lookout.JobSetInfo, error)
func (*SQLJobRepository) GetJobs ¶
func (r *SQLJobRepository) GetJobs(ctx context.Context, opts *lookout.GetJobsRequest) ([]*lookout.JobInfo, error)
func (*SQLJobRepository) GetQueueInfos ¶
type SQLJobStore ¶
type SQLJobStore struct {
// contains filtered or unexported fields
}
func NewSQLJobStore ¶
func NewSQLJobStore(db *goqu.Database, annotationPrefix string) *SQLJobStore
func (*SQLJobStore) MarkCancelled ¶
func (r *SQLJobStore) MarkCancelled(event *api.JobCancelledEvent) error
func (*SQLJobStore) RecordJobDuplicate ¶
func (r *SQLJobStore) RecordJobDuplicate(event *api.JobDuplicateFoundEvent) error
func (*SQLJobStore) RecordJobFailed ¶
func (r *SQLJobStore) RecordJobFailed(event *api.JobFailedEvent) error
func (*SQLJobStore) RecordJobPending ¶
func (r *SQLJobStore) RecordJobPending(event *api.JobPendingEvent) error
func (*SQLJobStore) RecordJobReprioritized ¶
func (r *SQLJobStore) RecordJobReprioritized(event *api.JobReprioritizedEvent) error
func (*SQLJobStore) RecordJobRunning ¶
func (r *SQLJobStore) RecordJobRunning(event *api.JobRunningEvent) error
func (*SQLJobStore) RecordJobSucceeded ¶
func (r *SQLJobStore) RecordJobSucceeded(event *api.JobSucceededEvent) error
func (*SQLJobStore) RecordJobTerminated ¶
func (r *SQLJobStore) RecordJobTerminated(event *api.JobTerminatedEvent) error
func (*SQLJobStore) RecordJobUnableToSchedule ¶
func (r *SQLJobStore) RecordJobUnableToSchedule(event *api.JobUnableToScheduleEvent) error