Quantcast

Deployment not happening through Glu...Failing while installing script.

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Deployment not happening through Glu...Failing while installing script.

Neha Rana
Hi Yan,

I am getting below error in agent whenever I am executing a deployment plan:

2014/01/30 09:32:50.536 WARN [ScriptManagerImpl] Error while instantiating script: /home/XYZ: Connection timed out [[initParameters:[groupId:ABC, artifactId:XYZ, contextPath:/api, metadata:[product:FGH, version:1.0-SNAPSHOT], version:1.0-SNAPSHOT], mountPoint:/home/XYZ, scriptLocation:class:/abc.def.GluScripts.WebAppGluScript?cp=http%3A%2F%2Fadmin%3Aadmin123%XYZ.com%2Fnexus%2Fcontent%2Frepositories%2Fsnapshots%2Fabc%2Fdef%2FGluScripts%2F0.0.1-SNAPSHOT%2FGluScripts-0.0.1-20140130.083435-3.jar]]

In console , the following error is coming:

Install script for [/home/XYZ] on [ip-xx-xxx-xxx-xxx] - 1m3s

[+] org.linkedin.glu.agent.api.ScriptException: /home/XYZ
[+] java.net.ConnectException: Connection timed out

Please tell me the problem...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

Neha Rana
Also, I have packaged the glu scripts in a jar file and stored it in nexus..
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

frenchyan
Administrator
In reply to this post by Neha Rana
are you sure the cp argument is correct and properly encoded? When I decode it, it does not look right:

http://admin:admin123XYZ.com/nexus/content/repositories/snapshots/abc/def/GluScripts/0.0.1-SNAPSHOT/GluScripts-0.0.1-20140130.083435-3.jar

admin:admin123XYZ.com is not a valid host name

If the URL is correct (but wrong here because you obfuscated it to some extent), then I would suggest manually logging on the agent where you are trying to install the script and try to manually download the jar file (using curl for example). You can also use the command feature in the console and execute the curl command on the agent without having to log in...

Most likely this kind of problem is a connectivity issue between the agent host and the repository host. If you can do it manually then glu can do it as well. 

Yan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

Neha Rana
Thanks Yan....It was a mistake from my part.
  Actually, all of my glu components and nexus is in cloud. So,instead of giving private DNS , I was giving public DNS as host name which was creating a problem.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

Neha Rana
This post was updated on .
Now , I am trying to run 'redeploy' plan for my server.For that , it is showing me :

    1. Run [unconfigure] phase for [/home/XYZ] on [ip-xx-xxx-xxx-xxx]

    2. Run [uninstall] phase for [/home/XYZ] on [ip-xx-xxx-xxx-xxx]

    3. Uninstall script for [/home/XYZ] on [ip-xx-xxx-xxx-xxx]

    4. Install script for [/home/XYZ] on [ip-xx-xxx-xxx-xxx]

    5. Run [install] phase for [/home/XYZ] on [ip-xx-xxx-xxx-xxx]

    6. Run [configure] phase for [/home/XYZ] on [ip-xx-xxx-xxx-xxx]

    7. Run [start] phase for [/home/XYZ] on [ip-xx-xxx-xxx-xxx]

So, till Step 6 i.e. Run [configure] it is working fine. At the last step i.e. 7(start phase) it's getting failed because my jetty is already running.So, to solve this problem I want to stop jetty in the first step itself...
i.e. I want to put ' Run [stop] phase for {/home/XYZ} in the first step.

  How to achieve this i.e. changing/adding more steps in redeployment plan...Do I need to do something with state machine..If yes, then how?  Please let me know....
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

Neha Rana
This post was updated on .
Also, for 'deploy' plan, it's getting stuck at the last step-  i.e. Run [start] phase for [/home/XYZ].
When I checked the agent instance , everything seems fine .i.e. war gets deployed and jetty got started.But still in the console UI, it's showing last step getting stuck even after successful deployment?

When I checked the details of the agent from console UI, it's showing:

scriptState

    script: {}
    stateMachine
        currentState: stopped

        error: Clear error

            View Full Stack Trace

            * org.linkedin.glu.agent.api.ScriptExecutionException: "script=abc.xyz.GluScripts.WebAppGluScript [/home/XYZ], action=start"
            * org.linkedin.glu.agent.api.ScriptExecutionCauseException: "[java.lang.InterruptedException]: null"




What 's could be the reason?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

frenchyan
Administrator
In reply to this post by Neha Rana
The problem is most likely in the glu script that you wrote (WebAppGluScript). Every phase is supposed to block until fully complete and then exit. It is probably not exiting because the condition you have to block does not get fully satisfied. You can check an example of glu script there: https://github.com/pongasoft/glu/blob/master/scripts/org.linkedin.glu.script-jetty/src/main/groovy/JettyGluScript.groovy

In regards to your other question, the glu script has many phases, like stop, unconfigure, etc... and you should make sure that you stop the container in one of them (this is what the JettyGluScript example script does). There is no need to add a new phase. Whatever you put in a glu script is code that is "outside" of glu and you have total control over it. What glu does is invoke the various phases in the proper order (defined by the state machine). What the phases do is up to you. You just need to make sure that each phase properly blocks until complete and then exits when complete so that glu can call the next phase.

Yan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

Neha Rana
Hi Yan,

 I am invoking stop() in my glu script to stop the container but in glu console I am never getting Run [stop] phase ..Is it some bug ??

For redeploy plan, the first phase that comes in glu console is:

Run [unconfigure] phase for [/home/YXZ] on [ip-xx.xx.xx.xx]

The  first step should be Run [stop] so as to stop jetty first , then Run [unconfigure] phase right?

    I am using glu 5.4.2..

Regards,
Neha
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

Neha Rana
Also , for 'stop' plan in glu console, it's showing me:

no plan..  

 Please help..
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

frenchyan
Administrator

You need to share your glu script.

Yan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

Neha Rana
Now I am getting Run[stop] phase as well after changing my JettyScript.

PFB my JettyScript which is being inhertied by WebAppGluScript:

class JettyScript {

    def port
    def pid
    def contextPath


    protected baseConfigure() {
        // save port
        port = 9000 as int
        contextPath = resolveContext()
        // setup monitor to check server health
        timers.schedule(timer: serverMonitor, repeatFrequency: params.serverMonitorFrequency ?: '5s')
    }

    protected baseStart() {
        startServer()
        waitTillServerIsUp()
    }

    protected baseStop() {
        stopServer()
        waitTillServerIsStopped()
    }

    protected baseUnconfigure() {
        port = null
        pid = null
        contextPath = null
    }





    protected String resolveContext() {
        String context = params.contextPath
        if (context == null || context.isEmpty()) {
            return "/"
        }
        return context
    }


    protected boolean isWebAppUp() {
        log.debug("Hitting <a href="http://localhost:$">http://localhost:${port}${contextPath}")
        log.info(" Is Webapp Up ()")
        def head = shell.httpHead("<a href="http://localhost:$">http://localhost:${port}${contextPath}")
        return head.responseCode == 200
    }

    protected boolean isServerUp() {
        Integer pid = isProcessUp()
        if (pid && shell.listening('localhost', port)) {
            return true
        } else {
            return false
        }
    }


    protected waitTillServerIsUp() {
        //shell.waitFor(timeout: '5s', heartbeat: '250') {

         
         shell.waitFor() {
         pid = isProcessUp()
        }
     
       shell.waitFor() { duration ->
           log.info "${duration}: Waiting for server to be up"

            if (isProcessDown()) {
                shell.fail("Server could not be started. Check log file for details.")
           }

            return isServerUp()
        }
    }

    protected startServer() {
        log.info " start Server"
        //shell.exec("service jetty start")      


         def command= " service jetty start "
        def proc = command.execute()                 // Call *execute* on the string
         proc.waitFor()      



    }

    protected Integer isProcessUp() {
        log.info " Is process Up"
        def pidFile = new File("/var/run/jetty.pid")
        log.info " Got PID"
         //shell.exec("cat /var/run/jetty.pid")
         
          def command= " cat /var/run/jetty.pid "
        def proc = command.execute()                 // Call *execute* on the string
         proc.waitFor()        
 
        if (pidFile.exists()) {
            return pidFile.getText().trim().toInteger()
        } else {
            return null
        }
    }


    protected boolean isProcessDown() {
        return !new File("/var/run/jetty.pid").exists()
    }

    protected waitTillServerIsStopped() {
        shell.waitFor(timeout: '60s', heartbeat: '1s') { duration ->
            log.info "${duration}: Waiting for server to be down"
            isProcessDown()
        }
    }

    protected stopServer() {
        shell.exec("service jetty stop")
    }


    protected deleteInstalledFiles() {
        shell.exec("rm -rf /opt/jetty/webapps/*")
        shell.exec("rm -rf /opt/jetty/contexts/*")
        //shell.exec("rm -rf /home/jetty/local/*")
    }

    protected baseUninstall() {
        deleteInstalledFiles()
    }


    def serverMonitor = {
        try {
            def serverUp = isServerUp()
            def webAppUp = isWebAppUp()

            log.debug("Health Check: server - ${serverUp}, webapp - ${webAppUp}")

            def currentState = stateManager.state.currentState
            def currentError = stateManager.state.error

            def newState = null
            def newError = null

            if (currentState == 'running') {
                if(!serverUp) {
                    newState = 'stopped'
                    pid = null
                    newError = 'Server down detected. Check the log file for errors.'
                    log.warn("${newError} => forcing new state ${newState}")
                } else if (!webAppUp) {
                    newError = 'WebApp error detected. Check the log file for errors.'
                    log.warn("${newError} => forcing new state ${newState}")
                }
            } else if (serverUp && webAppUp) {
                newState = 'running'
                log.info("Server up detected.")
            }

            if (newState) {
                stateManager.forceChangeState(newState, newError)
            }

            log.debug("Server Monitor: ${stateManager.state.currentState}")
        }
        catch (Throwable th) {
            log.warn("Exception while running serverMonitor: ${th.message}")
            log.debug("Exception while running serverMonitor (ignored)", th)
        }
    }
}

But now, even after successful completion of all the phases of deployment plan, it's showing 'DELTA' for my instance where the application is deployed.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

frenchyan
Administrator
It is unclear how the WebAppScript ties into the JettyScript since you have not included it. I assume each phase delegates to the methods? You should include it as well.

Otherwise this script looks fine. I guess the only comment I would make, (which btw, has nothing to do with glu per se), is that checking that the process is down by simply validating that a process pid file exists or not may not be the best approach. I am not familiar with what your OS does, but if /var/run/jetty.pid is created by you (not by the OS) and is not guaranteed (by the OS) to not exist when the process is not there anymore, then I can see some trouble... simply do kill -9 on your container, and if that leaves the pid file around, then clearly isProcessDown will never return true... I guess the same holds for isServerUp... 

Yan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

Neha Rana
Thanks Yan for replyin...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Deployment not happening through Glu...Failing while installing script.

Neha Rana
Hi Yan!

It's working perfectly perfectly fine now...the problem was with my model file....I was giving wrong context path, that's why my process was never showing 'UP' state...that's for all the support:)
Loading...