status

package
v0.0.0-...-0a6fc28 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: AGPL-3.0 Imports: 4 Imported by: 149

Documentation

Index

Constants

View Source
const (
	MessageWaitForMachine    = "waiting for machine"
	MessageWaitForContainer  = "waiting for container"
	MessageInstallingAgent   = "installing agent"
	MessageInitializingAgent = "agent initialising"
	MessageInstallingCharm   = "installing charm software"
)

Variables

This section is empty.

Functions

func ActiveTaskStatuses

func ActiveTaskStatuses() []string

ActiveTaskStatuses returns a slice of strings representing the possible statuses of an active task.

func AllHistoryKind

func AllHistoryKind() map[HistoryKind]string

AllHistoryKind will return all valid HistoryKinds.

func IsAgentPresent

func IsAgentPresent(status StatusInfo) bool

IsAgentPresent returns true if the agent is idle or executing.

func IsInstancePresent

func IsInstancePresent(status StatusInfo) bool

IsInstancePresent returns true if the instance is running.

func IsMachinePresent

func IsMachinePresent(status StatusInfo) bool

IsMachinePresent returns true if the machine is started.

func IsUnitWorkloadPresent

func IsUnitWorkloadPresent(status StatusInfo) bool

IsUnitWorkloadPresent returns true if the unit workload is active, or is in a state where it is expected to become active.

func ValidModelStatus

func ValidModelStatus(status Status) bool

ValidModelStatus returns true if status has a valid value (that is to say, a value that it's OK to set) for models.

func ValidWorkloadStatus

func ValidWorkloadStatus(status Status) bool

ValidWorkloadStatus returns true if status has a valid value (that is to say, a value that it's OK to set) for units or applications.

Types

type DetailedStatus

type DetailedStatus struct {
	Status Status
	Info   string
	Data   map[string]any
	Since  *time.Time
	Kind   HistoryKind
}

DetailedStatus holds status info about a machine or unit agent.

type History

type History []DetailedStatus

History holds many DetailedStatus,

type HistoryKind

type HistoryKind string

HistoryKind represents the possible types of status history entries.

const (
	// KindModel represents the model itself.
	KindModel HistoryKind = "model"
	// KindApplication represents an entry for an application.
	KindApplication HistoryKind = "application"
	// KindSAAS represents an entry for a saas application.
	KindSAAS HistoryKind = "saas"
	// KindUnit represents agent and workload combined.
	KindUnit HistoryKind = "unit"
	// KindUnitAgent represent a unit agent status history entry.
	KindUnitAgent HistoryKind = "juju-unit"
	// KindWorkload represents a charm workload status history entry.
	KindWorkload HistoryKind = "workload"
	// KindMachineInstance represents an entry for a machine instance.
	KindMachineInstance HistoryKind = "machine"
	// KindMachine represents an entry for a machine agent.
	KindMachine HistoryKind = "juju-machine"
	// KindContainerInstance represents an entry for a container instance.
	KindContainerInstance HistoryKind = "container"
	// KindContainer represents an entry for a container agent.
	KindContainer HistoryKind = "juju-container"
	// KindFilesystem represents an entry for a filesystem.
	KindFilesystem HistoryKind = "filesystem"
	// KindVolume represents an entry for a volume.
	KindVolume HistoryKind = "volume"
	// KindTask represents a task in an operation.
	KindTask HistoryKind = "task"
)

IMPORTANT DEV NOTE: when changing this HistoryKind list in any way, these may need to be revised:

* HistoryKind.Valid() * AllHistoryKind() * command help for 'show-status-log' describing these kinds.

func (HistoryKind) String

func (k HistoryKind) String() string

String returns a string representation of the HistoryKind.

func (HistoryKind) Valid

func (k HistoryKind) Valid() bool

Valid will return true if the current kind is a valid one.

type InstanceStatusHistoryGetter

type InstanceStatusHistoryGetter interface {
	InstanceStatusHistory(filter StatusHistoryFilter) ([]StatusInfo, error)
}

InstanceStatusHistoryGetter instances can fetch their instance status history.

type ModificationStatusGetter

type ModificationStatusGetter interface {
	ModificationStatus() (StatusInfo, error)
}

ModificationStatusGetter represents a type whose modification status can be read.

type Status

type Status string

Status used to represent the status of an entity, but has recently become and applies to "workloads" as well, which we don't currently model, for no very clear reason.

Status values currently apply to machine (agents), unit (agents), unit (workloads), application (workloads), volumes, filesystems, and models.

const (

	// Stopped is set when:
	// The machine's agent will perform no further action, other than
	// to set the unit to Dead at a suitable moment.
	Stopped Status = "stopped"

	// Down is set when:
	// The machine ought to be signalling activity, but it cannot be
	// detected.
	Down Status = "down"
)
const (

	// Allocating is set when:
	// The machine on which a unit is to be hosted is still being
	// spun up in the cloud.
	Allocating Status = "allocating"

	// Rebooting is set when:
	// The machine on which this agent is running is being rebooted.
	// The juju-agent should move from rebooting to idle when the reboot is complete.
	Rebooting Status = "rebooting"

	// Executing is set when:
	// The agent is running a hook or task. The human-readable message should reflect
	// which hook or task is being run.
	Executing Status = "executing"

	// Idle is set when:
	// Once the agent is installed and running it will notify the Juju server and its state
	// becomes "idle". It will stay "idle" until some action (e.g. it needs to run a hook) or
	// error (e.g it loses contact with the Juju server) moves it to a different state.
	Idle Status = "idle"

	// Lost is set when:
	// The juju agent has not communicated with the juju server for an unexpectedly long time;
	// the unit agent ought to be signalling activity, but none has been detected.
	Lost Status = "lost"
)
const (

	// Unset is only for applications, and is a placeholder status.
	// The core/cache package deals with aggregating the unit status
	// to the application level.
	Unset Status = "unset"

	// Maintenance is set when:
	// The unit is not yet providing services, but is actively doing stuff
	// in preparation for providing those services.
	// This is a "spinning" state, not an error state.
	// It reflects activity on the unit itself, not on peers or related units.
	Maintenance Status = "maintenance"

	// Terminated is set when:
	// This unit used to exist, we have a record of it (perhaps because of storage
	// allocated for it that was flagged to survive it). Nonetheless, it is now gone.
	Terminated Status = "terminated"

	// Unknown is set when:
	// A unit-agent has finished calling install, config-changed, and start,
	// but the charm has not called status-set yet.
	Unknown Status = "unknown"

	// Waiting is set when:
	// The unit is unable to progress to an active state because an application to
	// which it is related is not running.
	Waiting Status = "waiting"

	// Blocked is set when:
	// The unit needs manual intervention to get back to the Running state.
	Blocked Status = "blocked"

	// Active is set when:
	// The unit believes it is correctly offering all the services it has
	// been asked to offer.
	Active Status = "active"
)
const (

	// Attaching indicates that the storage is being attached
	// to a machine.
	Attaching Status = "attaching"

	// Attached indicates that the storage is attached to a
	// machine.
	Attached Status = "attached"

	// Detaching indicates that the storage is being detached
	// from a machine.
	Detaching Status = "detaching"

	// Detached indicates that the storage is not attached to
	// any machine.
	Detached Status = "detached"
)
const (

	// Available indicates that the model is available for use.
	Available Status = "available"

	// Busy indicates that the model is not available for use because it is
	// running a process that must take the model offline, such as a migration,
	// upgrade, or backup.  This is a spinning state, it is not an error state,
	// and it should be expected that the model will eventually go back to
	// available.
	Busy Status = "busy"
)
const (

	// Joining is used to signify that a relation should become joined soon.
	Joining Status = "joining"

	// Joined is the normal status for a healthy, alive relation.
	Joined Status = "joined"

	// Broken is the status for when a relation life goes to Dead.
	Broken Status = "broken"

	// Suspending is used to signify that a relation will be temporarily broken
	// pending action to resume it.
	Suspending Status = "suspending"

	// Suspended is used to signify that a relation is temporarily broken pending
	// action to resume it.
	Suspended Status = "suspended"
)
const (

	// Completed indicates that the task ran to completion as intended.
	Completed Status = "completed"

	// Cancelled means that the task was cancelled before being run.
	Cancelled Status = "cancelled"

	// Aborting indicates that the task is running but should be
	// aborted.
	Aborting Status = "aborting"

	// Aborted indicates the task was aborted.
	// TODO: is this really used? What is the difference between aborted
	// and cancelled?
	Aborted Status = "aborted"
)
const (
	Empty             Status = ""
	Provisioning      Status = "allocating"
	ProvisioningError Status = "provisioning error"
)

InstanceStatus

const (

	// Destroying indicates that the entity is being destroyed.
	//
	// This is valid for volumes, filesystems, and models.
	Destroying Status = "destroying"
)
const (

	// Error means the entity requires human intervention
	// in order to operate correctly.
	//
	// The task did not get run due to an error.
	Error Status = "error"
)
const (

	// Failed is set when:
	//
	// The unit agent has failed in some way,eg the agent ought to be signalling
	// activity, but it cannot be detected. It might also be that the unit agent
	// detected an unrecoverable condition and managed to tell the Juju server about it.
	//
	// The task did not completed successfully.
	Failed Status = "failed"
)
const (

	// Pending is set when:
	//
	// The machine is not yet participating in the model.
	//
	// The task first is queued.
	Pending Status = "pending"
)
const (

	// Running indicates that the entity is currently running.
	Running Status = "running"
)
const (

	// Started is set when:
	// The entity is actively participating in the model.
	// For unit agents, this is a state we preserve for backwards
	// compatibility with scripts during the life of Juju 1.x.
	// In Juju 2.x, the agent-state will remain “active” and scripts
	// will watch the unit-state instead for signals of application readiness.
	Started Status = "started"
)

func (Status) IsInActiveTaskStatus

func (s Status) IsInActiveTaskStatus() bool

IsInActiveTaskStatus returns true if status has a known value for a completed task or operation.

func (Status) KnownAgentStatus

func (s Status) KnownAgentStatus() bool

KnownAgentStatus returns true if status has a known value for an agent. It includes every status that has ever been valid for a unit or machine agent. This is used by the apiserver client facade to filter out unknown values.

func (Status) KnownInstanceStatus

func (s Status) KnownInstanceStatus() bool

KnownInstanceStatus returns true if status has a known value for a machine cloud instance.

func (Status) KnownMachineStatus

func (s Status) KnownMachineStatus() bool

KnownMachineStatus returns true if status has a known value for a machine.

func (Status) KnownModificationStatus

func (s Status) KnownModificationStatus() bool

KnownModificationStatus returns true if the status has a known value for a modification of an instance.

func (Status) KnownTaskStatus

func (s Status) KnownTaskStatus() bool

KnownTaskStatus returns true if status has a known value for a task or operation.

func (Status) KnownWorkloadStatus

func (s Status) KnownWorkloadStatus() bool

KnownWorkloadStatus returns true if status has a known value for a workload. It includes every status that has ever been valid for a unit agent. This is used by the apiserver client facade to filter out unknown values.

func (Status) Matches

func (s Status) Matches(candidate Status) bool

Matches returns true if the candidate matches status, taking into account that the candidate may be a legacy status value which has been deprecated.

func (Status) String

func (s Status) String() string

String returns a string representation of the Status.

func (Status) WorkloadMatches

func (s Status) WorkloadMatches(candidate Status) bool

WorkloadMatches returns true if the candidate matches status, taking into account that the candidate may be a legacy status value which has been deprecated.

type StatusGetter

type StatusGetter interface {
	Status() (StatusInfo, error)
}

StatusGetter represents a type whose status can be read.

type StatusHistoryFilter

type StatusHistoryFilter struct {
	// Size indicates how many results are expected at most.
	Size int
	// FromDate indicates the earliest date from which logs are expected.
	FromDate *time.Time
	// Delta indicates the age of the oldest log expected.
	Delta *time.Duration
	// Exclude indicates the status messages that should be excluded
	// from the returned result.
	Exclude set.Strings
}

StatusHistoryFilter holds arguments that can be use to filter a status history backlog.

func (*StatusHistoryFilter) Validate

func (f *StatusHistoryFilter) Validate() error

Validate checks that the minimum requirements of a StatusHistoryFilter are met.

type StatusInfo

type StatusInfo struct {
	Status  Status
	Message string
	Data    map[string]any
	Since   *time.Time
}

StatusInfo holds a Status and associated information.

func UnitDisplayStatus

func UnitDisplayStatus(unitStatus, containerStatus StatusInfo) StatusInfo

UnitDisplayStatus is used for CAAS units where the status of the unit could be overridden by the status of the container.

type StatusSetter

type StatusSetter interface {
	SetStatus(StatusInfo) error
}

StatusSetter represents a type whose status can be set.

Jump to

Keyboard shortcuts

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