Skip to article content
FrontendXLesson 14 / 16

Rollback and Observability

Take one task-board application from local tests to a real delivery pipeline: continuous integration fundamentals, push and pull-request quality gates, lint, type-check, unit, component and end-to-end gates, dependency caching, matrix builds, artifacts and checksums, secrets and supply-chain security, release promotion, staging and production, rollback and observability.

advanced · about 40 minutes · 4 exercises

  • Explain
  • Implement
  • Debug
  • Test

What you will be able to do

#
  • Run a bounded post-deploy health check.
  • Choose between a flag rollback and a redeploy rollback.
  • Use deploy markers to correlate releases with incidents.

Overview

#

Assume every deploy can fail

A deploy can succeed as a command and still break the product. Rollback and observability are the two halves of the safety net: rollback restores a known-good state, and observability tells you that you need to.

snippet.yaml
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - run: ./deploy.sh
      - name: health check
        run: |
          for i in $(seq 1 10); do
            if curl -fsS "$BASE_URL/health"; then exit 0; fi
            sleep 3
          done
          echo "health check failed"
          exit 1

Rollback strategies

The fastest rollback is usually a feature flag: turn the new behavior off without redeploying. When a redeploy is needed, roll back to the previous known-good artifact rather than rebuilding, so the restored bytes are the ones that were verified. Database migrations need forward-compatible changes so the previous application version still works against the new schema.

Health checks and readiness

A health check confirms the deployed environment responds. A readiness check confirms it can serve real traffic, including its dependencies. Run them as a post-deploy step and fail the job when they do not pass, so a broken deploy does not look green.

Observability

Metrics, logs and traces are the evidence you use to decide whether a deploy is healthy. A deploy marker, a timestamped event in the metrics stream, lets you correlate a change in error rate with a release. Without markers, you cannot tell which deploy caused a spike.

Alerting on the right signals

Alert on symptoms users feel, such as error rate or latency, not on every internal counter. An alert that fires constantly is ignored, which defeats its purpose.

Sandbox boundary

The browser sandbox cannot deploy, roll back or read production telemetry. It can run the pure decision logic, such as choosing rollback from a health status.

Exercises

#

Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.

  1. Exercise 1Implement

    Add a post-deploy health-check step that polls the health endpoint up to ten times and fails the job if it never responds.

    starter.yaml
    jobs:
      deploy:
        runs-on: ubuntu-latest
        steps:
          - run: ./deploy.sh
    

    Reveal the reference answer
    reference.yaml
    jobs:
      deploy:
        runs-on: ubuntu-latest
        steps:
          - run: ./deploy.sh
          - name: health check
            run: |
              for i in $(seq 1 10); do
                if curl -fsS "$BASE_URL/health"; then exit 0; fi
                sleep 3
              done
              echo "health check failed"
              exit 1

    Authored expected output: A health-check step that retries the endpoint and fails the job after ten attempts.

    Polling with a bounded retry turns a transient startup delay into a pass while still failing a genuinely broken deploy.

  2. Exercise 2Debug

    This rollback step references a version that was never recorded, so it fails. Fix it to roll back to the previous recorded artifact.

    starter.yaml
          - run: ./rollback.sh --to latest
    

    Reveal the reference answer
    reference.yaml
          - run: ./rollback.sh --to "$PREVIOUS_VERSION"
            env:
              PREVIOUS_VERSION: ${{ vars.LAST_KNOWN_GOOD }}
    

    Authored expected output: The rollback targets a recorded previous version instead of an undefined label.

    A rollback needs a concrete target. Recording the last known good version makes the rollback deterministic.

  3. Exercise 3Test

    Write a function deployDecision(health) that returns 'rollback' when health is 'unhealthy', 'hold' when health is 'degraded' and 'promote' when health is 'healthy'.

    starter.javascript
    function deployDecision(health) {
      // return 'rollback', 'hold' or 'promote'
    }

    Reveal the reference answer
    reference.javascript
    function deployDecision(health) {
      if (health === 'unhealthy') return 'rollback';
      if (health === 'degraded') return 'hold';
      if (health === 'healthy') return 'promote';
      return 'hold';
    }

    Authored expected output: deployDecision('unhealthy') is 'rollback'; deployDecision('degraded') is 'hold'; deployDecision('healthy') is 'promote'.

    The decision function is pure and runs in the browser sandbox. The telemetry that feeds it comes from the real environment.

  4. Exercise 4Explain

    Explain why a feature flag is often a faster rollback than redeploying.

    Reveal the reference answer
    reference.text
    Turning a flag off changes behavior immediately without a build, a deploy or a cache invalidation. A redeploy takes time to build and ship and can itself fail. The flag decouples the decision to disable a feature from the mechanics of releasing code.

    Authored expected output: A correct answer contrasts instant flag toggling with the time and risk of a redeploy.

    Rollback speed matters during an incident. A flag removes the deploy step from the critical path.

Common misconceptions

#
  • A successful deploy command means the product works.
  • Rollback always means rebuilding the previous version.
  • Alerting on every internal counter improves reliability.

Follow-up practice

#
  • cicd-15-quality-task-board-pipeline

Related resources

#

Your progress

#

Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.

Verification: authored. Answers and outputs on this page are authored reference material, not executed results.

© 2026 FrontendX. All rights reserved.