diff --git a/sahara/service/edp/job_manager.py b/sahara/service/edp/job_manager.py index 0a8418b9..a2238af9 100644 --- a/sahara/service/edp/job_manager.py +++ b/sahara/service/edp/job_manager.py @@ -189,9 +189,12 @@ def get_job_status(job_execution_id): return job_execution -def update_job_statuses(): +def update_job_statuses(cluster_id=None): ctx = context.ctx() - for je in conductor.job_execution_get_all(ctx, end_time=None): + kwargs = {'end_time': None} + if cluster_id: + kwargs.update({'cluster_id': cluster_id}) + for je in conductor.job_execution_get_all(ctx, **kwargs): try: get_job_status(je.id) except Exception as e: diff --git a/sahara/service/ops.py b/sahara/service/ops.py index a674f92c..9cc6b45d 100644 --- a/sahara/service/ops.py +++ b/sahara/service/ops.py @@ -305,6 +305,7 @@ def _provision_scaled_cluster(cluster_id, node_group_id_map): _("Terminating cluster failed for the following reason(s): {reason}")) def terminate_cluster(cluster_id): ctx = context.ctx() + job_manager.update_job_statuses(cluster_id=cluster_id) cluster = conductor.cluster_get(ctx, cluster_id) plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name)