Runtime Manager does not provide a bulk restart for CloudHub 2.0 applications. When many applications on a Private Space need new replicas, for example after a Private Space change that only takes effect when replicas are recreated, restarting them one by one in the UI is slow and error-prone.
This article describes the attached script ch2_bulk_restart.py. It performs a rolling restart of every running application deployed to a Private Space in one business group and environment, and records the result for every application.
Restart all running CloudHub 2.0 applications deployed to Private Spaces in a business group and environment, with a rolling update (no downtime for applications that use the rolling update strategy), without changing their configuration.
CloudHub 2.0 creates a new deployment version and replaces the replicas whenever the application configuration changes. The script changes one dummy application property, restart.count, incrementing it by one on every run. For each application it:
GET .../amc/application-manager/api/v2/organizations/{orgId}/environments/{envId}/deployments/{deploymentId}).restart.count, and all protected (secure) properties with their masked value ******. A masked value keeps the stored secret. See KB 005316378.UNSAFE.PATCH for that deployment and checks the response: same property set, the new restart.count value, and a new deployment version.Only the application properties section is sent. Other settings are not included in the request and are not changed: log levels, scheduler settings, ingress/public endpoint, runtime version, replicas, vCores, JVM arguments, update strategy and the rest of the deployment settings.
restart.count property is added to each application and is visible to the app like any other property. Do not use a property with this name in your applications, as a plain or a protected property.FAILED.APPLYING a change are included.recreate update strategy have downtime, because the old replicas stop before the new ones start. These apps are skipped unless you pass --include-recreate.PENDING with reasons such as "Waiting for compute capacity to be provisioned for the replica" or network initialization messages. The old replicas keep running, so the application stays available, but the restart takes longer. The script pauses after each batch (by default 120 seconds after every 5 restarts). On busy Private Spaces use a smaller --batch-size or a longer --batch-pause.HTTP 400: Runtime Version not supported for this target. and applies no change. The script reports these apps as ERROR with the runtime version, and continues. Update these apps to a supported runtime version (the latest patch is recommended) in Runtime Manager. The update itself restarts them.APPLYING because its new replicas keep crashing is restarted again, and the new version fails the same way. Check such apps in Runtime Manager before the run, or leave them out with --app.--execute nothing is changed.eu1.anypoint.mulesoft.com.macOS / Linux: export ANYPOINT_CLIENT_ID=<client id> export ANYPOINT_CLIENT_SECRET=<client secret> Windows (PowerShell): $env:ANYPOINT_CLIENT_ID="<client id>" $env:ANYPOINT_CLIENT_SECRET="<client secret>"If both a connected app and
ANYPOINT_TOKEN are set, the connected app is used.python3 ch2_bulk_restart.py --org <businessGroupId> --env <environmentId>Check the list: every app is shown as
WOULD (would be restarted) or SKIP (with the reason), together with its property counts, update strategy, replicas and runtime version.python3 ch2_bulk_restart.py --org <businessGroupId> --env <environmentId> --executeTo restart only some applications, add
--app <name> once for each app.| Option | Meaning |
|---|---|
--org | Business group ID (required) |
--env | Environment ID (required) |
--execute | Actually restart. Without it the run is a dry run. |
--app NAME | Only this application; repeat for more than one |
--include-recreate | Also restart apps with the recreate update strategy (downtime) |
--batch-size N | Restarts per batch, default 5. Only accepted restarts count. |
--batch-pause S | Seconds to wait after each batch, default 120 |
--host | Control plane host, default anypoint.mulesoft.com |
--report-dir | Where run reports are written, default reports/ next to the script |
Every application gets a result line on screen, for example:
[12/35] ERROR app-a PATCH rejected: HTTP 400: Runtime Version not supported for this target. (runtime 4.8.5:4e-java8) [14/35] PATCHING app-b [14/35] PATCHED app-b props 14->14, protected 0, restart.count->2, rolling, replicas 1, runtime 4.6.34:6-java8, new version 9a603387
| Result | Meaning |
|---|---|
WOULD | Dry run: would be restarted |
SKIP | Not selected; the reason is shown |
PATCHED | Restart requested; new deployment version created |
ERROR | Rejected by the platform (for example HTTP 400) or not applied; nothing changed for this app |
UNSAFE | Not sent, because the request could not be confirmed to keep all properties |
UNKNOWN | The PATCH got a server error, so it may or may not have been applied. The run stops. Check this app in Runtime Manager before running again. |
CHECK | The PATCH response did not match the request. The run stops. Check this app in Runtime Manager. |
Each run writes a folder named <businessGroupId>_<environmentId>_<YYYYMMDDHHMMSS> that contains:
run.log: the same lines as the screen.report.json: every application with its result and reason. For restarted apps it also has the previous and new deployment version.The run also stops if authentication fails. If a restart was not applied because of that, it is recorded against the application.
To return an application to the version it had before the restart:
report.json lists the previous version for each restarted application.
Disclaimer – not a MuleSoft product.
The attached script ch2_bulk_restart.py is provided as a sample only. It is not a MuleSoft product, is not covered by MuleSoft Support or any SLA, and is provided "as is" without warranty of any kind.
Before you run it against production:
--execute, in a non-production environment.You are responsible for testing, running and maintaining the script in your environment. The script prints the same disclaimer at the start of every run.
005460813
7 KB

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.