Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

MTA Assessment WF #354

Merged

Conversation

rgolangh
Copy link
Contributor

@rgolangh rgolangh commented May 18, 2023

MTA Assessment Workflow

This is an assessment workflow that is based on the Migration Analysis
infra workflow.
The main difference is that the checker of that workflow downloads the
html report and tries to extract a table of scores of issues found by
the analysis. The ProcessAnalysisTask has a predicate passed in the
constructor to test against the scores of the analysis and based on that
the task returns the passOption or the defaultOption. The passOption is
the next flow to invoke, that should be the move2kube.

The flow is roughly:

Start
  -
Infra flow start
  -
submit analysis report
  -
End

Start
  -
Checker flow start
  -
check report is ready
  -
switch (is ready?)
  yes -> go to parse
  no  -> go to check report is ready
  -
parse
  -
switch (match incidents on predicate)
  true - return pass option (move2kube)
  false - return default option
  -
End

@openshift-ci openshift-ci bot requested review from nirarg and pkliczewski May 18, 2023 16:38
@rgolangh rgolangh changed the title mta assessment wf WIP: mta assessment wf May 18, 2023
@rgolangh rgolangh force-pushed the mta-assessment-wf branch from 3598775 to d8c74ed Compare May 31, 2023 09:29
@rgolangh rgolangh force-pushed the mta-assessment-wf branch 3 times, most recently from 24e0127 to ee17910 Compare June 2, 2023 13:21
@rgolangh rgolangh changed the title WIP: mta assessment wf MTA Assessment WF Jun 2, 2023
@rgolangh rgolangh force-pushed the mta-assessment-wf branch from ee17910 to 2c137ed Compare June 2, 2023 13:24
.prettierrc.json Outdated Show resolved Hide resolved
// this is the "migration issues" section from report from url.It assumed to be in
// HTML format. In version 6.1 of MTA it can be
// downloaded as csv and would be simpler to process, hopefully.
URI uri = URI.create(reportURL).resolve("reports");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be "report"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually needed to add a / in the end. but it works

return new DefaultWorkReport(WorkStatus.FAILED, workContext,
new Exception("failed to parse report index. Missing reports/report_index_*"));
}
String migrationIssuesReport = downloadReport(uri.resolve(reportLinks.get(0).text()));
Copy link
Contributor

@RichardW98 RichardW98 Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reportLinks.get(0) is <a href="reports/report_index_demo.html" style="float: left; margin-right: 5px; margin-top: 6px;"> *** </a>, I think we only want "reports/report_index_demo.html"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like mentioned on chat - I dropped the html rendering in favour of parsing the javascript data. all this code is gone now

}

@Bean(name = "AnalyzeApplicationAssessment")
@Assessment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should repoUrl and appName parameters be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I set them as workflow level params

@pkliczewski
Copy link
Collaborator

@rgolangh can we please finalize the PR this week?

@rgolangh rgolangh force-pushed the mta-assessment-wf branch from 2c137ed to 22a78fd Compare June 6, 2023 07:23
@rgolangh rgolangh force-pushed the mta-assessment-wf branch 2 times, most recently from d58e4cd to 134913f Compare June 6, 2023 16:43
Signed-off-by: Roy Golan <rgolan@redhat.com>
request.setMessageType("text");
request.setBody("Report URL: " + reportURL);
request.subject("Migration Analysis Report Completed");
request.setUsernames(List.of("test"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be the user that invoked the workflow instead of the default "test" value?
can be obtained by SecurityUtils.getUsername()

prettierrc.json Outdated
@@ -0,0 +1 @@
{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this file used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is a reminder to me that I didn't git ignore that yet!


@Configuration
@Profile("local")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason to state a profile as part of the workflow-definition?

@@ -76,15 +78,24 @@ WorkFlowOption notSupportOption() {
.setDescription("Non-Supported Workflow Steps").build();
}

@Bean
WorkFlowOption analyzeOption() {
return new WorkFlowOption.Builder("analyzeOption", "AnalyzeApplicationAssessment")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to suggest adding a class named AnalysysConstants or MTAConstants that will list the constants used here and reduces the chances of misspelling the keys.
We don't have such a convention yet, but we have that as part of Move2kube and I find it useful.

public class MTAAnalysisReport {

/**
* migrationIssuesReport is assumed to be valid html. MTA 6.1 should supply a CSV as
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment refers to migrationIssuesReport but it is nowhere to be found in this PR.
could you update the comment and perhaps use javadoc style?

@@ -81,12 +71,16 @@ public SubmitAnalysisTask submitAnalysisTask(WorkFlow fetchReportURL) {
}

@Bean
public GetAnalysisTask getAnalysisTask() {
return new GetAnalysisTask(URI.create(mtaUrl), "", messageConsumer());
public GetAnalysisTask getAnalysisTask(Notifier notifier) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+100 for the Notifier. much more elegant and reusable.

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import static com.redhat.parodos.workflows.workflow.SequentialFlow.Builder.aNewSequentialFlow;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no static imports should be allowed in the code. weird the checkstyle didn't fail for it.
it should be allowed only in tests (unless workflow-examples are excluded).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/spring-projects/spring-framework/wiki/Code-Style#import-statements

Static imports should not be used in production code, but they should be used in test code, especially for things like import static org.assertj.core.api.Assertions.assertThat;.

workflow-example is considered to be production code

* An assessment workflow to analyze applications using Migration Toolkit for Applications
* and return a move2kube option when needed.
* <p>
* This workflow will: - create an application with a name, and git repo URL - submit an
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps use

    tags to split into bullets to improve readability?

}

@Bean("fetchReportURL")
@Checker(cronExpression = "*/5 * * * * ?")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 5s reasonable or should be a higher value?

public WorkReport execute(WorkContext workContext) {
String reportURL;
try {
reportURL = getRequiredParameterValue("reportURL") + "/";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a need to check the URL isn't already terminated by "/" ?

@rgolangh rgolangh force-pushed the mta-assessment-wf branch from 134913f to 287a7ce Compare June 6, 2023 19:00
This is an assessment workflow which is based on the Migration Analysis
infra workflow.
The main differne is that the checker of that workflow downloads the
html report and tries to extract a table of scores of issues found by
the analysis. The ProcessAnalysisTask has a predicate passed in the
constructor to test against the scores of the analysis and based on that
the task returns the passOption or the defaultOption. The passOption is
the next flow to invoke, that should be the move2kube.

The flow is roughly:

Start
  -
Infra flow start
  -
submit analysis report
  -
End

Start
  -
Checker flow start
  -
check report is ready
  -
switch (is ready?)
  yes -> go to parse
  no  -> go to check report is ready
  -
parse
  -
switch (match incidents on predicate)
  true - return pass option (move2kube)
  false - return default option
  -
End

Signed-off-by: Roy Golan <rgolan@redhat.com>
@rgolangh rgolangh force-pushed the mta-assessment-wf branch from 287a7ce to e67fa39 Compare June 6, 2023 19:11
@openshift-ci
Copy link

openshift-ci bot commented Jun 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RichardW98

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Jun 6, 2023
@openshift-ci
Copy link

openshift-ci bot commented Jun 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RichardW98

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@RichardW98 RichardW98 added the lgtm label Jun 6, 2023
@openshift-merge-robot openshift-merge-robot merged commit 222c5e9 into rhdhorchestrator:main Jun 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants