pulumi/pkg/graph
Will Jones 07322d6b98
Support topologically sorting snapshots (#17403)
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.
2024-10-01 08:45:35 +00:00
..
dotconv Adds a flag to graph command to insert fragment (#14858) 2024-01-08 22:03:08 +00:00
graph.go Add license headers 2018-05-22 15:02:47 -07:00
toposort.go Support topologically sorting snapshots (#17403) 2024-10-01 08:45:35 +00:00