fix(apiserver): check the default queue exists and is open on submit (bug-1960)
Cause: preCheckJobRequest (controllers/jobs.go) ran the reserved-name, existence and closed checks only when a queue name was given; an empty name was set to "normal" and skipped them, so jobs were accepted into a closed default queue. Fix: default the name first, then run the same checks for every submission. Two existing tests now seed the default queue. (The controller side of bug-1960 is fixed separately.) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
387a421c57
commit
1ff068f6e7
3 changed files with 63 additions and 19 deletions
|
|
@ -1311,26 +1311,27 @@ func preCheckJobRequest(req *models.JobSubmitRequest) (n int, isArray bool, err
|
|||
// goes through the same checks and conversions below
|
||||
n, isArray = 1, false
|
||||
if req.QueueName == "" {
|
||||
// bug-1960: the default queue gets the same existence and closed
|
||||
// checks as a named one below
|
||||
req.QueueName = "normal"
|
||||
} else {
|
||||
// Reject submissions to the reserved internal recovery queue.
|
||||
if req.QueueName == "lost_and_found" {
|
||||
logger.Error("Job submission to reserved queue rejected",
|
||||
zap.String("queue_name", req.QueueName))
|
||||
return 0, false, fmt.Errorf(
|
||||
"cannot submit jobs to 'lost_and_found' — this is an internal recovery queue")
|
||||
}
|
||||
//validate queue_name whether exists
|
||||
queueInfo, ok := store.Queues.Get(req.QueueName)
|
||||
if !ok {
|
||||
logger.Error("Invalid queue name specified", zap.String("queue_name", req.QueueName))
|
||||
return 0, false, fmt.Errorf("invalid queue name: %s", req.QueueName)
|
||||
}
|
||||
queue_statusStr := formatQueueStatus(int64(queueInfo.QueueStatus))
|
||||
if strings.HasPrefix(strings.ToLower(queue_statusStr), "closed") {
|
||||
logger.Error("Queue is closed", zap.String("queue_name", req.QueueName))
|
||||
return 0, false, fmt.Errorf("cannot submit job to queue %s: queue is closed", req.QueueName)
|
||||
}
|
||||
}
|
||||
// Reject submissions to the reserved internal recovery queue.
|
||||
if req.QueueName == "lost_and_found" {
|
||||
logger.Error("Job submission to reserved queue rejected",
|
||||
zap.String("queue_name", req.QueueName))
|
||||
return 0, false, fmt.Errorf(
|
||||
"cannot submit jobs to 'lost_and_found' — this is an internal recovery queue")
|
||||
}
|
||||
//validate queue_name whether exists
|
||||
queueInfo, ok := store.Queues.Get(req.QueueName)
|
||||
if !ok {
|
||||
logger.Error("Invalid queue name specified", zap.String("queue_name", req.QueueName))
|
||||
return 0, false, fmt.Errorf("invalid queue name: %s", req.QueueName)
|
||||
}
|
||||
queue_statusStr := formatQueueStatus(int64(queueInfo.QueueStatus))
|
||||
if strings.HasPrefix(strings.ToLower(queue_statusStr), "closed") {
|
||||
logger.Error("Queue is closed", zap.String("queue_name", req.QueueName))
|
||||
return 0, false, fmt.Errorf("cannot submit job to queue %s: queue is closed", req.QueueName)
|
||||
}
|
||||
if req.JobName != "" {
|
||||
// A name containing '[' or ']' is an array index expression; it is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue