From 6f4c054295cfb00e81c5dbbec17426fb5c3c12d2 Mon Sep 17 00:00:00 2001 From: Jacky Zhang Date: Thu, 6 Jul 2023 11:41:05 -0400 Subject: [PATCH] Enable retrying failed/cancelled workflow runs --- .../js/Controllers/ControllerWorkflowRun.js | 20 +++++++++++++++++++ .../code/src/js/Shared/RODAN_EVENTS.js | 4 ++++ .../LayoutViewIndividualWorkflowRun.js | 13 ++++++++++-- .../template-main_workflowrun_individual.html | 3 +++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/rodan-client/code/src/js/Controllers/ControllerWorkflowRun.js b/rodan-client/code/src/js/Controllers/ControllerWorkflowRun.js index 90a08d6d3..67263e0a5 100644 --- a/rodan-client/code/src/js/Controllers/ControllerWorkflowRun.js +++ b/rodan-client/code/src/js/Controllers/ControllerWorkflowRun.js @@ -25,6 +25,7 @@ export default class ControllerWorkflowRun extends BaseController Radio.channel('rodan').on(RODAN_EVENTS.EVENT__WORKFLOWRUN_DELETED, options => this._handleEventWorkflowRunDeleteResponse(options)); Radio.channel('rodan').on(RODAN_EVENTS.EVENT__WORKFLOWRUN_SAVED, options => this._handleEventWorkflowRunSaveResponse(options)); Radio.channel('rodan').on(RODAN_EVENTS.EVENT__WORKFLOWRUN_STARTED, options => this._handleEventWorkflowRunStartResponse(options)); + Radio.channel('rodan').on(RODAN_EVENTS.EVENT__WORKFLOWRUN_RETRIED, options => this._handleEventWorkflowRunRetryResponse(options)); // Requests. Radio.channel('rodan').on(RODAN_EVENTS.EVENT__WORKFLOWRUN_SELECTED_COLLECTION, options => this._handleEventCollectionSelected(options), this); @@ -33,6 +34,7 @@ export default class ControllerWorkflowRun extends BaseController Radio.channel('rodan').reply(RODAN_EVENTS.REQUEST__WORKFLOWRUN_DELETE, options => this._handleRequestWorkflowRunDelete(options), this); Radio.channel('rodan').reply(RODAN_EVENTS.REQUEST__WORKFLOWRUN_SAVE, options => this._handleRequestWorkflowRunSave(options), this); Radio.channel('rodan').reply(RODAN_EVENTS.REQUEST__WORKFLOWRUN_START, options => this._handleRequestWorkflowRunStart(options), this); + Radio.channel('rodan').reply(RODAN_EVENTS.REQUEST__WORKFLOWRUN_RETRY, options => this._handleRequestWorkflowRunRetry(options), this); } /////////////////////////////////////////////////////////////////////////////////////// @@ -166,6 +168,13 @@ export default class ControllerWorkflowRun extends BaseController }); } + _handleEventWorkflowRunRetryResponse(options) + { + Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__MODAL_HIDE); + const project = Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__PROJECT_GET_ACTIVE); + Radio.channel('rodan').trigger(RODAN_EVENTS.EVENT__WORKFLOWRUN_SELECTED_COLLECTION, {project: project}); + } + /** * Handle request create WorkflowRun. */ @@ -214,6 +223,17 @@ export default class ControllerWorkflowRun extends BaseController {patch: true, success: (model) => Radio.channel('rodan').trigger(RODAN_EVENTS.EVENT__WORKFLOWRUN_STARTED, {workflowrun: model})}); } + /** + * Handle request retry WorkflowRun. + */ + _handleRequestWorkflowRunRetry(options) + { + Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__MODAL_SHOW_IMPORTANT, {title: 'Restarting Workflow Run', content: 'Please wait...'}); + options.workflowrun.set({status: 31}); + options.workflowrun.save(options.workflowrun.changed, + {patch: true, success: (model) => Radio.channel('rodan').trigger(RODAN_EVENTS.EVENT__WORKFLOWRUN_RETRIED, {workflowrun: model})}); + } + /////////////////////////////////////////////////////////////////////////////////////// // PRIVATE METHODS /////////////////////////////////////////////////////////////////////////////////////// diff --git a/rodan-client/code/src/js/Shared/RODAN_EVENTS.js b/rodan-client/code/src/js/Shared/RODAN_EVENTS.js index 0381edb26..29af4f04b 100644 --- a/rodan-client/code/src/js/Shared/RODAN_EVENTS.js +++ b/rodan-client/code/src/js/Shared/RODAN_EVENTS.js @@ -512,6 +512,8 @@ class RODAN_EVENTS this.EVENT__WORKFLOWRUN_SAVED = 'EVENT__WORKFLOWRUN_SAVED'; /** Triggered when WorkflowRun started. Sends {workflowrun: WorkflowRun}. */ this.EVENT__WORKFLOWRUN_STARTED = 'EVENT__WORKFLOWRUN_STARTED'; + /** Triggered when WorkflowRun retried. Sends {workflowrun: WorkflowRun}. */ + this.EVENT__WORKFLOWRUN_RETRIED = 'EVENT__WORKFLOWRUN_RETRIED'; /** Triggered when the user selects an individual WorkflowRun. Sends {workflow: WorkflowRun}. */ this.EVENT__WORKFLOWRUN_SELECTED = 'EVENT__WORKFLOWRUN_SELECTED'; /** Triggered when the user selects to see all available WorkflowRuns. Sends {project: Project (Project associated with WorkflowRunCollection)}. */ @@ -524,6 +526,8 @@ class RODAN_EVENTS this.REQUEST__WORKFLOWRUN_SAVE = 'REQUEST__WORKFLOWRUN_SAVE'; /** Request a WorkflowRun be started. Takes {model: WorkflowRun}. */ this.REQUEST__WORKFLOWRUN_START = 'REQUEST__WORKFLOWRUN_START'; + /** Request a failed or cancelled WorkflowRun be retried. Takes {model: WorkflowRun}. */ + this.REQUEST__WORKFLOWRUN_RETRY = 'REQUEST__WORKFLOWRUN_RETRY'; /////////////////////////////////////////////////////////////////////////////////////// // VERSION COMPATIBILITY CHECKS diff --git a/rodan-client/code/src/js/Views/Master/Main/WorkflowRun/Individual/LayoutViewIndividualWorkflowRun.js b/rodan-client/code/src/js/Views/Master/Main/WorkflowRun/Individual/LayoutViewIndividualWorkflowRun.js index 62e7e40b3..60e2dbb91 100644 --- a/rodan-client/code/src/js/Views/Master/Main/WorkflowRun/Individual/LayoutViewIndividualWorkflowRun.js +++ b/rodan-client/code/src/js/Views/Master/Main/WorkflowRun/Individual/LayoutViewIndividualWorkflowRun.js @@ -115,6 +115,14 @@ export default class LayoutViewIndividualWorkflowRun extends Marionette.View { Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__WORKFLOWRUN_DELETE, {workflowrun: this.model}); } + + /** + * Handle retry button. + */ + _handleButtonRetry() + { + Radio.channel('rodan').request(RODAN_EVENTS.REQUEST__WORKFLOWRUN_RETRY, {workflowrun: this.model}); + } } LayoutViewIndividualWorkflowRun.prototype.modelEvents = { 'all': 'render' @@ -124,6 +132,7 @@ LayoutViewIndividualWorkflowRun.prototype.ui = { buttonShowRunJobs: '#button-runjobs_show', buttonSave: '#button-save_workflowrun', buttonDelete: '#button-delete_workflowrun', + buttonRetry: '#button-retry_workflowrun', textName: '#text-workflowrun_name', textDescription: '#text-workflowrun_description' }; @@ -131,7 +140,7 @@ LayoutViewIndividualWorkflowRun.prototype.events = { 'click @ui.buttonShowResources': '_showResources', 'click @ui.buttonShowRunJobs': '_showRunJobs', 'click @ui.buttonSave': '_handleButtonSave', - 'click @ui.buttonDelete': '_handleButtonDelete' - + 'click @ui.buttonDelete': '_handleButtonDelete', + 'click @ui.buttonRetry': '_handleButtonRetry', }; LayoutViewIndividualWorkflowRun.prototype.template = _.template($('#template-main_workflowrun_individual').text()); diff --git a/rodan-client/code/templates/Views/Master/Main/WorkflowRun/Individual/template-main_workflowrun_individual.html b/rodan-client/code/templates/Views/Master/Main/WorkflowRun/Individual/template-main_workflowrun_individual.html index c8a903ed5..2a2d67f5b 100644 --- a/rodan-client/code/templates/Views/Master/Main/WorkflowRun/Individual/template-main_workflowrun_individual.html +++ b/rodan-client/code/templates/Views/Master/Main/WorkflowRun/Individual/template-main_workflowrun_individual.html @@ -10,6 +10,9 @@

Workflow Run

Updated on: <%= _.formatFromUTC(updated) %>
URL: <%= url %>
Status: <%= statusText %>
+ <% if (status === -1 || status === 9) { %> + + <% } %>