github.com/juju/juju@v0.0.0-20240327075706-a90865de2538/worker/uniter/remotestate/snapshot.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package remotestate
     5  
     6  import (
     7  	"github.com/juju/names/v5"
     8  
     9  	"github.com/juju/juju/core/life"
    10  	"github.com/juju/juju/core/model"
    11  	"github.com/juju/juju/core/secrets"
    12  	"github.com/juju/juju/rpc/params"
    13  )
    14  
    15  // Snapshot is a snapshot of the remote state of the unit.
    16  type Snapshot struct {
    17  	// Life is the lifecycle state of the unit.
    18  	Life life.Value
    19  
    20  	// Relations contains the lifecycle states of
    21  	// each of the application's relations, keyed by
    22  	// relation IDs.
    23  	Relations map[int]RelationSnapshot
    24  
    25  	// Storage contains the lifecycle and attached
    26  	// states of each of the unit's storage attachments.
    27  	Storage map[names.StorageTag]StorageSnapshot
    28  
    29  	// CharmModifiedVersion is increased whenever the application's charm was
    30  	// changed in some way.
    31  	CharmModifiedVersion int
    32  
    33  	// CharmURL is the string representation of charm URL that the unit is
    34  	// expected to run.
    35  	CharmURL string
    36  
    37  	// ForceCharmUpgrade reports whether the unit
    38  	// should upgrade even in an error state.
    39  	ForceCharmUpgrade bool
    40  
    41  	// ResolvedMode reports the method of resolving
    42  	// hook execution errors.
    43  	ResolvedMode params.ResolvedMode
    44  
    45  	// ProviderID is the cloud container's provider ID.
    46  	ProviderID string
    47  
    48  	// RetryHookVersion increments each time a failed
    49  	// hook is meant to be retried if ResolvedMode is
    50  	// set to ResolvedNone.
    51  	RetryHookVersion int
    52  
    53  	// ConfigHash is a hash of the last published version of the
    54  	// unit's config settings.
    55  	ConfigHash string
    56  
    57  	// TrustHash is a hash of the last published version of the unit's
    58  	// trust settings.
    59  	TrustHash string
    60  
    61  	// AddressesHash is a hash of the last published addresses for the
    62  	// unit's machine/container.
    63  	AddressesHash string
    64  
    65  	// Leader indicates whether or not the unit is the
    66  	// elected leader.
    67  	Leader bool
    68  
    69  	// LeaderSettingsVersion is the last published
    70  	// version of the leader settings for the application.
    71  	LeaderSettingsVersion int
    72  
    73  	// UpdateStatusVersion increments each time an
    74  	// update-status hook is supposed to run.
    75  	UpdateStatusVersion int
    76  
    77  	// ActionsPending is the list of pending actions to
    78  	// be performed by this unit.
    79  	ActionsPending []string
    80  
    81  	// ActionChanged contains a monotonically incrementing
    82  	// integer to signify changes in the Action's remote state.
    83  	ActionChanged map[string]int
    84  
    85  	// ActionsBlocked is true on CAAS when actions cannot be run due to
    86  	// pod initialization.
    87  	ActionsBlocked bool
    88  
    89  	// Commands is the list of IDs of commands to be
    90  	// executed by this unit.
    91  	Commands []string
    92  
    93  	// SecretRotations is a list of secret URIs that need to be rotated.
    94  	SecretRotations []string
    95  
    96  	// ExpiredSecretRevisions is a list of secret revisions that need to be expired.
    97  	ExpiredSecretRevisions []string
    98  
    99  	// ConsumedSecretInfo is a list of the labels and revision info
   100  	// for secrets consumed by this unit.
   101  	// The map is keyed on secret URI.
   102  	ConsumedSecretInfo map[string]secrets.SecretRevisionInfo
   103  
   104  	// ObsoleteSecretRevisions is a list of the obsolete
   105  	// revisions for secrets owned by this unit.
   106  	ObsoleteSecretRevisions map[string][]int
   107  
   108  	// DeletedSecrets is a list of deleted secret
   109  	// URIs owned by this unit.
   110  	DeletedSecrets []string
   111  
   112  	// UpgradeMachineStatus is the preparation status of
   113  	// any currently running machine upgrade.
   114  	UpgradeMachineStatus model.UpgradeSeriesStatus
   115  
   116  	// UpgradeMachineTarget is the OS base that an in-flight
   117  	// machine upgrade is transitioning to.
   118  	UpgradeMachineTarget string
   119  
   120  	// ContainerRunningStatus is set on CAAS models
   121  	// for remote init/upgrade of charm.
   122  	ContainerRunningStatus *ContainerRunningStatus
   123  
   124  	// LXDProfileName is the name of the lxd profile applied to the unit's
   125  	// machine for the current charm version.
   126  	LXDProfileName string
   127  
   128  	// CharmProfileRequired is true if the charm has a lxdprofile.yaml.
   129  	CharmProfileRequired bool
   130  
   131  	// WorkloadEvents is a list of IDs of workload events that need to be
   132  	// processed.
   133  	WorkloadEvents []string
   134  
   135  	// Shutdown is true on CAAS sidecar applications when SIGTERM is recevied
   136  	// but the unit isn't going to die, just a uniter restart/pod reschedule.
   137  	Shutdown bool
   138  }
   139  
   140  // RelationSnapshot tracks the state of a relationship from the viewpoint of the local unit.
   141  type RelationSnapshot struct {
   142  	// Life indicates whether this relation is active, stopping or dead
   143  	Life life.Value
   144  
   145  	// Suspended is used by cross-model relations to indicate the offer has
   146  	// disabled the relation, but has not removed it entirely.
   147  	Suspended bool
   148  
   149  	// Members tracks the Change version of each member's data bag
   150  	Members map[string]int64
   151  
   152  	// ApplicationMembers tracks the Change version of each member's application data bag
   153  	ApplicationMembers map[string]int64
   154  }
   155  
   156  // StorageSnapshot has information relating to a storage
   157  // instance belonging to a unit.
   158  type StorageSnapshot struct {
   159  	Kind     params.StorageKind
   160  	Life     life.Value
   161  	Attached bool
   162  	Location string
   163  }