Sub topic 13
Testing Patches and Rolling Them Out in Stages
Assume you can use sudo, read package-manager output, inspect systemd services, and access a test server over SSH. This chapter uses those skills to plan a staged rollout: test updates on a safe system, patch a small canary group, verify it, and then expand the change.
Why staged patching matters
A package update can fix a vulnerability and still cause an application failure. Common causes include a changed library interface, a new kernel behavior, a configuration-file conflict, or a service that fails to restart. Applying the same update to every server at once increases the size of the failure.
A staged rollout limits that risk. Keep one server or group unpatched until the rollout is proven. This holdback group gives you a comparison point and preserves time to investigate.
A practical sequence is:
- Record the server roles, applications, dependencies, and maintenance windows.
- Patch a disposable test system that resembles production.
- Patch one canary server or a small canary group.
- Run health checks and inspect logs.
- Expand to larger groups only when the checks pass.
- Keep a rollback or recovery procedure ready at every stage.
Build a test and canary plan
The test system should match production in the ways that matter: operating-system release, enabled repositories, application version, service configuration, and workload. A virtual machine snapshot can speed recovery, but it does not replace backups or a tested restore procedure.
Before patching, save the update list, confirm monitoring is working, and verify that you can connect through an alternate path if SSH or networking fails. Define success checks before the change. Examples include:
- The server returns a successful response to a health endpoint.
- Expected
systemdservices are active. - A representative job completes.
- Error rates, latency, and resource use remain within normal ranges.
- No new critical messages appear in the journal.
Use the same checks after every stage. Do not judge success only by whether the package command exits with status zero.
#!/usr/bin/env bash
set -u
services=(sshd nginx)
for service in "${services[@]}"; do
if systemctl is-active --quiet "$service"; then
echo "$service: active"
else
echo "$service: NOT active"
exit 1
fi
done
curl --fail --silent --show-error http://127.0.0.1/health
echo "health check passed"Expand the rollout safely
Use groups based on failure domains, not only alphabetical order. Separate servers by availability zone, customer, application role, or hardware type. Never patch every redundant member of a service at the same time. Maintain enough capacity to serve users while one group is unavailable.
Set a pause between stages. The pause should cover the longest meaningful workload, such as a scheduled backup, batch job, or daily traffic peak. Record the package versions, start and end times, checks performed, and operator decisions.
| Stage | Typical scope | Gate before continuing |
|---|---|---|
| Test | Disposable or isolated system | Application and integration checks pass |
| Canary | One server or small group | Monitoring stays normal through representative load |
| Production | One failure domain at a time | No unresolved alerts or service errors |
| Holdback | Intentionally delayed group | Used for comparison or emergency capacity |
A failed check is a stop signal. Do not continue because the package manager reported success. Investigate logs, compare the canary with the holdback group, and use the documented recovery path. Depending on the change, recovery may mean undoing a package transaction, restoring a snapshot, reinstalling the previous package version, or restoring the server from backup. Kernel and database changes often require a stronger recovery plan than ordinary user-space updates.
Exercise
Exercise
You have twelve identical web servers behind a load balancer. How should you stage a routine security update?
Show answer
Patch one canary while the other eleven serve traffic, run the defined health and workload checks, wait through a representative period, then patch one failure-domain group at a time. Stop and use the recovery plan if checks fail, while keeping at least one holdback group unpatched.