2019-06-13 19:48:20 +00:00
|
|
|
package influxdb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// ErrRunCanceled is returned from the RunResult when a Run is Canceled. It is used mostly internally.
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrRunCanceled = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Code: EInternal,
|
|
|
|
Msg: "run canceled",
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrTaskNotClaimed is returned when attempting to operate against a task that must be claimed but is not.
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrTaskNotClaimed = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Code: EConflict,
|
|
|
|
Msg: "task not claimed",
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrTaskAlreadyClaimed is returned when attempting to operate against a task that must not be claimed but is.
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrTaskAlreadyClaimed = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Code: EConflict,
|
|
|
|
Msg: "task already claimed",
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrNoRunsFound is returned when searching for a range of runs, but none are found.
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrNoRunsFound = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Code: ENotFound,
|
|
|
|
Msg: "no matching runs found",
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrInvalidTaskID error object for bad id's
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrInvalidTaskID = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Code: EInvalid,
|
|
|
|
Msg: "invalid id",
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrTaskNotFound indicates no task could be found for given parameters.
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrTaskNotFound = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Code: ENotFound,
|
|
|
|
Msg: "task not found",
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrRunNotFound is returned when searching for a single run that doesn't exist.
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrRunNotFound = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Code: ENotFound,
|
|
|
|
Msg: "run not found",
|
|
|
|
}
|
|
|
|
|
2019-09-16 20:55:39 +00:00
|
|
|
ErrRunKeyNotFound = &Error{
|
|
|
|
Code: ENotFound,
|
|
|
|
Msg: "run key not found",
|
|
|
|
}
|
|
|
|
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrPageSizeTooSmall = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Msg: "cannot have negative page limit",
|
|
|
|
Code: EInvalid,
|
|
|
|
}
|
|
|
|
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrPageSizeTooLarge = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Msg: fmt.Sprintf("cannot use page size larger then %d", MaxPageSize),
|
|
|
|
Code: EInvalid,
|
|
|
|
}
|
|
|
|
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrOrgNotFound = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Msg: "organization not found",
|
|
|
|
Code: ENotFound,
|
|
|
|
}
|
|
|
|
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrTaskRunAlreadyQueued = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Msg: "run already queued",
|
|
|
|
Code: EConflict,
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrOutOfBoundsLimit is returned with FindRuns is called with an invalid filter limit.
|
2019-07-15 20:57:51 +00:00
|
|
|
ErrOutOfBoundsLimit = &Error{
|
2019-06-13 19:48:20 +00:00
|
|
|
Code: EUnprocessableEntity,
|
|
|
|
Msg: "run limit is out of bounds, must be between 1 and 500",
|
|
|
|
}
|
2019-07-15 21:28:54 +00:00
|
|
|
|
2019-08-20 14:42:40 +00:00
|
|
|
// ErrInvalidOwnerID is called when trying to create a task with out a valid ownerID
|
|
|
|
ErrInvalidOwnerID = &Error{
|
2019-07-15 21:28:54 +00:00
|
|
|
Code: EInvalid,
|
2019-08-20 14:42:40 +00:00
|
|
|
Msg: "cannot create task with invalid ownerID",
|
2019-07-15 21:28:54 +00:00
|
|
|
}
|
2019-06-13 19:48:20 +00:00
|
|
|
)
|
|
|
|
|
2019-09-10 19:48:55 +00:00
|
|
|
// ErrFluxParseError is returned when an error is thrown by Flux.Parse in the task executor
|
|
|
|
func ErrFluxParseError(err error) *Error {
|
|
|
|
return &Error{
|
|
|
|
Code: EInvalid,
|
|
|
|
Msg: fmt.Sprintf("could not parse Flux script; Err: %v", err),
|
2019-10-09 20:51:03 +00:00
|
|
|
Op: "taskExecutor",
|
2019-09-10 19:48:55 +00:00
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrQueryError is returned when an error is thrown by Query service in the task executor
|
|
|
|
func ErrQueryError(err error) *Error {
|
|
|
|
return &Error{
|
|
|
|
Code: EInternal,
|
|
|
|
Msg: fmt.Sprintf("unexpected error from queryd; Err: %v", err),
|
2019-10-09 20:51:03 +00:00
|
|
|
Op: "taskExecutor",
|
2019-09-10 19:48:55 +00:00
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrResultIteratorError is returned when an error is thrown by exhaustResultIterators in the executor
|
|
|
|
func ErrResultIteratorError(err error) *Error {
|
|
|
|
return &Error{
|
2019-09-16 20:55:39 +00:00
|
|
|
Code: EInvalid,
|
2019-09-10 19:48:55 +00:00
|
|
|
Msg: fmt.Sprintf("Error exhausting result iterator; Err: %v", err),
|
2019-10-09 20:51:03 +00:00
|
|
|
Op: "taskExecutor",
|
2019-09-10 19:48:55 +00:00
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-13 19:48:20 +00:00
|
|
|
func ErrInternalTaskServiceError(err error) *Error {
|
|
|
|
return &Error{
|
|
|
|
Code: EInternal,
|
|
|
|
Msg: fmt.Sprintf("unexpected error in tasks; Err: %v", err),
|
2019-10-09 20:51:03 +00:00
|
|
|
Op: "task",
|
2019-06-13 19:48:20 +00:00
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrUnexpectedTaskBucketErr a generic error we can use when we rail to retrieve a bucket
|
|
|
|
func ErrUnexpectedTaskBucketErr(err error) *Error {
|
|
|
|
return &Error{
|
|
|
|
Code: EInternal,
|
|
|
|
Msg: fmt.Sprintf("unexpected error retrieving task bucket; Err: %v", err),
|
2019-10-09 20:51:03 +00:00
|
|
|
Op: "taskBucket",
|
2019-06-13 19:48:20 +00:00
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrTaskTimeParse an error for time parsing errors
|
|
|
|
func ErrTaskTimeParse(err error) *Error {
|
|
|
|
return &Error{
|
2019-10-09 20:51:03 +00:00
|
|
|
Code: EInternal,
|
2019-06-13 19:48:20 +00:00
|
|
|
Msg: fmt.Sprintf("unexpected error parsing time; Err: %v", err),
|
2019-10-09 20:51:03 +00:00
|
|
|
Op: "taskCron",
|
2019-06-13 19:48:20 +00:00
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ErrTaskOptionParse(err error) *Error {
|
|
|
|
return &Error{
|
|
|
|
Code: EInvalid,
|
|
|
|
Msg: fmt.Sprintf("invalid options; Err: %v", err),
|
2019-10-09 20:51:03 +00:00
|
|
|
Op: "taskOptions",
|
2019-06-13 19:48:20 +00:00
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-16 20:55:39 +00:00
|
|
|
func ErrJsonMarshalError(err error) *Error {
|
|
|
|
return &Error{
|
|
|
|
Code: EInvalid,
|
|
|
|
Msg: fmt.Sprintf("unable to marshal JSON; Err: %v", err),
|
2019-10-09 20:51:03 +00:00
|
|
|
Op: "taskScheduler",
|
2019-09-16 20:55:39 +00:00
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ErrRunExecutionError(err error) *Error {
|
|
|
|
return &Error{
|
|
|
|
Code: EInternal,
|
|
|
|
Msg: fmt.Sprintf("could not execute task run; Err: %v", err),
|
2019-10-09 20:51:03 +00:00
|
|
|
Op: "taskExecutor",
|
2019-09-16 20:55:39 +00:00
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
2019-09-25 18:02:04 +00:00
|
|
|
|
|
|
|
func ErrTaskConcurrencyLimitReached(runsInFront int) *Error {
|
|
|
|
return &Error{
|
|
|
|
Code: ETooManyRequests,
|
|
|
|
Msg: fmt.Sprintf("could not execute task, concurrency limit reached, runs in front: %d", runsInFront),
|
|
|
|
Op: "taskExecutor",
|
|
|
|
}
|
|
|
|
}
|