lifecyclecloudifyexternal-script

startDetection external script won't work in Cloudify 2.7.1


I can't arrive to use an axternal script for startDetection in Cloudify 2.7.1.

I try:

def result = ServiceUtils.isPortOccupied(port)
println "startDetection.groovy: is service started : ${result}"

return result

and the result is:

2014-09-25 12:46:09,268 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: isPortFree port ...
2014-09-25 12:46:09,300 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: is service started : false
2014-09-25 12:46:09,316 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - Command exited with value: 0
2014-09-25 12:46:09,517 default.service [1] INFO [org.cloudifysource.usm.UniversalServiceManagerBean] - Process liveness test passed

before the real end of the start script.

And I try:

def result = ServiceUtils.isPortOccupied(port)
println "startDetection.groovy: is service started : ${result}"
if (result){
    System.exit(0)
}
System.exit(-1)

and the result before the end of the start script is:

2014-09-25 12:59:19,299 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: isPortFree port ...
2014-09-25 12:59:19,331 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: is service started : false
2014-09-25 12:59:19,359 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - Command exited with value: 255
2014-09-25 12:59:19,360 default.service [1] SEVERE [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - Event lifecycle external process exited with abnormal status code: 255
2014-09-25 12:59:19,361 default.service [1] SEVERE  [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - Event lifecycle external process failed: /root/gigaspaces/tools/groovy/bin/groovy: 60: [: GNU/Linux: unexpected operator /root/gigaspaces/tools/groovy/bin/groovy: 100: [: GNU/Linux: unexpected operator startDetection.groovy: isPortFree port ... startDetection.groovy: is service started : false
2014-09-25 12:59:19,362 default.service [1] SEVERE [org.cloudifysource.usm.dsl.DSLEntryExecutor] - Failed to execute entry: startDetection.groovy; Caused by: org.cloudifysource.usm.USMException: Event lifecycle external process exited with abnormal status code: 255 /root/gigaspaces/tools/groovy/bin/groovy: 60: [: GNU/Linux: unexpected operator /root/gigaspaces/tools/groovy/bin/groovy: 100: [: GNU/Linux: unexpected operator startDetection.groovy: isPortFree port ... startDetection.groovy: is service started : false

    at org.cloudifysource.usm.launcher.DefaultProcessLauncher.launchProcess(DefaultProcessLauncher.java:762)
    at org.cloudifysource.usm.launcher.DefaultProcessLauncher.launchProcess(DefaultProcessLauncher.java:1086)
    at org.cloudifysource.usm.dsl.DSLEntryExecutor.run(DSLEntryExecutor.java:90)
    at org.cloudifysource.usm.dsl.DSLBeanConfiguration$6.isProcessAlive(DSLBeanConfiguration.java:529)
    at org.cloudifysource.usm.USMLifecycleBean.isProcessLivenessTestPassed(USMLifecycleBean.java:736)
    at org.cloudifysource.usm.UniversalServiceManagerBean.launch(UniversalServiceManagerBean.java:1140)
    at org.cloudifysource.usm.UniversalServiceManagerBean.installAndRun(UniversalServiceManagerBean.java:834)
    at org.cloudifysource.usm.UniversalServiceManagerBean.access$000(UniversalServiceManagerBean.java:103)
    at org.cloudifysource.usm.UniversalServiceManagerBean$2$1.run(UniversalServiceManagerBean.java:807)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

2014-09-25 12:59:19,362 default.zabbix [1] WARNING [org.cloudifysource.usm.dsl.DSLBeanConfiguration] - Liveness Detector failed to execute. Exception was: org.cloudifysource.usm.USMException: Event lifecycle external process exited with abnormal status code: 255

and the result after the end of the start script is:

2014-09-25 12:46:09,268 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: isPortFree port ...
2014-09-25 12:46:09,300 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - startDetection.groovy: is service started : false
2014-09-25 12:46:09,316 default.service [1] INFO [org.cloudifysource.usm.launcher.DefaultProcessLauncher] - Command exited with value: 0
2014-09-25 12:46:09,517 default.service [1] INFO [org.cloudifysource.usm.UniversalServiceManagerBean] - Process liveness test passed

In both case it doesn't work.

I can only use the startDetection in closure like that:

startDetection {
    println "service.groovy(startDetection): isPortFree ${port} ..."
    return ServiceUtils.isPortOccupied(port)
}

like the stopDetection.

Someone know why?


Solution

  • The log entries you copied above seem ok. With start detection, if you use an external lifecycle script, all you can do is pass a process return code which indicates pass/fail. A zero return code indicates the test passed - start detection completed successfully. A non-zero value means the test did not pass.

    In your question, when the start script completed successfully, you get this: Process liveness test passed

    So the script finished correctly, start detection passed. What is it exactly that doesn't work?