From afbd7e9c7d84d2da90a7fe726917af166e5cf9d3 Mon Sep 17 00:00:00 2001 From: gabriel-farache Date: Sun, 7 Jul 2024 09:40:49 +0200 Subject: [PATCH] MTA: Check mandatories incidents before reporting (#280) Signed-off-by: gabriel-farache --- mta-v6.x/application.properties | 2 +- mta-v6.x/specs/notifications.json | 4 +- mta-v7.x/application.properties | 4 +- mta-v7.x/argfile.conf | 4 ++ mta-v7.x/mta.svg | 2 +- mta-v7.x/mta.sw.yaml | 89 +++++++++++++++++++++++-- mta-v7.x/specs/mta.json | 48 ++++++++++--- mta-v7.x/specs/notifications.json | 5 -- shared/specs/notifications-openapi.yaml | 2 - 9 files changed, 131 insertions(+), 29 deletions(-) create mode 100644 mta-v7.x/argfile.conf diff --git a/mta-v6.x/application.properties b/mta-v6.x/application.properties index afba433e..95859670 100644 --- a/mta-v6.x/application.properties +++ b/mta-v6.x/application.properties @@ -1,5 +1,5 @@ quarkus.kogito.devservices.enabled=false -mta.url = ${MTA_URL:http://tackle-ui.my-konveyor-operator.svc.cluster.local:8080} +mta.url = ${MTA_URL:http://mta-ui.openshift-mta.svc.cluster.local:8080} quarkus.rest-client.mta_json.url = ${mta.url} quarkus.rest-client.notifications.url=${BACKSTAGE_NOTIFICATIONS_URL:http://backstage-backstage.rhdh-operator/api/notifications/} \ No newline at end of file diff --git a/mta-v6.x/specs/notifications.json b/mta-v6.x/specs/notifications.json index 878996d8..7861ce64 100644 --- a/mta-v6.x/specs/notifications.json +++ b/mta-v6.x/specs/notifications.json @@ -12,9 +12,7 @@ } ], "servers": [ - { - "url": "http://localhost:7007/api/notifications" - } + ], "paths": { "/notifications": { diff --git a/mta-v7.x/application.properties b/mta-v7.x/application.properties index afba433e..a4f7e4bf 100644 --- a/mta-v7.x/application.properties +++ b/mta-v7.x/application.properties @@ -1,5 +1,5 @@ quarkus.kogito.devservices.enabled=false -mta.url = ${MTA_URL:http://tackle-ui.my-konveyor-operator.svc.cluster.local:8080} +mta.url = ${MTA_URL:http://mta-ui.openshift-mta.svc.cluster.local:8080} quarkus.rest-client.mta_json.url = ${mta.url} -quarkus.rest-client.notifications.url=${BACKSTAGE_NOTIFICATIONS_URL:http://backstage-backstage.rhdh-operator/api/notifications/} \ No newline at end of file +quarkus.rest-client.notifications_json.url=${BACKSTAGE_NOTIFICATIONS_URL:http://backstage-backstage.rhdh-operator/api/notifications/} \ No newline at end of file diff --git a/mta-v7.x/argfile.conf b/mta-v7.x/argfile.conf new file mode 100644 index 00000000..663fe882 --- /dev/null +++ b/mta-v7.x/argfile.conf @@ -0,0 +1,4 @@ +BUILDER_IMAGE=brew.registry.redhat.io/rh-osbs/openshift-serverless-1-logic-swf-builder-rhel8@sha256:012439f21f964478225a459042f6e1dc14f63fdf4ae089c4ee5e613814682a27 +FLOW_NAME=MTA v7.x Serverless Workflow +FLOW_SUMMARY=MTA v7.x Serverless Workflow +FLOW_DESCRIPTION=MTA v7.x workflow consumes a source code repo and asses if it can be migrated diff --git a/mta-v7.x/mta.svg b/mta-v7.x/mta.svg index 4a196a28..21c75b19 100644 --- a/mta-v7.x/mta.svg +++ b/mta-v7.x/mta.svg @@ -1 +1 @@ -StartGetApplicationAppExistCreateApplicationCreateTaskgroupSubmitAnalysispollResultscheckReportDoneGetTrackersTrackersExistGetTrackerTrackerExistsGetTrackerProjectsTrackerProjectsExis t GetTrackerProjectTrackerProjectExistGetTrackerProjectIs sueTypes TrackerProjectIssue TypesExist GetMigrationWavesMigrationWavesExi st CreateMigrationWa ve GetJiraTicketsMigrationWaveJiraT icketExists CreateJiraNotifyCompletionreportEndNotifyFailureBackst age End(.taskgroup... (.taskgroup... (.trackers !... (.trackers !... (.tracker !... (.tracker !... (.trackerPro... (.trackerPro... (.trackerPro... (.trackerPro... (.trackerPro... (.trackerPro... (.migratio... (.migratio... (.migratio... (.migratio... (.migratio... (.migratio... (.migratio... (.migratio... (.taskgroup... (.taskgroup... (.taskgroup... (.taskgroup... (.taskgroup... (.taskgroup... .application ... .application ... \ No newline at end of file +StartGetApplicationAppExistCreateApplicationCreateTaskgroupSubmitAnalysispollResultscheckReportDoneGetApplicationAnal ysis CountMandatoriesI ncidents CountNonMandato riesIncidents CheckMandatoriesI ncidents GetTrackersTrackersExistGetTrackerTrackerExistsGetTrackerProjectsTrackerProjectsExis t GetTrackerProjectTrackerProjectExistGetTrackerProjectIs sueTypes TrackerProjectIssue TypesExist GetMigrationWavesMigrationWavesExi st CreateMigrationWa ve GetJiraTicketsMigrationWaveJiraT icketExists CreateJiraNotifyCompletionreportEndNotifyFailureBackst age EndNotifyMandatoriesIncidentsInApplicati on EndhasMandatorie... hasMandatorie... NotifyTracker NotifyTracker (.trackers != null) (.trackers != null) (.tracker != null) (.tracker != null) (.trackerProject... (.trackerProject... (.trackerProject ... (.trackerProject ... (.trackerProject... (.trackerProject... (.migrationWav... (.migrationWav... (.migrationWav... (.migrationWav... (.migrationWav... (.migrationWav... (.migrationWav... (.migrationWav... taskFailed taskFailed taskNotCompleted taskNotCompleted .application != ... .application != ... \ No newline at end of file diff --git a/mta-v7.x/mta.sw.yaml b/mta-v7.x/mta.sw.yaml index d3d2543b..d30a5475 100644 --- a/mta-v7.x/mta.sw.yaml +++ b/mta-v7.x/mta.sw.yaml @@ -18,6 +18,8 @@ functions: operation: "{application: .applications|map(select(.repository.url == .repositoryURL))[0]}" - name: getApplication operation: specs/mta.json#getApplications + - name: getApplicationAnalysis + operation: specs/mta.json#getApplicationAnalysis - name: createApplication operation: specs/mta.json#createApplication - name: createTaskgroup @@ -55,6 +57,13 @@ functions: - name: logInfo type: custom operation: "sysout:INFO" + - name: countMandatoriesIncidents + type: expression + operation: .applicationAnalysis | [select (.issues[].category=="mandatory")][0] | [.issues[]?.incidents //[]] | .[-1][-1].id + - name: countNonMandatoriesIncidents + type: expression + operation: .applicationAnalysis | [select (.issues[].category!="mandatory")][0] | [.issues[]?.incidents //[]] | .[-1][-1].id + states: - name: GetApplication type: operation @@ -164,14 +173,65 @@ states: - name: checkReportDone type: switch dataConditions: - - condition: (.taskgroup.state == "Ready" and (.taskgroup.tasks[0].state == "Running" or .taskgroup.tasks[0].state == "Pending")) + - condition: (.taskgroup.state == "Ready" and (.taskgroup.tasks[0].state == "Running" or (.taskgroup.tasks[0].state == "Pending" or .taskgroup.tasks[0].state == "Postponed"))) transition: pollResults - - condition: (.taskgroup.state == "Ready" and .exportToIssueManager == "true" and .taskgroup.tasks[0].state == "Succeeded") - transition: GetTrackers - - condition: (.taskgroup.state == "Ready" and .exportToIssueManager == "false" and .taskgroup.tasks[0].state == "Succeeded") - transition: NotifyCompletion + name: taskNotCompleted - condition: (.taskgroup.state == "Ready" and .taskgroup.tasks[0].state == "Failed") transition: NotifyFailureBackstage + name: taskFailed + defaultCondition: + transition: GetApplicationAnalysis + - name: GetApplicationAnalysis + type: operation + actionMode: sequential + actions: + - name: getApp + functionRef: + refName: getApplicationAnalysis + arguments: + id: .application.id + actionDataFilter: + toStateData: ".applicationAnalysis" + transition: CountMandatoriesIncidents + - name: CountMandatoriesIncidents + type: operation + actionMode: sequential + actions: + - name: countApplicationMandatoryIncident + actionDataFilter: + toStateData: .application.mandatoriesIncidents + functionRef: + refName: countMandatoriesIncidents + - name: "logMandatoriesIncidents" + functionRef: + refName: "logInfo" + arguments: + message: "\"Mandatory incidents: \\(.application.mandatoriesIncidents|tostring)\"" + transition: CountNonMandatoriesIncidents + - name: CountNonMandatoriesIncidents + type: operation + actionMode: sequential + actions: + - name: countApplicationNotMandatoryIncident + actionDataFilter: + 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 + dataConditions: + - condition: .application.mandatoriesIncidents > 0 + transition: NotifyMandatoriesIncidentsInApplication + name: hasMandatoriesIncidents + - condition: (.application.mandatoriesIncidents == 0 and .exportToIssueManager == "true") + transition: GetTrackers + name: NotifyTracker defaultCondition: transition: NotifyCompletion - name: GetTrackers @@ -359,7 +419,7 @@ states: refName: createNotification arguments: title: "MTA analysis completed" - message: '"MTA analysis is completed and the report for " + .application.repository.url + " is ready."' + message: '"MTA analysis is completed with " + (.application.nonMandatoriesIncidents|tostring) + " non-mandatory incidents and the report for " + .application.repository.url + " is ready."' origin: "MTA Analysis Workflow" topic: "MTA Analysis Workflow" targetUsers: if .backstageUser != null then [.backstageUser] else [] end @@ -386,4 +446,21 @@ states: topic: "MTA Analysis Workflow" targetUsers: if .backstageUser != null then [.backstageUser] else [] end targetGroups: if .backstageGroup != null then [.backstageGroup] else [] end + end: true + - name: NotifyMandatoriesIncidentsInApplication + type: operation + actions: + - condition: .backstageUser != null or .backstageGroup != null + functionRef: + refName: createNotification + arguments: + title: "MTA analysis ended with incidents in mandatories issues" + message: '"MTA analysis for " + .application.repository.url + " completed with " + (.application.mandatoriesIncidents|tostring) +" incidents in mandatories issues. Check the analysis report."' + origin: "MTA Analysis Workflow" + topic: "MTA Analysis Workflow" + targetUsers: if .backstageUser != null then [.backstageUser] else [] end + targetGroups: if .backstageGroup != null then [.backstageGroup] else [] end + actions: + - title: "View analysis report" + url: "$SECRET.mta.url + \"/applications/\" + (.application.id|tostring)+ \"/analysis\"" end: true \ No newline at end of file diff --git a/mta-v7.x/specs/mta.json b/mta-v7.x/specs/mta.json index 144c71a2..57a952bb 100644 --- a/mta-v7.x/specs/mta.json +++ b/mta-v7.x/specs/mta.json @@ -42,7 +42,7 @@ { "bearerAuth": [] } - ] + ] }, "post": { "operationId": "createMigrationwave", @@ -117,7 +117,7 @@ { "bearerAuth": [] } - ] + ] } }, "/hub/taskgroups/{id}/submit": { @@ -191,7 +191,7 @@ { "bearerAuth": [] } - ] + ] } }, "/hub/trackers/{id}": { @@ -298,7 +298,6 @@ ], "x-codegen-request-body-name": "application" } - }, "/hub/applications/{id}": { "get": { @@ -410,7 +409,39 @@ ] } }, - + "/hub/applications/{id}/analysis": { + "get": { + "tags": [ + "analyses" + ], + "operationId": "getApplicationAnalysis", + "summary": "Get the latest analysis.", + "description": "Get the latest analysis for an application.", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "Application ID", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "$ref": "#/components/schemas/api.Analysis" + } + } + } + } + } + } + }, "/hub/taskgroups": { "get": { "operationId": "getTaskgroups", @@ -513,7 +544,7 @@ { "bearerAuth": [] } - ] + ] }, "put": { "operationId": "updateTaskGroups", @@ -878,7 +909,6 @@ } } }, - "components": { "schemas": { "api.Addon": { @@ -2848,7 +2878,7 @@ } } } - }, + }, "securitySchemes": { "bearerAuth": { "type": "http", @@ -2858,4 +2888,4 @@ } }, "x-original-swagger-version": "2.0" -} +} \ No newline at end of file diff --git a/mta-v7.x/specs/notifications.json b/mta-v7.x/specs/notifications.json index 878996d8..ba19b665 100644 --- a/mta-v7.x/specs/notifications.json +++ b/mta-v7.x/specs/notifications.json @@ -11,11 +11,6 @@ "description": "notifications plugin" } ], - "servers": [ - { - "url": "http://localhost:7007/api/notifications" - } - ], "paths": { "/notifications": { "post": { diff --git a/shared/specs/notifications-openapi.yaml b/shared/specs/notifications-openapi.yaml index f3e72ee3..56d7729a 100644 --- a/shared/specs/notifications-openapi.yaml +++ b/shared/specs/notifications-openapi.yaml @@ -7,8 +7,6 @@ info: tags: - name: notifications description: notifications plugin -servers: - - url: http://localhost:7007/api/notifications paths: /: post: