2.14. Upgrades and Rollbacks

The final part of this tutorial covers upgrading the 'helloserver' deployment inside the 'dev' environment to a newer version (2.0). We will keep the helloserver inside the 'uat' environment at version 1.0.

The 2.0 version of helloserver requires an additional piece of configuration. Upgrading from 1.0 to 2.0 will prompt for this configuration. Rolling back from 2.0 to 1.0 will remove this configuration from the property file.

To upgrade helloserver to 2.0, we use the bw deploy command. BundleWorks will detect an existing installation and "do the right thing" (either upgrade or rollback) based on the bundle created date inside the bundle 'info' file. BundleWorks will call the upgrade.sh or rollback.sh script inside the 2.0 bundle as required.

Type the following commands to first add the helloserver 2.0 bundle to inventory (since we had removed it earlier) and then to deploy it to the 'dev' environment:

bw add $BUNDLEWORKS_HOME/tutorial/helloserver-2.0.tgz $HOME/works/bundles
bw deploy $HOME/works/bundles/helloserver/2.0 $HOME/works/environments/dev

During this upgrade, you will be prompted to select a language (the new piece of configuration). This language property will be added to the helloserver.properties file.

Restart the helloserver application and test using the 'hello' command. You should see the greeting in the language of your choice.

helloserver restart
helloserver hello

You can see the addition of the language property to configuration by using the cfgdiff command as follows:

helloserver cfgdiff helloserver.properties

To see which versions of helloserver are deployed, type bw whereis helloserver, and you should see output similar to the following:

$ bw whereis helloserver
Available
   /home/admin/works/bundles/helloserver/1.0
   /home/admin/works/bundles/helloserver/2.0
Deployed
   /home/admin/works/environments/dev (/home/admin/works/bundles/helloserver/2.0)
   /home/admin/works/environments/uat (/home/admin/works/bundles/helloserver/1.0)

To see which deployed bundles are currently running, type bw list running, and you should see output similar to the following:

/home/admin/works/environments/dev
   helloserver -> /home/admin/works/bundles/helloserver/2.0
/home/admin/works/environments/uat
   helloserver -> /home/admin/works/bundles/helloserver/1.0

We'll complete this tutorial by rolling back the 'helloserver' web application to version 1.0. As with the upgrade, this is accomplished using the bw deploy command as follows:

bw deploy $HOME/works/bundles/helloserver/1.0 $HOME/works/environments/dev

Restart the helloserver application and test using the 'hello' command. You should see the original 'Hello.' greeting again.

helloserver restart
helloserver hello

You can type helloserver history and helloserver cfghistory to view the complete history of this deployment.