@@ -58,6 +58,24 @@ pub struct Instance {
58
58
59
59
#[ diesel( embed) ]
60
60
pub runtime_state : InstanceRuntimeState ,
61
+
62
+ /// A UUID identifying the saga currently holding the update lock on this
63
+ /// instance. If this is [`None`] the instance is not locked. Otherwise, if
64
+ /// this is [`Some`], the instance is locked by the saga owning this UUID.
65
+ /// Note that this is not (presently) the UUID *of* the locking saga, but
66
+ /// rather, a UUID *generated by* that saga. Therefore, it may not be
67
+ /// useable to look up which saga holds the lock.
68
+ ///
69
+ /// This field is guarded by the instance's `updater_gen`
70
+ #[ diesel( column_name = updater_id) ]
71
+ pub updater_id : Option < Uuid > ,
72
+
73
+ /// The generation number for the updater lock. This is updated whenever the
74
+ /// lock is acquired or released, and is used in attempts to set the
75
+ /// `updater_id` field to ensure that the snapshot which indicated that the
76
+ /// lock was not held is still valid when setting the lock ID.
77
+ #[ diesel( column_name = updater_gen) ]
78
+ pub updater_gen : Generation ,
61
79
}
62
80
63
81
impl Instance {
@@ -85,6 +103,9 @@ impl Instance {
85
103
hostname : params. hostname . to_string ( ) ,
86
104
boot_on_fault : false ,
87
105
runtime_state,
106
+
107
+ updater_gen : Generation :: new ( ) ,
108
+ updater_id : None ,
88
109
}
89
110
}
90
111
@@ -171,24 +192,6 @@ pub struct InstanceRuntimeState {
171
192
#[ diesel( column_name = migration_id) ]
172
193
pub migration_id : Option < Uuid > ,
173
194
174
- /// A UUID identifying the saga currently holding the update lock on this
175
- /// instance. If this is [`None`] the instance is not locked. Otherwise, if
176
- /// this is [`Some`], the instance is locked by the saga owning this UUID.
177
- /// Note that this is not (presently) the UUID *of* the locking saga, but
178
- /// rather, a UUID *generated by* that saga. Therefore, it may not be
179
- /// useable to look up which saga holds the lock.
180
- ///
181
- /// This field is guarded by the instance's `updater_gen`
182
- #[ diesel( column_name = updater_id) ]
183
- pub updater_id : Option < Uuid > ,
184
-
185
- /// The generation number for the updater lock. This is updated whenever the
186
- /// lock is acquired or released, and is used in attempts to set the
187
- /// `updater_id` field to ensure that the snapshot which indicated that the
188
- /// lock was not held is still valid when setting the lock ID.
189
- #[ diesel( column_name = updater_gen) ]
190
- pub updater_gen : Generation ,
191
-
192
195
/// The "internal" state of this instance. The instance's externally-visible
193
196
/// state may be delegated to the instance's active VMM, if it has one.
194
197
///
@@ -206,8 +209,6 @@ impl InstanceRuntimeState {
206
209
dst_propolis_id : None ,
207
210
migration_id : None ,
208
211
gen : Generation :: new ( ) ,
209
- updater_gen : Generation :: new ( ) ,
210
- updater_id : None ,
211
212
}
212
213
}
213
214
}
@@ -231,8 +232,6 @@ impl From<omicron_common::api::internal::nexus::InstanceRuntimeState>
231
232
propolis_id : state. propolis_id ,
232
233
dst_propolis_id : state. dst_propolis_id ,
233
234
migration_id : state. migration_id ,
234
- updater_gen : Generation :: new ( ) ,
235
- updater_id : None ,
236
235
}
237
236
}
238
237
}
0 commit comments