remotestate

package
v0.0.0-...-23dbee4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Charm

type Charm interface {
	// LXDProfileRequired returns true if this charm has an lxdprofile.yaml
	LXDProfileRequired() (bool, error)
}

type RelationSnapshot

type RelationSnapshot struct {
	// Life indicates whether this relation is active, stopping or dead
	Life life.Value

	// Suspended is used by cross-model relations to indicate the offer has
	// disabled the relation, but has not removed it entirely.
	Suspended bool

	// Members tracks the Change version of each member's data bag
	Members map[string]int64

	// ApplicationMembers tracks the Change version of each member's application data bag
	ApplicationMembers map[string]int64
}

RelationSnapshot tracks the state of a relationship from the viewpoint of the local unit.

type RemoteStateWatcher

type RemoteStateWatcher struct {
	// contains filtered or unexported fields
}

RemoteStateWatcher collects unit, application, and application config information from separate state watchers, and updates a Snapshot which is sent on a channel upon change.

func NewWatcher

func NewWatcher(config WatcherConfig) (*RemoteStateWatcher, error)

NewWatcher returns a RemoteStateWatcher that handles state changes pertaining to the supplied unit.

func (*RemoteStateWatcher) ClearResolvedMode

func (w *RemoteStateWatcher) ClearResolvedMode()

func (*RemoteStateWatcher) CommandCompleted

func (w *RemoteStateWatcher) CommandCompleted(completed string)

func (*RemoteStateWatcher) ExpireRevisionCompleted

func (w *RemoteStateWatcher) ExpireRevisionCompleted(expiredRevision string)

ExpireRevisionCompleted is called when a secret revision has been expired.

func (*RemoteStateWatcher) Kill

func (w *RemoteStateWatcher) Kill()

Kill is part of the worker.Worker interface.

func (*RemoteStateWatcher) RemoteStateChanged

func (w *RemoteStateWatcher) RemoteStateChanged() <-chan struct{}

func (*RemoteStateWatcher) RemoveSecretsCompleted

func (w *RemoteStateWatcher) RemoveSecretsCompleted(uris []string)

RemoveSecretsCompleted is called when secrets have been deleted.

func (*RemoteStateWatcher) RotateSecretCompleted

func (w *RemoteStateWatcher) RotateSecretCompleted(rotatedURL string)

RotateSecretCompleted is called when a secret identified by the URL has been rotated.

func (*RemoteStateWatcher) Snapshot

func (w *RemoteStateWatcher) Snapshot() Snapshot

func (*RemoteStateWatcher) Wait

func (w *RemoteStateWatcher) Wait() error

Wait is part of the worker.Worker interface.

func (*RemoteStateWatcher) WorkloadEventCompleted

func (w *RemoteStateWatcher) WorkloadEventCompleted(workloadEventID string)

type SecretTriggerWatcherFunc

type SecretTriggerWatcherFunc func(names.UnitTag, bool, chan []string) (worker.Worker, error)

SecretTriggerWatcherFunc is a function returning a secrets trigger watcher.

type Snapshot

type Snapshot struct {
	// Life is the lifecycle state of the unit.
	Life life.Value

	// Relations contains the lifecycle states of
	// each of the application's relations, keyed by
	// relation IDs.
	Relations map[int]RelationSnapshot

	// Storage contains the lifecycle and attached
	// states of each of the unit's storage attachments.
	Storage map[names.StorageTag]StorageSnapshot

	// CharmModifiedVersion is increased whenever the application's charm was
	// changed in some way.
	CharmModifiedVersion int

	// CharmURL is the string representation of charm URL that the unit is
	// expected to run.
	CharmURL string

	// ForceCharmUpgrade reports whether the unit
	// should upgrade even in an error state.
	ForceCharmUpgrade bool

	// ResolvedMode reports the method of resolving
	// hook execution errors.
	ResolvedMode params.ResolvedMode

	// ProviderID is the cloud container's provider ID.
	ProviderID string

	// RetryHookVersion increments each time a failed
	// hook is meant to be retried if ResolvedMode is
	// set to ResolvedNone.
	RetryHookVersion int

	// ConfigHash is a hash of the last published version of the
	// unit's config settings.
	ConfigHash string

	// TrustHash is a hash of the last published version of the unit's
	// trust settings.
	TrustHash string

	// AddressesHash is a hash of the last published addresses for the
	// unit's machine/container.
	AddressesHash string

	// Leader indicates whether or not the unit is the
	// elected leader.
	Leader bool

	// LeaderSettingsVersion is the last published
	// version of the leader settings for the application.
	LeaderSettingsVersion int

	// UpdateStatusVersion increments each time an
	// update-status hook is supposed to run.
	UpdateStatusVersion int

	// ActionsPending is the list of pending actions to
	// be performed by this unit.
	ActionsPending []string

	// ActionChanged contains a monotonically incrementing
	// integer to signify changes in the Action's remote state.
	ActionChanged map[string]int

	// Commands is the list of IDs of commands to be
	// executed by this unit.
	Commands []string

	// SecretRotations is a list of secret URIs that need to be rotated.
	SecretRotations []string

	// ExpiredSecretRevisions is a list of secret revisions that need to be expired.
	ExpiredSecretRevisions []string

	// ConsumedSecretInfo is a list of the labels and revision info
	// for secrets consumed by this unit.
	// The map is keyed on secret URI.
	ConsumedSecretInfo map[string]secrets.SecretRevisionInfo

	// ObsoleteSecretRevisions is a list of the obsolete
	// revisions for secrets owned by this unit.
	ObsoleteSecretRevisions map[string][]int

	// DeletedSecrets is a list of deleted secret
	// URIs owned by this unit.
	DeletedSecrets []string

	// LXDProfileName is the name of the lxd profile applied to the unit's
	// machine for the current charm version.
	LXDProfileName string

	// CharmProfileRequired is true if the charm has a lxdprofile.yaml.
	CharmProfileRequired bool

	// WorkloadEvents is a list of IDs of workload events that need to be
	// processed.
	WorkloadEvents []string

	// Shutdown is true on CAAS sidecar applications when SIGTERM is recevied
	// but the unit isn't going to die, just a uniter restart/pod reschedule.
	Shutdown bool
}

Snapshot is a snapshot of the remote state of the unit.

type StorageAccessor

type StorageAccessor interface {
	// StorageAttachment returns the storage attachment with the specified
	// unit and storage tags.
	StorageAttachment(context.Context, names.StorageTag, names.UnitTag) (params.StorageAttachment, error)
}

type StorageSnapshot

type StorageSnapshot struct {
	Kind     params.StorageKind
	Life     life.Value
	Attached bool
	Location string
}

StorageSnapshot has information relating to a storage instance belonging to a unit.

type UniterClient

type UniterClient interface {
	Charm(url string) (api.Charm, error)
	Relation(ctx context.Context, tag names.RelationTag) (api.Relation, error)
	StorageAttachment(context.Context, names.StorageTag, names.UnitTag) (params.StorageAttachment, error)
	StorageAttachmentLife(context.Context, []params.StorageAttachmentId) ([]params.LifeResult, error)
	Unit(context.Context, names.UnitTag) (api.Unit, error)
	WatchRelationUnits(context.Context, names.RelationTag, names.UnitTag) (watcher.RelationUnitsWatcher, error)
	WatchStorageAttachment(context.Context, names.StorageTag, names.UnitTag) (watcher.NotifyWatcher, error)
	WatchUpdateStatusHookInterval(context.Context) (watcher.NotifyWatcher, error)
	UpdateStatusHookInterval(context.Context) (time.Duration, error)
}

type UpdateStatusTimerFunc

type UpdateStatusTimerFunc func(duration time.Duration) Waiter

type Waiter

type Waiter interface {
	After() <-chan time.Time
}

type Watcher

type Watcher interface {
	// RemoteStateChanged returns a channel which is signalled
	// whenever the remote state is changed.
	RemoteStateChanged() <-chan struct{}

	// Snapshot returns the current snapshot of the remote state.
	Snapshot() Snapshot

	worker.Worker
}

type WatcherConfig

type WatcherConfig struct {
	UniterClient                 UniterClient
	LeadershipTracker            leadership.Tracker
	SecretRotateWatcherFunc      SecretTriggerWatcherFunc
	SecretExpiryWatcherFunc      SecretTriggerWatcherFunc
	SecretsClient                api.SecretsWatcher
	UpdateStatusChannel          UpdateStatusTimerFunc
	CommandChannel               <-chan string
	RetryHookChannel             watcher.NotifyChannel
	UnitTag                      names.UnitTag
	ModelType                    model.ModelType
	Sidecar                      bool
	EnforcedCharmModifiedVersion int
	Logger                       logger.Logger
	CanApplyCharmProfile         bool
	WorkloadEventChannel         <-chan string
	InitialWorkloadEventIDs      []string
	ShutdownChannel              <-chan bool
}

WatcherConfig holds configuration parameters for the remote state watcher.

Jump to

Keyboard shortcuts

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