diff --git a/workflows/mta-v7.x/mta.svg b/workflows/mta-v7.x/mta.svg index 44465c8e..c4aeb1e0 100644 --- a/workflows/mta-v7.x/mta.svg +++ b/workflows/mta-v7.x/mta.svg @@ -1 +1 @@ -StartCreateApplicationCreateTaskgroupSubmitAnalysispollResultscheckReportDoneTaskFailedErrorGetApplicationAnal ysis CountMandatoriesI ncidents CountNonMandato riesIncidents CheckMandatoriesI ncidents GetTrackersTrackersExistTrackersDoesNotEx istError GetTrackerTrackerExistsTrackerDoesNotExi stError GetTrackerProjectsTrackerProjectsExis t TrackerProjectsDoe sNotExistError GetTrackerProjectTrackerProjectExistTrackerProjectDoes NotExistError GetTrackerProjectIs sueTypes TrackerProjectIssue TypesExist TrackerProjectIssueTypesDoesNotExist Error CreateMigrationWa ve CreateJiraCheckMandatoriesI ncidentsAfterIssueC reation NotifyCompletionreportCompletionEndNotifyMandatoriesIncidentsInApplicati on reportCompletionWithMandatoriesIncid entsInApplication EndNotifyFailureBackst age reportFailureEndhasMandatorie... hasMandatorie... NotifyTracker NotifyTracker (.trackers != null) (.trackers != null) (.tracker != null) (.tracker != null) (.trackerProject... (.trackerProject... (.trackerProject ... (.trackerProject ... (.trackerProject... (.trackerProject... hasMandatorie... hasMandatorie... taskFailed taskFailed taskNotCompleted taskNotCompleted \ No newline at end of file +StartCreateApplicationCreateTaskgroupSubmitAnalysispollResultscheckReportDoneTaskFailedErrorGetApplicationAnal ysis CountMandatoriesI ncidents CountNonMandato riesIncidents CheckMandatoriesI ncidents GetTrackersTrackersExistTrackersDoesNotEx istError GetTrackerTrackerExistsTrackerDoesNotExi stError GetTrackerProjectsTrackerProjectsExis t TrackerProjectsDoe sNotExistError GetTrackerProjectTrackerProjectExistTrackerProjectDoes NotExistError GetTrackerProjectIs sueTypes TrackerProjectIssue TypesExist TrackerProjectIssueTypesDoesNotExist Error CreateMigrationWa ve CreateJiraCheckMandatoriesI ncidentsAfterIssueC reation NotifyCompletionEndNotifyMandatoriesIncidentsInApplicati on EndNotifyFailureBackst age reportFailureEndCancelTaskAborthasMandatorie... hasMandatorie... NotifyTracker NotifyTracker (.trackers != null) (.trackers != null) (.tracker != null) (.tracker != null) (.trackerProject... (.trackerProject... (.trackerProject ... (.trackerProject ... (.trackerProject... (.trackerProject... hasMandatorie... hasMandatorie... taskFailed taskFailed taskNotCompleted taskNotCompleted \ No newline at end of file diff --git a/workflows/mta-v7.x/mta.sw.yaml b/workflows/mta-v7.x/mta.sw.yaml index 135bf91a..497b0208 100644 --- a/workflows/mta-v7.x/mta.sw.yaml +++ b/workflows/mta-v7.x/mta.sw.yaml @@ -22,6 +22,8 @@ functions: - name: filterApplication type: expression operation: "{application: .applications|map(select(.repository.url == .repositoryURL))[0]}" + - name: deleteTaskGroup + operation: specs/mta.json#deleteTaskGroup - name: getApplication operation: specs/mta.json#getApplications - name: getApplicationAnalysis @@ -102,50 +104,65 @@ functions: - name: successResult type: expression operation: '{ - "completedWith":"success", - "message": "MTA v7.x analysis completed for " + .repositoryURL, - "outputs":[ - { - "key":"MTA Analysis Result URL", - "value": $SECRET.mta.url + "/hub/applications/" + (.application.id|tostring) + "/analysis/report", - "format":"link" - }, - { - "key":"Migration Wave Ticket URL", - "value": (if .migrationWaveJiraTicket != null then .migrationWaveJiraTicket.link else "" end), - "format":"link" - } - ], - "nextWorkflows":[ - { - "id":"m2k", - "name":"Move2Kube workflow" - } - ] + result: { + completedWith:"success", + message: "MTA v7.x analysis completed for " + .repositoryURL, + outputs:[ + { + key:"MTA Analysis Result URL", + value: $SECRET.mta.url + "/hub/applications/" + (.application.id|tostring) + "/analysis/report", + format:"link" + }, + { + key:"Migration Wave Ticket URL", + value: (if .migrationWaveJiraTicket != null then .migrationWaveJiraTicket.link else "" end), + format:"link" + } + ], + nextWorkflows:[ + { + id:"m2k", + name:"Move2Kube workflow" + } + ] + } }' - name: mandatoriesIncidentsResult type: expression operation: '{ - "completedWith": "warning", - "message": "MTA analysis for " + .application.repository.url + " completed with " + (.application.mandatoriesIncidents|tostring) + " incidents in mandatory issues that need to be fixed before being able to provide any next possible workflow. Check the analysis report." + (if .migrationWaveJiraTicket != null then " Application was exported to issue manager." else "" end), - "outputs": [ - { - "key":"MTA Analysis Result URL", - "value": ($SECRET.mta.url + "/hub/applications/" + (.application.id|tostring) + "/analysis/report"), - "format": "link" - }, - { - "key":"Migration Wave Ticket URL", - "value": (if .migrationWaveJiraTicket != null then .migrationWaveJiraTicket.link else "" end), - "format": "link" - } - ] + result: { + completedWith: "warning", + message: "MTA analysis for " + .application.repository.url + " completed with " + (.application.mandatoriesIncidents|tostring) + " incidents in mandatory issues that need to be fixed before being able to provide any next possible workflow. Check the analysis report." + (if .migrationWaveJiraTicket != null then " Application was exported to issue manager." else "" end), + outputs: [ + { + key:"MTA Analysis Result URL", + value: ($SECRET.mta.url + "/hub/applications/" + (.application.id|tostring) + "/analysis/report"), + format: "link" + }, + { + key:"Migration Wave Ticket URL", + value: (if .migrationWaveJiraTicket != null then .migrationWaveJiraTicket.link else "" end), + format: "link" + } + ] + } }' - name: errorResult type: expression operation: '{ - "completedWith":"error", - "message": "MTA analysis for " + .application.repository.url + " failed: " + .exitMessage + ". Check logs of task pod: " + .taskgroup.tasks[0].pod + result: { + completedWith:"error", + message: "MTA analysis for " + .application.repository.url + " failed: " + .exitMessage + ". Check logs of task pod: " + .taskgroup.tasks[0].pod + } + }' + + - name: abortResult + type: expression + operation: '{ + result: { + completedWith:"aborted", + message: "MTA analysis for " + .application.repository.url + " aborted, all in progress tasks were cancelled." + } }' states: @@ -191,6 +208,7 @@ states: - name: SubmitAnalysis type: operation actionMode: sequential + compensatedBy: CancelTaskAbort actions: - name: submitTaskgroup functionRef: @@ -213,15 +231,9 @@ states: transition: pollResults - name: pollResults type: operation + compensatedBy: CancelTaskAbort actionMode: sequential actions: - - name: "SleepBeforeChecking" - functionRef: - refName: "logInfo" - arguments: - message: '"Sleeping before checking the analysis result "' - sleep: - after: PT30S - name: "getTaskgroup" functionRef: refName: getTaskgroup @@ -229,13 +241,11 @@ states: id: ".taskgroup.id" actionDataFilter: toStateData: .taskgroup - - name: "logTaskGroup" - functionRef: - refName: "logInfo" - arguments: - message: "\"Logging data: \\(.)\"" + sleep: + before: PT30S transition: checkReportDone - name: checkReportDone + compensatedBy: CancelTaskAbort type: switch dataConditions: - condition: (.taskgroup.state == "Ready" and (.taskgroup.tasks[0].state == "Running" or (.taskgroup.tasks[0].state == "Pending" or .taskgroup.tasks[0].state == "Postponed"))) @@ -273,11 +283,6 @@ states: toStateData: .application.mandatoriesIncidents functionRef: refName: countMandatoriesIncidents - - name: "logMandatoriesIncidents" - functionRef: - refName: "logInfo" - arguments: - message: "\"Mandatory incidents: \\(.application.mandatoriesIncidents|tostring)\"" transition: CountNonMandatoriesIncidents - name: CountNonMandatoriesIncidents type: operation @@ -288,11 +293,6 @@ states: toStateData: .application.nonMandatoriesIncidents functionRef: refName: countNonMandatoriesIncidents - - name: "logNonMandatoriesIncidents" - functionRef: - refName: "logInfo" - arguments: - message: "\"Non-mandatory incidents: \\(.application.nonMandatoriesIncidents|tostring)\"" transition: CheckMandatoriesIncidents - name: CheckMandatoriesIncidents type: switch @@ -444,11 +444,6 @@ states: type: operation actionMode: sequential actions: - - name: logInfo - functionRef: - refName: "logInfo" - arguments: - message: "\"Logging data: \\(.)\"" - name: "CreateTickets" functionRef: refName: createTicket @@ -496,18 +491,9 @@ states: topic: "MTA Analysis Workflow" link: '$SECRET.mta.url + "/hub/applications/" + (.application.id|tostring) + "/analysis/report"' severity: "normal" - transition: reportCompletion - - name: reportCompletion - type: operation - actionMode: sequential - actions: - name: reportCompletion functionRef: refName: successResult - actionDataFilter: - toStateData: ".result" - stateDataFilter: - output: ". += .result" end: true - name: NotifyMandatoriesIncidentsInApplication type: operation @@ -524,17 +510,9 @@ states: topic: "MTA Analysis Workflow" link: '$SECRET.mta.url + "/hub/applications/" + (.application.id|tostring) + "/analysis/report"' severity: "high" - transition: reportCompletionWithMandatoriesIncidentsInApplication - - name: reportCompletionWithMandatoriesIncidentsInApplication - type: operation - actions: - name: reportCompletionWithMandatoriesIncidentsInApplication functionRef: refName: mandatoriesIncidentsResult - actionDataFilter: - toStateData: ".result" - stateDataFilter: - output: ". += .result" end: true - name: NotifyFailureBackstage type: operation @@ -559,8 +537,33 @@ states: - name: reportFailure functionRef: refName: errorResult - actionDataFilter: - toStateData: ".result" - stateDataFilter: - output: ". += .result" end: true + - name: CancelTaskAbort + type: operation + usedForCompensation: true + actions: + - name: logInfo + functionRef: + refName: logInfo + arguments: + message: '${"MTA workflow: " + $WORKFLOW.instanceId + " was aborted while task was still in progress}"' + - name: "abortTasks" + functionRef: + refName: deleteTaskGroup + arguments: + id: ".taskgroup.id" + - name: createNotification + functionRef: + refName: createNotification + arguments: + recipients: + type: "entity" + entityRef: .recipients + payload: + title: "MTA analysis aborted" + description: '"MTA analysis for " + .application.repository.url + " aborted while tasks still in progress, tasks were cancelled"' + topic: "MTA Analysis Workflow" + severity: "critical" + - name: reportAbort + functionRef: + refName: abortResult diff --git a/workflows/shared/schemas/workflow-result-schema.json b/workflows/shared/schemas/workflow-result-schema.json index f2e91416..226bf09e 100644 --- a/workflows/shared/schemas/workflow-result-schema.json +++ b/workflows/shared/schemas/workflow-result-schema.json @@ -10,7 +10,8 @@ "enum": [ "error", "success", - "warning" + "warning", + "aborted" ] }, "message": {