Documentation
¶
Overview ¶
Package finalizer removes what a cloud suite run left behind in the shared organisation.
The framework's cleanup registry deletes only what a scenario registered and gives up on a delete that failed, so a failed scenario, a refused delete or an interrupted step can leave resources in a long-lived organisation. A Tracker records the name suffix of every runner of a run and, after the run, deletes each entry of the organisation's collections that is named with one of those suffixes. It is shared by the cloud suite's step packages; each supplies the Collections of the platform it drives.
Index ¶
Constants ¶
const DefaultMinAttempt = 15 * time.Second
DefaultMinAttempt is the time a deletion gets when its collection's Timeout is already spent.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collection ¶
type Collection struct {
// Name identifies the collection in diagnostics and in the removed list.
Name string
// List returns the entries of the collection. When it fails part way it may return the
// entries it read together with the error; those are still swept and the error is reported.
List func(ctx context.Context) ([]Leftover, error)
// Delete removes one entry by its ID. An entry that is already gone is not an error.
Delete func(ctx context.Context, id string) error
// Timeout bounds the time this collection may spend, within the caller's own deadline. Each
// deletion may use what is left of it. Once it is spent, a deletion still gets MinAttempt, so
// no leftover goes without an attempt. Zero leaves only the caller's deadline.
Timeout time.Duration
// MinAttempt is the time a deletion gets after Timeout is spent. Zero means
// DefaultMinAttempt.
MinAttempt time.Duration
}
Collection is one list of the system under test that a Tracker reads and deletes from.
type Leftover ¶
type Leftover struct {
// ID is what Collection.Delete needs to delete the entry.
ID string
// Names are every value a generated name can appear in for this entry, such as its id,
// handle and display name. A handle cut to fit a length limit loses the runner suffix, but
// the display name it was cut from keeps it.
Names []string
}
Leftover is one entry a Sweep found in the system under test.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker holds the runner suffixes of one run and sweeps the organisation for entries named with them. Every name from the framework's unique generator carries its runner's suffix.
func NewTracker ¶
NewTracker returns a Tracker that has seen no runner yet. A nil logger selects the default logger.
func (*Tracker) Owns ¶
Owns reports whether any of the names carries the suffix of a tracked runner.
func (*Tracker) Sweep ¶
Sweep runs through the collections in order. For each it lists the collection, keeps the entries named with a tracked suffix and deletes them, carrying on past a failure. It returns what it removed as "<collection name>/<id>", each one a leak the registry cleanup missed, and the joined errors for what it could not list or delete.