amino-os / Amino.Run

Amino Distributed OS - Runtime Manager
Apache License 2.0
29 stars 12 forks source link

Gradle examples:run reports success on failure #799

Closed quinton-hoole closed 5 years ago

quinton-hoole commented 5 years ago

See details below, in particular note the following:

Task :examples:hanksTodo:runapp FAILED

FAILURE: Build failed with an exception.

... but then, magic happens! ...

BUILD SUCCESSFUL in 54s 5 actionable tasks: 5 executed

It seems that the gradle script in examples/build.gradle is buggy.

$ ./gradlew examples:hankstodo:run

> Task :examples:hanksTodo:runenvoms
Launched OMS Server. !!!

> Task :examples:hanksTodo:runenvks1
Launched Kernel Server 1. !!!

> Task :examples:hanksTodo:runenvks2
Launched Kernel Server 2. !!!

> Task :examples:hanksTodo:runenvapp
Starting a Gradle Daemon, 4 busy and 20 stopped Daemons could not be reused, use --status for details
> Task :core:checkGraalVmVersion
> Task :dependencies:apache.harmony:compileJava UP-TO-DATE
> Task :dependencies:java.rmi:compileJava UP-TO-DATE
> Task :core:compileJava UP-TO-DATE
> Task :core:processResources NO-SOURCE
> Task :core:classes UP-TO-DATE
> Task :dependencies:apache.harmony:processResources NO-SOURCE
> Task :dependencies:apache.harmony:classes UP-TO-DATE
> Task :dependencies:apache.harmony:genStubs SKIPPED
> Task :dependencies:apache.harmony:compileStubsJava NO-SOURCE
> Task :dependencies:apache.harmony:compileTestJava NO-SOURCE
> Task :dependencies:apache.harmony:jar UP-TO-DATE
> Task :dependencies:java.rmi:processResources NO-SOURCE
> Task :dependencies:java.rmi:classes UP-TO-DATE
> Task :dependencies:java.rmi:genStubs SKIPPED
> Task :dependencies:java.rmi:compileStubsJava NO-SOURCE
> Task :dependencies:java.rmi:compileTestJava NO-SOURCE
> Task :dependencies:java.rmi:jar UP-TO-DATE
> Task :core:genGraalTestStubs UP-TO-DATE
> Task :core:compileGraalTestStubs UP-TO-DATE
> Task :core:genStubs UP-TO-DATE
> Task :core:compileStubsJava UP-TO-DATE
> Task :core:compileSampleSO UP-TO-DATE
> Task :core:genUnitTestStubs UP-TO-DATE
> Task :core:processStubsResources NO-SOURCE
> Task :core:stubsClasses UP-TO-DATE
> Task :examples:helloworld:compileJava UP-TO-DATE
> Task :core:compileTestJava UP-TO-DATE
> Task :core:processTestResources UP-TO-DATE
> Task :core:testClasses UP-TO-DATE
> Task :core:compileIntegTestDemoPkg UP-TO-DATE
> Task :core:genIntegTestStubs UP-TO-DATE
> Task :core:compileIntegrationTestJava UP-TO-DATE
> Task :core:jar UP-TO-DATE
> Task :examples:hanksTodo:compileJava UP-TO-DATE
> Task :examples:hanksTodo:processResources NO-SOURCE
> Task :examples:hanksTodo:classes UP-TO-DATE
> Task :examples:hanksTodo:genStubs UP-TO-DATE
> Task :examples:hanksTodo:compileStubsJava UP-TO-DATE
> Task :examples:hanksTodo:processStubsResources NO-SOURCE
> Task :examples:hanksTodo:stubsClasses UP-TO-DATE

> Task :examples:hanksTodo:runapp
Received tlm: amino.run.appexamples.hankstodo.stubs.TodoListManager_Stub@18be83e4
new to do list for 1
Adding Subject0. Content: Task0<0> at iteration 0
Exception in thread "main" java.lang.RuntimeException: amino.run.policy.util.consensus.raft.LeaderException: Current Leader is 00000000-0000-0000-0000-000000000000
        at amino.run.appexamples.hankstodo.stubs.TodoList_Stub.addToDo(TodoList_Stub.java:156)
        at amino.run.appexamples.hankstodo.HanksTodoMain.main(HanksTodoMain.java:76)
Caused by: amino.run.policy.util.consensus.raft.LeaderException: Current Leader is 00000000-0000-0000-0000-000000000000
        at amino.run.policy.util.consensus.raft.Server.applyToStateMachine(Server.java:377)
        at amino.run.policy.replication.ConsensusRSMPolicy$ServerPolicy.onRPC(ConsensusRSMPolicy.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at amino.run.common.ObjectHandler.invoke(ObjectHandler.java:106)
        at amino.run.kernel.server.KernelObject.invoke(KernelObject.java:40)
        at amino.run.kernel.server.KernelServerImpl.makeKernelRPC(KernelServerImpl.java:116)
        at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
        at sun.rmi.transport.Transport$1.run(Transport.java:200)
        at sun.rmi.transport.Transport$1.run(Transport.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:835)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

> Task :examples:hanksTodo:runapp FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':examples:hanksTodo:runapp'.
> Process 'command '/Users/quinton/Downloads/graalvm-ce-1.0.0-rc8/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 16s
23 actionable tasks: 2 executed, 21 up-to-date

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 54s
5 actionable tasks: 5 executed
maheshrajus commented 5 years ago

@quinton-hoole : I checked this issue and please find my analysis below. 1) 'runapp' task no relation with 'runenvapp' task. runenvapp task will be SUCCESSFUL always even 'runapp' task fails/success. 2) I fixed this by using the "runenvapp.finalizedBy runapp". In this case, if 'runenvapp' task status will be decided by 'runapp' task.

    task runenvapp(type: ExecWait, dependsOn: ksTask) {
        command './gradlew ' + project + ':runapp'
        //If any failures in 'runapp' task then 'runenvapp' task also should fail.
        finalizedBy runapp
    }

3) Here cleaning (closing oms port, ks ports) in failure case is not happening because the Gradle is not continuing further tasks.

If the user wants to execute all tasks including success/fail case then ./gradlew --continue examples:hankstodo:run should give.

Old way: /gradlew examples:hankstodo:run After this fix: /gradlew --continue examples:hankstodo:run

Please confirm whether this is ok or any suggestions on the same. Thank you!

Before fix: beforeFix

After fix: AfterFix

quinton-hoole commented 5 years ago

Thanks @maheshrajus. I think we need to figure out a way to clean up automatically, even on failure. Can you perhaps use the finalizedBy trick to do that? e.g. add something like "finalizedBy cleanup" at the end of runEnvApp?

I don't think it's reasonable to expect everyone to remember to add the --continue option in runs after tests fail.

quinton-hoole commented 5 years ago

Fixed by #806