Handling Duplicate Code Locations After Agent Restarts
Last updated: October 20, 2025
When restarting Dagster agent pods or updating configurations, you may encounter duplicate code locations if the agent-to-Dagster+ communication is disrupted. This can happen when:
Deleting and recreating agent pods
Using
dagster-cloud deployment settings set-from-file
To minimize the occurrence of duplicate code locations, use kubectl rollout restart when possible, as this ensures a more graceful shutdown and restart of the agent.
Note that in cases where configuration changes are needed, you'll need to:
First apply the configuration changes:
bash kubectl apply -fThen perform the rollout restart if needed
If duplicate code locations do appear, they may need to be manually cleaned up through the Dagster interface. This issue can occur due to:
New code locations being created instead of updating existing ones
Old locations not being properly deregistered
Race conditions during agent reconnection