diff --git a/lib/cluster/services/jobs.js b/lib/cluster/services/jobs.js index 111c0ec94ef..e3242aef3cc 100644 --- a/lib/cluster/services/jobs.js +++ b/lib/cluster/services/jobs.js @@ -340,11 +340,18 @@ module.exports = function(context, cluster_service) { } // Updates the job but does not automatically start it. - function updateJob(job_id, job) { - return job_store.update(job_id, job) + function updateJob(job_id, jobUpdates) { + return getJob(job_id) + .then(function(job_spec) { + var updatedJob = _.assign({}, job_spec, jobUpdates); + return _validateJob(updatedJob); + }) + .then(function(validJob) { + return job_store.update(job_id, validJob); + }) .catch(function(err) { var errMsg = parseError(err); - logger.error(`could not updateJob`, errMsg) + logger.error(`could not updateJob`, errMsg); }); }