mirror of https://github.com/pulumi/pulumi.git
07322d6b98
An important precondition of Pulumi state snapshots is that they are *topologically sorted* with respect to dependencies. That is, each resource in a state snapshot *must* appear *after* those that it depends on (where "depends" here means any kind of dependency relationship -- `Provider`, `Parent`, `DeletedWith`, and so on). The `Snapshot.VerifyIntegrity` method checks this property (among others) and, upon failure, yields a snapshot integrity error. It turns out that we don't currently have the ability to explicitly sort or re-sort a state snapshot. There are a couple of reasons for this: * Snapshots are typically built in response to resource registrations from a program, and we require that these registrations are sent in topological order. Indeed, for imperative languages, such as Python, Go, NodeJS, Java and C#, it is not possible to write a program that does *not* send its resource registrations in the appropriate order (at least not using the official SDKs). YAML, being the only currently-supported declarative language, sorts its registrations ahead of sending them to the engine in order to meet this precondition. * Eagerly sorting snapshots e.g. prior to writes would change the performance characteristics of the CLI on various hot paths, so is probably not something we want to do proactively/optimistically. However, when it comes to repairing snapshot integrity errors, we *do* want to sort broken states to bring them back to a good state. This commit thus introduces the `Snapshot.Toposort` method to this end, in preparation for integration into e.g. a `state repair` command in a later commit. |
||
---|---|---|
.. | ||
dotconv | ||
graph.go | ||
toposort.go |