fix(apiserver): validate named and array submissions like any other (bug-1953)

preCheckJobRequest() returned from inside its job-name branch, so every
named or array job skipped the description, project and resreq checks,
resreq validation and the shell-limit conversion that follow. The name now
only sets the job count and array flag, and every submission runs the rest.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-10-10 08:59:34 +00:00
parent 27ef506058
commit e00526f9f5
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
2 changed files with 54 additions and 19 deletions

View file

@ -1307,6 +1307,9 @@ var (
// to 400).
func preCheckJobRequest(req *models.JobSubmitRequest) (n int, isArray bool, err error) {
logger.Debug("Enter preCheckJobRequest")
// bug-1953: the name only decides n and isArray; every submission then
// goes through the same checks and conversions below
n, isArray = 1, false
if req.QueueName == "" {
req.QueueName = "normal"
} else {
@ -1343,27 +1346,26 @@ func preCheckJobRequest(req *models.JobSubmitRequest) (n int, isArray bool, err
req.JobName = arrayName
logger.Debug("preCheckJobRequest parsed array job name",
zap.String("jobName", req.JobName), zap.Int("arraySize", count))
return count, true, nil
}
// Names without brackets keep the existing path (1.4).
arrayName, idx, slotLimit, err := createArrayName(req.JobName)
if err != nil {
logger.Error("job name format is invalid", zap.Error(err))
return 0, false, errors.New("job array list format is invalid: " + err.Error())
}
if arrayName != "" {
if err = isValidArrayName(arrayName); err != nil {
logger.Error(err.Error())
n, isArray = count, true
} else {
// Names without brackets keep the existing path (1.4).
arrayName, idx, slotLimit, err := createArrayName(req.JobName)
if err != nil {
logger.Error("job name format is invalid", zap.Error(err))
return 0, false, errors.New("job array list format is invalid: " + err.Error())
}
}
req.JobName = arrayName
logger.Debug("preCheckJobRequest parsed job name is: ", zap.String("jobName", req.JobName),
zap.Any("indices", idx), zap.Any("slotLimit", slotLimit))
return 1, false, nil
if arrayName != "" {
if err = isValidArrayName(arrayName); err != nil {
logger.Error(err.Error())
return 0, false, errors.New("job array list format is invalid: " + err.Error())
}
}
req.JobName = arrayName
logger.Debug("preCheckJobRequest parsed job name is: ", zap.String("jobName", req.JobName),
zap.Any("indices", idx), zap.Any("slotLimit", slotLimit))
}
} else {
if req.Command != "" {
if len(req.Command) > 4094 {
@ -1531,7 +1533,7 @@ func preCheckJobRequest(req *models.JobSubmitRequest) (n int, isArray bool, err
req.LaunchType = launchType
}
return 1, false, nil
return n, isArray, nil
}
// It returns minTasks, maxTasks, and an error if parsing fails or constraints are violated.