[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:
Yifan Xiong 2019-12-06 11:16:01 +08:00 коммит произвёл GitHub
Родитель b3baf46743
Коммит 4b0346bf3c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -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();
});
}