Example #1
0
    def stop_interactive_session(self, interactive_session_id):
        """Stop an interactive workflow run."""
        int_session = InteractiveSession.query.filter_by(
            id_=interactive_session_id).first()

        if not int_session:
            raise REANAInteractiveSessionError(
                "Interactive session for workflow {} does not exist.".format(
                    self.workflow.name))
        action_completed = True
        try:
            delete_k8s_ingress_object(
                ingress_name=int_session.name,
                namespace=REANA_RUNTIME_KUBERNETES_NAMESPACE,
            )
        except Exception as e:
            action_completed = False
            raise REANAInteractiveSessionError(
                "Unkown error while stopping interactive session:\n{}".format(
                    e))
        finally:
            if action_completed:
                # TODO: once multiple sessions will be supported instead of
                # deleting a session, its status should be changed to "stopped"
                # int_session.status = RunStatus.stopped
                current_db_sessions = Session.object_session(self.workflow)
                current_db_sessions.delete(int_session)
                current_db_sessions.commit()
 def stop_interactive_session(self):
     """Stop an interactive workflow run."""
     delete_k8s_ingress_object(
         ingress_name=self.workflow.interactive_session_name,
         namespace=KubernetesWorkflowRunManager.default_namespace)
     self.workflow.interactive_session_name = None
     self.workflow.interactive_session = None
     current_db_sessions = Session.object_session(self.workflow)
     current_db_sessions.add(self.workflow)
     current_db_sessions.commit()