Safe delivery

A deploy check, partly written

Your platform team runs an offline check before a batch rollout. Work on the Python checker using normalized deployment records. Report unsafe defaults without changing the input. This exercise runs against fixtures, not a live cluster.

In production

This offline checker runs before a batch rollout. A miss lets an unsafe Deployment ship; a false positive blocks a safe one.

What it must return

Return only deployments that fail at least one rule, each as {name, issues}, keeping input order and the fixed issue order: replicas, readiness, memory.

  • Each record has a unique name. Other fields may be missing; numeric fields contain numbers when present.
  • Report no_replicas when replicas is missing or at most zero.
  • Report no_readiness_probe unless readiness_probe is True.
  • Report no_memory_limit when memory_limit_mib is missing or at most zero.
  • Return {name, issues} for unsafe deployments only. Keep input order and issue order: replicas, readiness, memory.
  • Do not mutate the input or contact a cluster.
  • Do not modify the input. All records have valid identifiers and numeric metrics when present.

Edge cases

  • replicas missing or ≤ 0 → no_replicas.
  • readiness_probe must be exactly True; anything else → no_readiness_probe.
  • memory_limit_mib missing or ≤ 0 → no_memory_limit.

Signature

audit_deployments(deployments) -> list[dict]

Part of this function is already written. The TODO comments mark what is left.

Hints

  1. Second hint

  2. A partial sketch

The reference solution opens after the last hint.

Adapted from Baodium Interview Coach.

solution.py · Python

Loading editor…

A ready deployment

deployments

[
  {
    "name": "api",
    "replicas": 2,
    "readiness_probe": true,
    "memory_limit_mib": 512
  }
]

Expected

[]

Each run uses a fresh Python runtime in this browser, with a 3-second limit and a Stop button. The first run downloads the runtime. 0 of 3 in Safe delivery passed in Python on this device.

Next: A deploy check, with a bug