/
snapshot.go
163 lines (124 loc) · 4.82 KB
/
snapshot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package remotestate
import (
"github.com/juju/names/v5"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/model"
"github.com/juju/juju/core/secrets"
"github.com/juju/juju/rpc/params"
)
// Snapshot is a snapshot of the remote state of the unit.
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
// ActionsBlocked is true on CAAS when actions cannot be run due to
// pod initialization.
ActionsBlocked bool
// 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
// UpgradeMachineStatus is the preparation status of
// any currently running machine upgrade.
UpgradeMachineStatus model.UpgradeSeriesStatus
// UpgradeMachineTarget is the OS base that an in-flight
// machine upgrade is transitioning to.
UpgradeMachineTarget string
// ContainerRunningStatus is set on CAAS models
// for remote init/upgrade of charm.
ContainerRunningStatus *ContainerRunningStatus
// 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
}
// RelationSnapshot tracks the state of a relationship from the viewpoint of the local unit.
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
}
// StorageSnapshot has information relating to a storage
// instance belonging to a unit.
type StorageSnapshot struct {
Kind params.StorageKind
Life life.Value
Attached bool
Location string
}