Interview Prep/Python for DevOps/Automation scripting & CLI design

You are asked to write a "self-healing" script that restarts a service when its health check fails. What design concerns do you raise?

IntermediateScenarioAutomation scripting & CLI design
Answer

Situation read → Auto-remediation can hide problems or cause restart storms.

What I'd do →

  1. Prefer platform features first: systemd Restart=on-failure with StartLimitBurst, Kubernetes liveness probes, ASG health checks.
  2. If a script is still needed: require N consecutive failures before acting, add a cooldown, cap restarts per hour, and alert a human after the cap.
  3. Log and emit a metric for every remediation so frequency is visible.
  4. Never remediate on a dependency failure (restarting the app does not fix the DB).

Why → Unbounded auto-restart turns a degraded service into a flapping one.

Interview tip → Say every auto-remediation must also notify; silent healing hides the root cause.

All Python for DevOps questions Roadmap: Python for automation

More on Automation scripting & CLI design