Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

[Rest Server] Add get job api v2 #2851

Merged
merged 4 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rest-server/src/controllers/v2/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const update = asyncHandler(async (req, res) => {
throw createError('Conflict', 'ConflictJobError', `Job ${frameworkName} already exists.`);
}
} catch (error) {
if (error.code === 'UnknownError') {
if (error.code !== 'NoJobError') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can log this?

if (error.code === 'NoJobError') {
  log.Debug('...');
  return;
}

throw error;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not an error if job not found here, no need to log.

throw error;
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/rest-server/src/models/v2/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,13 @@ async function get(frameworkName) {
url: launcherConfig.frameworkPath(frameworkName),
headers: launcherConfig.webserviceRequestHeaders(userName),
});
if (response.status !== status('OK')) {
if (response.status === status('OK')) {
return response.data;
} else if (response.status === status('Not Found')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove else

if (status === statue('OK')) {
  return ...;
}

if (...) {
  throw ...
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

throw createError('Not Found', 'NoJobError', `Job ${frameworkName} is not found.`);
} else {
throw createError(response.status, 'UnknownError', response.data.raw_body);
}
return response.data;
}

async function put(frameworkName, config, rawConfig) {
Expand Down