Skip to content

Commit

Permalink
MTA: Check mandatories incidents before reporting
Browse files Browse the repository at this point in the history
Signed-off-by: gabriel-farache <[email protected]>
  • Loading branch information
gabriel-farache committed Jul 1, 2024
1 parent 36196d2 commit 5794a80
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 28 deletions.
2 changes: 1 addition & 1 deletion mta-v6.x/application.properties
Original file line number Diff line number Diff line change
@@ -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/}
4 changes: 1 addition & 3 deletions mta-v6.x/specs/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
}
],
"servers": [
{
"url": "http://localhost:7007/api/notifications"
}

],
"paths": {
"/notifications": {
Expand Down
4 changes: 2 additions & 2 deletions mta-v7.x/application.properties
Original file line number Diff line number Diff line change
@@ -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/}
quarkus.rest-client.notifications_json.url=${BACKSTAGE_NOTIFICATIONS_URL:http://backstage-backstage.rhdh-operator/api/notifications/}
4 changes: 4 additions & 0 deletions mta-v7.x/argfile.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BUILDER_IMAGE=brew.registry.redhat.io/rh-osbs/openshift-serverless-1-logic-swf-builder-rhel8@sha256:012439f21f964478225a459042f6e1dc14f63fdf4ae089c4ee5e613814682a27
FLOW_NAME=MTA Serverless Workflow
FLOW_SUMMARY=MTA Serverless Workflow
FLOW_DESCRIPTION=MTA workflow consumes a source code repo and asses if it can be migrated
2 changes: 1 addition & 1 deletion mta-v7.x/mta.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 88 additions & 5 deletions mta-v7.x/mta.sw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,6 +57,14 @@ functions:
- name: logInfo
type: custom
operation: "sysout:INFO"
- name: countMandatoriesIncidents
type: expression
operation: .applicationAnalysis | [select (.issues[].category!="mandatory")][0] | [.issues[]?.incidents //[]] | .[-1][-1].id
# cat anal.json | jq '. | [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
Expand Down Expand Up @@ -166,12 +176,68 @@ states:
dataConditions:
- condition: (.taskgroup.state == "Ready" and (.taskgroup.tasks[0].state == "Running" or .taskgroup.tasks[0].state == "Pending"))
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"
- name: "logApplicationAnalysis"
functionRef:
refName: "logInfo"
arguments:
message: "\"Application analysis: \\(.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
Expand Down Expand Up @@ -359,7 +425,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 mandatories 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
Expand All @@ -386,4 +452,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
48 changes: 39 additions & 9 deletions mta-v7.x/specs/mta.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{
"bearerAuth": []
}
]
]
},
"post": {
"operationId": "createMigrationwave",
Expand Down Expand Up @@ -117,7 +117,7 @@
{
"bearerAuth": []
}
]
]
}
},
"/hub/taskgroups/{id}/submit": {
Expand Down Expand Up @@ -191,7 +191,7 @@
{
"bearerAuth": []
}
]
]
}
},
"/hub/trackers/{id}": {
Expand Down Expand Up @@ -298,7 +298,6 @@
],
"x-codegen-request-body-name": "application"
}

},
"/hub/applications/{id}": {
"get": {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -513,7 +544,7 @@
{
"bearerAuth": []
}
]
]
},
"put": {
"operationId": "updateTaskGroups",
Expand Down Expand Up @@ -878,7 +909,6 @@
}
}
},

"components": {
"schemas": {
"api.Addon": {
Expand Down Expand Up @@ -2848,7 +2878,7 @@
}
}
}
},
},
"securitySchemes": {
"bearerAuth": {
"type": "http",
Expand All @@ -2858,4 +2888,4 @@
}
},
"x-original-swagger-version": "2.0"
}
}
5 changes: 0 additions & 5 deletions mta-v7.x/specs/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
"description": "notifications plugin"
}
],
"servers": [
{
"url": "http://localhost:7007/api/notifications"
}
],
"paths": {
"/notifications": {
"post": {
Expand Down
2 changes: 0 additions & 2 deletions shared/specs/notifications-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ info:
tags:
- name: notifications
description: notifications plugin
servers:
- url: http://localhost:7007/api/notifications
paths:
/:
post:
Expand Down

0 comments on commit 5794a80

Please sign in to comment.