Supply Chain Management Blogs by SAP
Expand your SAP SCM knowledge and stay informed about supply chain management technology and solutions with blog posts by SAP. Follow and stay connected.
cancel
Showing results for 
Search instead for 
Did you mean: 
subrahmanyam_pampana
Product and Topic Expert
Product and Topic Expert
0 Kudos
212

In the fast-paced world of software development, rolling out updates is a routine task. However, not every update goes as planned. Sometimes, a newly deployed version of an application introduces unforeseen issues, and rolling back to a previous stable version becomes essential. Cloud Foundry (CF) makes this process straightforward with its built-in support for managing application droplets. In this post, we’ll walk through the steps to reset a CF droplet to a previous version and download a droplet.

What is a Droplet in Cloud Foundry?
A droplet is an immutable snapshot of your application code, its dependencies, and the runtime environment created during the staging process. When you deploy an app to CF, it stages the app, generates a droplet, and assigns it to the app’s instances. Each droplet represents a specific version of your application. CF keeps up to 5 previous droplets in a staged state. Older droplets are marked as expired.

Why Reset a Droplet?
You might want to reset a droplet to a previous version for various reasons:

  • The new version of the application has critical bugs or performance issues.
  • A misconfiguration was introduced in the latest deployment.
  • There’s a need to quickly restore service stability.

Prerequisites
Before resetting or downloading a droplet, ensure the following:

  1. Install cf cli if it is not already installed. You can download it from the official site.
  2. Ensure you have access to the Cloud Foundry CLI (cf command-line tool).
  3. Make sure you have the necessary permissions to view application history and make updates.
  4. Verify that the previous droplets are available and listed in the app’s droplet history.
  5. Install the multiapps plugin, if not already installed, using the following command:

 

cf install-plugin multiapps

 

Step-by-Step Guide to Reset a Droplet

1. Login to CF
Login to CF using the following command

 

cf login -u <userId> -a <API_URL>

 

Or use Single Sign-On (SSO):

 

cf login -u <userId> -a <API_URL> --sso

 

Replace <userId> and <API_URL> with your user ID and the public API endpoint

2. List Available Droplets
Retrieve the list of available droplets for your application:

 

cf droplets <app-name>

 

This command will display all droplets associated with the application, including their GUID, creation date, and state. Identify the GUID of the droplet you want to reset.

3. Change the Current Droplet
Change the current droplet to a previous one using the following command:

 

cf set-droplet <app-name> <guid-droplet>

 

Replace <guid-droplet> with the GUID of the desired droplet.

4.Restart the App
After changing the droplet, restart the application:

 

cf restart <app-name>

 

This step is mandatory to apply the changes. After restarting, verify the current droplet with:

 

cf droplets <app-name>

 

Downloading a Droplet

Downloading a droplet allows you to retrieve a specific version of your application for debugging, analysis, or redeployment.

1. List Available Droplets
Retrieve the list of available droplets for your application:

 

cf droplets <app-name>

 

Identify the GUID of the droplet you want to download.

2. Download the Droplet
Use the cf curl command to download the droplet:

 

cf curl /v3/droplets/<droplet-guid>/download --output <filename>

 

Replace <droplet-guid> with the GUID of the desired droplet.
Replace <filename> with the desired file name for saving the droplet locally (e.g., my-droplet.tar).

Example:

 

cf droplets my-app cf curl /v3/droplets/abc12345-6789-def0-ghij-klmnopqrstuv/download --output my-app-droplet.tar

 

The downloaded file will be a tarball containing the application code, dependencies, and runtime environment.

Conclusion
Resetting a droplet in Cloud Foundry is a lifesaver when you need to revert to a stable version of your application quickly. Additionally, downloading droplets and examining can provide deeper insights into your application’s state for debugging or analysis. 

Have you faced challenges with rolling back or downloading droplets in Cloud Foundry? Share your experiences and solutions!