During a framework migration from an older version (e.g., Fast-Agent 0.3.15) to a new system (e.g., FastMCP 2.0), the entire source code directory was unexpectedly deleted without functional replacements. This resulted in a completely broken build pipeline, preventing further development and deployment. The incident highlights the importance of safeguards during migrations, especially in Kubernetes-based deployments.
Issue
The migration process accidentally deleted the entire source code directory (k3s/api/) containing critical files, including:
- Docker configuration (Dockerfile)
- Dependency management (requirements.txt)
- Core application logic (main.py, worker scripts)
- Configuration files (e.g.,
fastagent.config.yaml)
This deletion led to:
- A broken build pipeline due to missing Dockerfile and dependencies.
- An empty source directory, preventing any deployment.
- Broken Kubernetes manifests with unresolved environment variable references.
- Failed deployment scripts due to missing context configurations.
Culprit
The root cause was a flawed migration strategy that:
- Deleted before creating: Removed all source files without ensuring replacements were ready.
- Committed non-functional state: Migration commits contained only documentation, TODO lists, and architecture plans—no working code.
- Lack of parallel implementation: No feature flags or gradual rollout strategy was implemented.
- Missing pre-deletion validation: No verification that new code existed or that the build pipeline would pass.
Solution
Codebase Restoration
- Reverted to a known working state using Git history to restore the deleted directory:
This recovered all critical components, including the Dockerfile, dependencies, and application logic.git checkout HEAD -- k3s/api/
Deployment Fixes
- Fixed Kubernetes Context Issues: Added explicit context flags to deployment scripts to ensure correct cluster targeting.
- Simplified Configuration: Consolidated environment variables using Kubernetes ConfigMaps to reduce complexity and errors.
Migration Safeguards
To prevent future incidents, the following measures were implemented:
- Parallel Implementation: New code must coexist with legacy code during transitions.
- Feature Flagging: Runtime switching between implementations to allow gradual testing.
- Traffic Splitting: Domain-based or percentage-based rollout to compare metrics.
Verification Process
A pre-deletion checklist was established to ensure:
- The build pipeline passes.
- All tests execute successfully.
- The cluster remains healthy before any file deletions.
This solution restored functionality while providing a safer framework for future migrations, including:
- Automated verification gates.
- Backup systems for critical components.
- Gradual rollout mechanisms to minimize risk.