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

Issue #14396: checker-framework.yml should fail execution if report generation fails #14409

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

relentless-pursuit
Copy link

Resolve #14396

This PR enhances the GitHub Actions workflow for the Checker Framework by ensuring execution fails upon detecting errors during report generation.

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Items

BufferedReader reader = null
try {
reader = new BufferedReader(new InputStreamReader(process.inputStream))
String lineFromReader = reader.readLine()
while (lineFromReader != null) {
println(lineFromReader)
checkerFrameworkLines.add(lineFromReader)
if (lineFromReader.contains("OutOfMemoryError")) {
Copy link
Member

Choose a reason for hiding this comment

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

We need any error, can we make code general ?
Can we simply rely on mvn exit code?

Copy link
Author

Choose a reason for hiding this comment

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

Okay.

Copy link
Author

Choose a reason for hiding this comment

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

We need any error, can we make code general ? Can we simply rely on mvn exit code?

I am trying to throw an exception the moment it encounters a non-zero exit code, assuming a OOM detected. And, this probably might make the CI/CD to fail. Please let me know your thoughts on it.

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

I like this a way more

@relentless-pursuit
Copy link
Author

I like this a way more

how do we test such scenarios in our local?

@romani
Copy link
Member

romani commented Feb 4, 2024

You can update groovy to start mvn with low memory like -xmx 512mb please google exact syntax.

@relentless-pursuit
Copy link
Author

You can update groovy to start mvn with low memory like -xmx 512mb please google exact syntax.

Sure, thanks.

@relentless-pursuit
Copy link
Author

relentless-pursuit commented Feb 6, 2024

You can update groovy to start mvn with low memory like -xmx 512mb please google exact syntax.

@romani, @rnveach I tried with reducing the jvm heap size to check if the code i added was running fine. But, even at 128mb, i am not being able to simulate an OOM. The other way i tried was runing a infinite loop, the CI did hint towards a OOM, but, as obvious the lines of code I added to terminal the script wasn't executed. Any alternative or correction needed?

@relentless-pursuit relentless-pursuit force-pushed the checker-failure branch 3 times, most recently from 233b364 to e7fc6c0 Compare February 6, 2024 08:42
@relentless-pursuit
Copy link
Author

relentless-pursuit commented Feb 6, 2024

You can update groovy to start mvn with low memory like -xmx 512mb please google exact syntax.

@romani, @rnveach I tried with reducing the jvm heap size to check if the code i added was running fine. But, even at 128mb, i am not being able to simulate an OOM. The other way i tried was runing a infinite loop, the CI did hint towards a OOM, but, as obvious the lines of code I added to terminal the script wasn't executed. Any alternative or correction needed?

Even if I am failing to replicate OOM, but, atleast I am being able to register an exit status which I had introduced throwin a RunTimeException from the below logs. So, possibly this might also be the case when maven executions runs out of memory.

Caught: java.lang.RuntimeException: Maven process exited with error code: 1
java.lang.RuntimeException: Maven process exited with error code: 1

@romani
Copy link
Member

romani commented Feb 7, 2024

We bumped memory usage for maven to bypass this problem in CI, if we revert such commit we should be able reproduce problem in CI, but instead of weird failure of diff on suppression we should have failed step of report generation.

Commit revert might be too much, but revert of lines as 1a041e3#diff-9c5fb3d1b7e3b0f54bc5c4182965c4fe1f9023d449017cece3005d3f90e8e4d8L2938 should bring us back to CI problem to run Checker

@relentless-pursuit relentless-pursuit force-pushed the checker-failure branch 6 times, most recently from df4617b to fb75b89 Compare February 7, 2024 07:06
@relentless-pursuit relentless-pursuit force-pushed the checker-failure branch 4 times, most recently from adba322 to c77b498 Compare February 18, 2024 08:32
@relentless-pursuit
Copy link
Author

relentless-pursuit commented Feb 18, 2024

@nrmancuso, I have added the reports of before and after changes.

Without any changes to groovy file, we continue to get OOM but with some strange suppressions as reported previously

https://github.com/checkstyle/checkstyle/actions/runs/7947755703/job/21696975080?pr=14409

After groovy changes, we can handle the OOM properly

https://github.com/checkstyle/checkstyle/actions/runs/7947830206/job/21697133364?pr=14409

@relentless-pursuit
Copy link
Author

@relentless-pursuit before we drop commits, please do the following so that we can easily revisit and quickly understand what you've done here.

  1. Separate your changes here into three commits:

    • one with CI disablement
    • one with hack to cause failure
    • one with update to groovy script
  2. Place a link in the issue to the commit that has the hack to cause CI to fail, with a short description. It is likely that we might need such a hack in the future for something else.

  3. Please explain how your changes in the groovy script helped us, I do not see the Maven process exited with error code message in the output you've shared.

Thanks a lot for all the work on this.

Done.

@relentless-pursuit
Copy link
Author

relentless-pursuit commented Feb 18, 2024

3. Please explain how your changes in the groovy script helped us, I do not see the Maven process exited with error code message in the output you've shared.

Caught: java.lang.RuntimeException: Maven process exited with error code: 1
java.lang.RuntimeException: Maven process exited with error code: 1
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at checker-framework.getCheckerFrameworkErrors(checker-framework.groovy:132)
	at checker-framework.checkCheckerFrameworkReport(checker-framework.groovy:79)
	at checker-framework.parseArgumentAndExecute(checker-framework.groovy:34)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at checker-framework.run(checker-framework.groovy:17)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

<failOnError>false</failOnError>
<meminitial>1024m</meminitial>
<maxmem>8192m</maxmem>
<failOnError>true</failOnError>
Copy link
Member

Choose a reason for hiding this comment

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

How will the maven execution fail without this?

Copy link
Author

Choose a reason for hiding this comment

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

If I understood it right, the final commit must have the changes of groovy including failOnError be true for all checkers.

Copy link
Member

Choose a reason for hiding this comment

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

If I understood it right, the final commit must have the changes of groovy including failOnError be true for all checkers.

Yes, that’s right. Right now, we only have one updated, and it is in the “hack” to cause OOM commit.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the review. I have made the changes. Please let me know if they are right.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, let's drop other commits and prepare for merge.

Copy link
Member

@nrmancuso nrmancuso Feb 20, 2024

Choose a reason for hiding this comment

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

@relentless-pursuit codenarc is failing in semaphore:
Violation: Rule=ThrowRuntimeException P=2 Line=132 Msg=[The type RuntimeException should not be thrown] Src=[throw new RuntimeException("Maven process exited with error code: " + exitCode)]

Is there a specific reason to throw an exception here? Can we just System.exit(1)?

Copy link
Member

Choose a reason for hiding this comment

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

System.exit(1)

After thinking on this, this is a hack that we should probably avoid. I also have doubts about whether we would execute the finally block below this to close the reader. @relentless-pursuit let's keep it the way you had it and find a more specific exception class as recommended by codenarc: https://codenarc.org/codenarc-rules-exceptions.html#:~:text=Checks%20for%20throwing%20an%20instance%20of%20java.lang.RuntimeException.%20Throw%20an%20instance%20of%20a%20more%20specific%20exception%20subclass%20instead.

Copy link
Author

@relentless-pursuit relentless-pursuit Feb 20, 2024

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Let's do IllegalStateException

Copy link
Author

Choose a reason for hiding this comment

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

Let's do IllegalStateException

Done. I also checked with the hack, and it seems to be working fine. https://github.com/checkstyle/checkstyle/actions/runs/7974597699/job/21770876534?pr=14409

@relentless-pursuit relentless-pursuit force-pushed the checker-failure branch 10 times, most recently from 3417172 to 34b1b6f Compare February 20, 2024 13:54
….groovy to fail execution if report generation fails
@nrmancuso
Copy link
Member

@relentless-pursuit thanks for working on this, I know these sorts of issues can get pretty involved!

@relentless-pursuit
Copy link
Author

@relentless-pursuit thanks for working on this, I know these sorts of issues can get pretty involved!

Always happy to help Checkstyle. And, thanks to you and other maintainers for always being patient with the contributors like me.

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Ok to merge, elegant fix.

@romani romani assigned rnveach and unassigned romani Feb 20, 2024
@rnveach rnveach merged commit 3b29018 into checkstyle:master Feb 21, 2024
110 of 113 checks passed
@relentless-pursuit relentless-pursuit deleted the checker-failure branch May 27, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

checker-framework.yml should be able to fail execution if report generation is failed
4 participants