Help us shape the future of Go! Take the 2026 Go Developer Survey

lifecycle

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACLNotRequested = "not_requested"
	ACLStillInUse   = "still_in_use"
	ACLSkipped      = "skipped"
)

Variables

This section is empty.

Functions

func UnretiredOrphanServices

func UnretiredOrphanServices(registryPath, ownershipPath string) ([]string, error)

UnretiredOrphanServices lists the services whose remote device deletion is dormant because an ownership record for them has no retired_at while they are absent from a present, valid registry.json. It reads local files only, so doctor can report it without calling the Tailscale API. A registry file that is missing or blank makes every deletion dormant for that reason instead, and yields no names.

Types

type AdoptionResult

type AdoptionResult struct {
	ServiceName string `json:"service_name"`
	Matches     int    `json:"matches"`
	Written     bool   `json:"written"`
}

type Options

type Options struct {
	RegistryPath      string
	OwnershipPath     string
	OwnershipOverride *tsruntime.OwnershipLedger
	Now               time.Time
	DryRun            bool
	ManageACL         bool
	// CheckUnusedACL asks this run to report on the shared Funnel grant.
	// Local absence cannot authorize deletion of a tailnet-wide shared grant,
	// so the report is a skip with a warning, never a deletion.
	CheckUnusedACL bool
	// CleanLocalNodeState allows this run to delete the local tsnet state
	// directory of an orphan service whose remote nodes it proved are gone.
	//
	// It is off by default and set only by the daemon, because the daemon is
	// the process that can answer LocalNodeStateInUse. A separate `tslink
	// cleanup` process cannot see another process's tsnet servers, so it leaves
	// the directories alone rather than guessing.
	CleanLocalNodeState bool
	// LocalNodeStateInUse reports whether a tsnet server in this process still
	// holds the state directory for serviceName.
	//
	// It is required whenever CleanLocalNodeState is set, and a nil function
	// disables the cleanup instead of being read as "nothing holds any state".
	// "Nobody told me" and "nothing holds it" are different statements, and
	// only the caller can tell them apart.
	LocalNodeStateInUse func(serviceName string) bool
	// WithNodeStateLock serializes the final local deletion with this daemon's
	// service startup. The network cleanup runs outside this short lock.
	WithNodeStateLock func(func() error) error
	// TryWithNodeStateLock is the daemon's nonblocking startup gate. A false
	// result means cleanup must retain state and retry on a later tick.
	TryWithNodeStateLock func(context.Context, func() error) (bool, error)
}

type Result

type Result struct {
	DryRun                      bool            `json:"dry_run"`
	RegistryChanged             bool            `json:"registry_changed"`
	ExpiredFunnels              []string        `json:"expired_funnels"`
	DevicesMatched              []string        `json:"devices_matched"`
	DevicesWouldDelete          []string        `json:"devices_would_delete"`
	DevicesDeleted              []string        `json:"devices_deleted"`
	DevicesProtected            []string        `json:"devices_protected"`
	DevicesAdopted              []string        `json:"devices_adopted,omitempty"`
	Adoption                    *AdoptionResult `json:"adoption,omitempty"`
	DeviceCleanupSkipped        bool            `json:"device_cleanup_skipped"`
	DeviceSkipReason            string          `json:"device_skip_reason,omitempty"`
	DeviceSkipUnknownProvenance []string        `json:"device_skip_unknown_provenance,omitempty"`
	ACLAction                   string          `json:"acl_action"`
	Warnings                    []string        `json:"warnings,omitempty"`
	// ExpiredFunnelsNotWritten names services whose Funnel deadline has
	// passed while another registry entry has a problem of its own, so the
	// downgrade was not written to registry.json. A daemon withdraws them in
	// memory at every sync and must sync; the warning reports them.
	ExpiredFunnelsNotWritten []string `json:"-"`
}

Result intentionally contains service/hostname labels but never NodeIDs.

func Reconcile

func Reconcile(ctx context.Context, options Options) (Result, error)

Reconcile is the single lifecycle implementation used by cleanup, serve startup, and the serve wall-clock ticker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL