Skip to content

Commit

Permalink
fixed update api to validate changes before saving them resolves tera…
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnoble committed Sep 28, 2017
1 parent 28075a1 commit ed1d7ad
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/cluster/services/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down

0 comments on commit ed1d7ad

Please sign in to comment.