Merge "[APIv2] Refactor job cancel operation"
This commit is contained in:
commit
a1db392af7
@ -63,17 +63,6 @@ def jobs_get(job_id):
|
||||
return u.render(result)
|
||||
|
||||
|
||||
@rest.get('/jobs/<job_id>/cancel')
|
||||
@acl.enforce("data-processing:job-executions:cancel")
|
||||
@v.check_exists(api.get_job_execution, id='job_id')
|
||||
@v.validate(None, v_j_e.check_job_execution_cancel)
|
||||
def jobs_cancel(job_id):
|
||||
result = u.to_wrapped_dict_no_render(api.cancel_job_execution, job_id)
|
||||
result['engine_job_id'] = result['oozie_job_id']
|
||||
del result['oozie_job_id']
|
||||
return u.render(result)
|
||||
|
||||
|
||||
@rest.patch('/jobs/<job_id>')
|
||||
@acl.enforce("data-processing:job-executions:modify")
|
||||
@v.check_exists(api.get_job_execution, id='job_id')
|
||||
|
@ -83,24 +83,18 @@ def get_job_execution(id, refresh_status=False):
|
||||
return conductor.job_execution_get(context.ctx(), id)
|
||||
|
||||
|
||||
def cancel_job_execution(id):
|
||||
context.set_current_job_execution_id(id)
|
||||
job_execution = conductor.job_execution_get(context.ctx(), id)
|
||||
api.OPS.cancel_job_execution(id)
|
||||
|
||||
return job_execution
|
||||
|
||||
|
||||
def update_job_execution(id, values):
|
||||
_update_status(values.pop("info", None))
|
||||
_update_status(values.pop("info", None), id)
|
||||
return conductor.job_execution_update(context.ctx(), id, values)
|
||||
|
||||
|
||||
def _update_status(info):
|
||||
def _update_status(info, id):
|
||||
if info:
|
||||
status = info.get("status", None)
|
||||
if status == edp.JOB_ACTION_SUSPEND:
|
||||
api.OPS.job_execution_suspend(id)
|
||||
if status == edp.JOB_ACTION_CANCEL:
|
||||
api.OPS.cancel_job_execution(id)
|
||||
|
||||
|
||||
def delete_job_execution(id):
|
||||
|
@ -74,7 +74,7 @@ JOB_EXEC_UPDATE_SCHEMA = {
|
||||
"type": "simple_config",
|
||||
"properties": {
|
||||
"status": {
|
||||
"enum": ["suspend"]
|
||||
"enum": ["suspend", "cancel"]
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
|
@ -89,9 +89,11 @@ JOB_TYPES_ACCEPTABLE_CONFIGS = {
|
||||
|
||||
# job actions
|
||||
JOB_ACTION_SUSPEND = 'suspend'
|
||||
JOB_ACTION_CANCEL = 'cancel'
|
||||
|
||||
JOB_ACTION_TYPES_ACCEPTABLE = [
|
||||
JOB_ACTION_SUSPEND
|
||||
JOB_ACTION_SUSPEND,
|
||||
JOB_ACTION_CANCEL
|
||||
]
|
||||
|
||||
ADAPT_FOR_OOZIE = 'edp.java.adapt_for_oozie'
|
||||
|
Loading…
Reference in New Issue
Block a user