pulumi: delete-before-replace triggers delete-before-replace in all dependencies
Following up from this community Slack thread, there is a bug where:
- The user changes data in a manually-named Kubernetes
ConfigMap, which triggers a delete-before-replace. - The user references that
ConfigMapin aDeployment. - Because step generator believes that any resource that is marked delete-before-replace must also have all its dependencies transitively marked delete-before-replace (specifically this line), we delete the entire
Deployment.
This is very bad for Kubernetes. It means that changing data in a ConfigMap can trigger a complete delete-first tear-down and rebuild of your application, including a stateful application.
The comment explaining this asserts that this is true, but I’m not really sure why it would be – why, in particular, would we need to mark resources that actually don’t need to be deleted at all, as delete-before-create?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 37 (33 by maintainers)
@naveensrinivasan We apologize for the delay here. This is a subtle and tricky issue, so it’s taken a bit of time to discuss and design. That said, it’s in our current sprint, and we will be acting on this soon. Expect a more detailed update tomorrow on the plans and timeframe on a fix.
The PR for this is in progress at https://github.com/pulumi/pulumi/pull/2369. Currently expecting this to be available next week (hopefully early next week).
Great! We are being blocked by the EKS issue referred here.
This may not in fact be TF’s behavior. Consider the following config:
If I deploy this, then change the name of the first bucket, then run an
apply, the second bucket is not replaced:I also don’t know whether you’d want to let a resource make a decision about its dependents. In general, this would seem to be something that only those dependents would be qualified to decide.
I am open to re-considering, but I am pretty confident that this a better for nearly all real-world applications:
Pod. Triggering a rollout ties the changes inConfigMap(which usually configures, e.g., nginx) to the well-understood liveness and readniness semantics of thePod. Using the live-update feature meansPods will simply update whenever the kubelet syncs, and you may never be alerted that something went wrong.ConfigMaparound, so if roll-forward fails, you not only have access to the old version of the application, but that old version doesn’t accidentally get live-updated, because it still references the oldConfigMap.Deployment, or they can roll their own fairly easily with nakedReplicaSets. In contrast, the live-update feature will simply update anyPodwhenever TTL cache expires and the kubelet syncs.ConfigMapchanges. In all of the cases I have seen, except one, I believe the “correct” way is to go route Pulumi goes instead.ConfigMap.As I said, I’m always super open to cases where I’ve missed something, but as it stands now, these to me are very compelling reasons to keep things as they are.
The behavior that this issue describes is due to three intersecting features:
ConfigMapsIn reverse order:
ConfigMaps as immutable in order to trigger rollouts when they are updated. We believe that this is consistent with the general expectation aroundConfigMaps. As such, any change to aConfigMapcauses it to be replaced (i.e. the currentConfigMapis deleted and a new one created).pulumi update. If, however a resource A is being deleted as part of a delete-before-replace, the deletions of A’s transitive dependents are scheduled at the same time as the deletion of A. This causes downtime and deletions that a user is unlikely to expect.We believe that it may be reasonable to avoid the cascading delete by default and instead allow resources to opt in to cascading deletes if necessary, and are investigating whether or not we can make this change without negatively affecting existing scenarios.