зеркало из https://github.com/microsoft/pai.git
[Rest Server] Fix duplicate affinity group name issue (#3971)
* Fix duplicate affinity group name issue Fix duplicate affinity group name issue.
This commit is contained in:
Родитель
b3baf46743
Коммит
4b0346bf3c
|
@ -33,7 +33,7 @@ const convertPriority = (priorityClass='test') => {
|
|||
return priorityClass in priorityMap ? priorityMap[priorityClass] : null;
|
||||
};
|
||||
|
||||
const hivedValidate = (protocolObj) => {
|
||||
const hivedValidate = (protocolObj, username) => {
|
||||
if (!hivedSchema.validate(protocolObj)) {
|
||||
throw createError('Bad Request', 'InvalidProtocolError', hivedSchema.validate.errors);
|
||||
}
|
||||
|
@ -162,14 +162,14 @@ const hivedValidate = (protocolObj) => {
|
|||
|
||||
const affinityGroupName = hivedConfig.taskRoles[taskRole].affinityGroupName;
|
||||
podSpec.affinityGroup = affinityGroupName ? {
|
||||
name: protocolObj.name + '/' + affinityGroupName,
|
||||
name: `${username}~${protocolObj.name}/${affinityGroupName}`,
|
||||
members: affinityGroups[affinityGroupName].affinityTaskList,
|
||||
} : null;
|
||||
}
|
||||
|
||||
if (defaultAffinityGroup != null) {
|
||||
podSpec.affinityGroup = {
|
||||
name: `${protocolObj.name}/default`,
|
||||
name: `${username}~${protocolObj.name}/default`,
|
||||
members: defaultAffinityGroup.affinityTaskList,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ const yaml = require('js-yaml');
|
|||
const mustache = require('mustache');
|
||||
|
||||
const createError = require('@pai/utils/error');
|
||||
const hivedMiddle = require('@pai/middlewares/v2/hived');
|
||||
const hived = require('@pai/middlewares/v2/hived');
|
||||
const launcherConfig = require('@pai/config/launcher');
|
||||
const protocolSchema = require('@pai/config/v2/protocol');
|
||||
|
||||
|
@ -188,7 +188,7 @@ const protocolSubmitMiddleware = [
|
|||
if (launcherConfig.enabledHived) {
|
||||
protocolSubmitMiddleware.push(
|
||||
(req, res, next) => {
|
||||
res.locals.protocol = hivedMiddle.validate(res.locals.protocol);
|
||||
res.locals.protocol = hived.validate(res.locals.protocol, req.user.username);
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче