Skip to content

Commit

Permalink
add bypass option to skip validation for _inactive jobs (#3592)
Browse files Browse the repository at this point in the history
This PR makes the following changes:
- When marking a job as `_inactive` using the JSON API, job validation
will be skipped. An old job may not have the needed connectors, assets,
etc to pass validation, but we still want to be able to mark it as
inactive.
- This will only skip validation when switching active from true or
undefined to false.
- Bump teraslice from **1.2.0** to **1.2.1**

Ref: #3471
  • Loading branch information
busma13 authored Apr 12, 2024
1 parent 92501f9 commit f5d3e8a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "teraslice-workspace",
"displayName": "Teraslice",
"version": "1.2.0",
"version": "1.2.1",
"private": true,
"homepage": "https://github.com/terascope/teraslice",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/teraslice/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "teraslice",
"displayName": "Teraslice",
"version": "1.2.0",
"version": "1.2.1",
"description": "Distributed computing platform for processing JSON data",
"homepage": "https://github.com/terascope/teraslice#readme",
"bugs": {
Expand Down
17 changes: 15 additions & 2 deletions packages/teraslice/src/lib/cluster/services/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,24 @@ export class JobsService {
return this.updateJob(jobId, job);
}

/**
* Update a job
*
* @param {string} jobId
* @param {Partial<jobRecord>} jobSpec
* @returns {Promise<JobRecord>}
*/
async updateJob(jobId: string, jobSpec: Partial<JobRecord>) {
await this._validateJobSpec(jobSpec);

const originalJob = await this.jobsStorage.get(jobId);

// If job is switching from active to inactive job validation is skipped
// This allows for old jobs that are missing required resources to be marked inactive
if (originalJob.active !== false && jobSpec.active === false) {
this.logger.info(`Skipping job validation to set jobId ${jobId} as _inactive`);
} else {
await this._validateJobSpec(jobSpec);
}

return this.jobsStorage.update(jobId, Object.assign({}, jobSpec, {
_created: originalJob._created
}));
Expand Down

0 comments on commit f5d3e8a

Please sign in to comment.