Upgrade a Bitbucket cluster through the API without downtime
API reference
The entire rolling upgrade process is governed by the following API:
https://<host>:<port>/rest/zdu/cluster
This API has the following calls:
Get an overview of the cluster's status. | |
Enable upgrade mode. | |
Get the status of the cluster. | |
Get an overview of a node's status. | |
Disable upgrade mode. You can only use this call if the upgrade progress is not MIXED. | |
Once all nodes are upgraded, finalize the rolling upgrade. This will automatically disable upgrade mode. |
For detailed information about each API call, see Bitbucket REST API Documentation.
Authenticating REST API calls
In a secure environment, you'll need to authenticate your REST API calls. See Personal access tokens and Bitbucket Server REST API Example - Basic Authentication for more information.
Downloading upgrade files
https://www.atlassian.com/software/bitbucket/download
Alternatively, you can also use the Pre-upgrade planning tool to help you download a compatible bug fix version. Choose > Administration > Plan your upgrade to open the tool.
Initiating a rolling upgrade
To initiate a rolling upgrade, enable rolling upgrade first. To do this, use:
https://<host>:<port>/rest/zdu/cluster/start
Enabling upgrade mode allows your cluster to accept nodes running a later bug fix version. This lets you upgrade one node and let it rejoin the cluster (along with the other non-upgraded nodes). Both upgraded and non-upgraded active nodes work together in keeping Bitbucket available to all users.
You can disable upgrade mode as long as you haven’t upgraded any nodes yet.
Upgrading each node individually
In general, upgrading a node during a rolling upgrade consists of four phases:
Finalizing the rolling upgrade
Once all nodes are upgraded, finalize the rolling upgrade. To do this, use:
https://<host>:<port>/rest/zdu/cluster/approve
This call will automatically disable upgrade mode.
After completing the rolling upgrade, you should:
- Update your apps accordingly
- Perform UAT and other tests as needed
Node statuses
To get the status of a node, use:
https://<host>:<port>/rest/zdu/cluster/nodes/<nodeID>
ACTIVE | Bitbucket is connected to the cluster and running with no errors. |
---|---|
STARTING | Bitbucket is still loading, and should transition to Active once finished. |
TERMINATING | Bitbucket was gracefully shut down, and should transition to Offline once finished. |
OFFLINE | Bitbucket is not responding on the node. This node will be removed from the cluster completely if it is still offline after Upgrade mode is disabled. |
ERROR | Something went wrong with Bitbucket on the node. |
Cluster statuses
To get the status of the cluster, use:
https://<host>:<port>/rest/zdu/cluster/state
STABLE | You can turn on Upgrade mode now. |
---|---|
READY_TO_UPGRADE | Upgrade mode is enabled, but no nodes have been upgraded yet. You can start upgrading your first node now. |
MIXED | At least one node is upgraded, but you haven't finished upgrading all nodes yet. Your cluster has nodes running different Bitbucket versions. You need to upgrade all nodes to the same bug fix version to transition to the next status (READY_TO_RUN_UPGRADE_TASKS) |
READY_TO_RUN_UPGRADE_TASKS | All nodes have node been upgraded. You can now finalize the rolling upgrade:
|
Troubleshooting
Node errors during rolling upgrade
There are several ways to address this:
Shut down Bitbucket gracefully on the node. This should disconnect the node from the cluster, allowing the node to transition to an Offline status.
If you can’t shut down Bitbucket gracefully, shut down the node altogether.
Once all active nodes are upgraded with no nodes in Error, you can finalize the rolling upgrade. You can investigate any problems with the problematic node afterwards and re-connect it to the cluster once you address the error.
Disabling upgrade mode
- haven't been upgraded yet
- aren't in an Error state
The cluster's status will transition to Mixed if an upgraded node joins the cluster or a node enters an error state.
Mixed status with Upgrade mode disabled
If a node is in an Error state with Upgrade mode disabled, you can't enable Upgrade mode. Fix the problem or remove the node from the cluster to enable Upgrade mode.