Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MTA-2041: send err to analysis command #149

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,10 @@ func NewAnalyzeCmd(log logr.Logger) *cobra.Command {
}
xmlOutputDir, err := analyzeCmd.ConvertXML(cmd.Context())
if err != nil {
log.Error(err, "failed to convert xml rules")
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like error comes out empty everytime because the analyzer command is not producing any output to stderr. I am wondering whether we should fix that in analyzer-lsp and not remove these lines.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will take a look there

Copy link
Contributor

Choose a reason for hiding this comment

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

it might be worth adding a flag, that can say print to stderr on failure for all of the commands (shim/lsp/dep).

Copy link
Collaborator Author

@eemcmullan eemcmullan Jan 25, 2024

Choose a reason for hiding this comment

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

The issue is that without sending the error to stderr, the error on output is blank like so:

ERRO[0042] container run error                           error="exit status 1"
Error:

Instead of a flag, maybe we need to force this? Is this something we want to close here and open as an issue in analyzer? @pranavgaikwad @shawn-hurley

return err
}
err = analyzeCmd.RunAnalysis(cmd.Context(), xmlOutputDir)
if err != nil {
log.Error(err, "failed to run analysis")
return err
}
err = analyzeCmd.CreateJSONOutput()
Expand Down Expand Up @@ -749,7 +747,7 @@ func (a *analyzeCommand) RunAnalysis(ctx context.Context, xmlOutputDir string) e
WithCleanup(a.cleanup),
)
if err != nil {
return err
return fmt.Errorf("error running analysis - see analysis log %v", analysisLogFilePath)
}

a.log.Info("running dependency analysis",
Expand All @@ -768,7 +766,7 @@ func (a *analyzeCommand) RunAnalysis(ctx context.Context, xmlOutputDir string) e
WithCleanup(a.cleanup),
)
if err != nil {
return err
return fmt.Errorf("error running dependency analysis - see dependency log %v", depsLogFilePath)
}

return nil
Expand Down Expand Up @@ -1035,7 +1033,7 @@ func (a *analyzeCommand) ConvertXML(ctx context.Context) (string, error) {
WithCleanup(a.cleanup),
)
if err != nil {
return "", err
return "", fmt.Errorf("error running windup shim - see shim log %v", shimLogPath)
}

return tempOutputDir, nil
Expand Down
3 changes: 1 addition & 2 deletions cmd/shimconvert.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ func (w *windupShimCommand) Run(ctx context.Context) error {
WithCleanup(w.cleanup),
)
if err != nil {
w.log.V(1).Error(err, "failed to run convert command")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above

return err
return fmt.Errorf("error running windup shim - see shim log %v", shimLogPath)
}
return nil
}
Loading