Manage Offline Deployment Servers with Selective Redeploys

submit to reddit StumbleUpon Delicious Save to Delicious
One of the key features of AnthillPro is the ability to configure distributed deployments.  Often these deployments may be to multiple agents.  Consider a distributed testing scenario where you are deploying to twenty or more agents.  AnthillPro is designed to display both the environment that the deploy workflow ran against, and the specific agents that were utilized. 

The question then becomes, “what if one or more of those agents are offline?”  In a typical AnthillPro configuration, the deployment will fail letting the end user know that not all of the agents were online.  However, this is not always desirable. 

Scenario's exist where you may still want to continue with the deployment to the other online agents.     To achieve this functionality you can utilize an agent filter script that will only return agents that are online. 

import com.urbancode.anthill3.domain.agent.Agent;
import com.urbancode.anthill3.services.agent.AgentManager;
import com.urbancode.anthill3.runtime.scripting.*;
import com.urbancode.anthill3.runtime.scripting.helpers.*;
import com.urbancode.commons.util.CollectionUtil;

/* Return all agents online */
return new Where() {

    public Agent[] filter(Agent[] agents) {
        agentList = new LinkedList();
        for (int i=0; i<agents.length; i++) {
            status = AgentManager.getInstance().getAgentStatus(agents[i]);
            if (status != null && status.isOnline()) {

                agentList.add(agents[i]);
            }
        }
        return (Agent[]) agentList.toArray(new Agent[agentList.size()]);
    }
}


With the above script you do not have to worry about your deployments failing because an agent was not online. 

However, this creates a new situation.  What about the agents that were offline?  Ideally, we would want to identify those agents so that we can later redeploy to only those agents that were skipped.

A proper solution should alert the end user that agents were offline. Once the agents were back online another deployment workflow could be run.

A Beanshell Script  (used with the Evaluate Script Step) to determine what agents were skipped during deployment can be found at

https://bugs.urbancode.com/browse/AHPSCRIPTS-102

Using that script we can now correctly identify which agents were skipped.  Notice that we set two properties in the process. 

agents_offline:  This property will be set to true if agents were offline. 
Agents_not_deployed_too:  This will contain the names of the agents that were skipped.

These two properties will play an important role in allowing us to redeploy our build to only the agents that were skipped.  We will however, need to make some changes to our initial agent filter script that returns all online agents.

The agent filter script needs to check the value of 'agents_offline' to determine if we are doing a re-deployment.  If we are in fact doing a redeployment, the list of agents returned will be the value of the 'Agents_not_deployed_too' property.

The full agent filter script (with changes) can also be found at

https://bugs.urbancode.com/browse/AHPSCRIPTS-102

The combination of these two scripts can be useful if it is used in appropriate environments.  Use of such scripts should not be used if you need to ensure all agents currently have the same version of artifacts.

If this is your scenario, then I would recommend failing your deployment if any agents are offline, and then re-deploying. 

If you are interested in seeing these scripts in action, please check out the short demo provided at the link below.

http://www.screencast.com/t/hikf68Cp



© 2006-2010 Urbancode, Inc.
Anthill, AnthillPro, and AnthillOS are trademarks of Urbancode, Inc.
All other trademarks are owned by their respective owners.
tel: (216) 858-9000 fax: i (216) 393-0006 email:info@urbancode.com