@@ -20,6 +20,8 @@ use nexus_db_errors::public_error_from_diesel;
2020use nexus_db_lookup:: DbConnection ;
2121use nexus_db_model:: ReconfiguratorConfig as DbReconfiguratorConfig ;
2222use nexus_db_model:: SqlU32 ;
23+ use nexus_types:: deployment:: PlannerConfig ;
24+ use nexus_types:: deployment:: ReconfiguratorConfig ;
2325use nexus_types:: deployment:: ReconfiguratorConfigParam ;
2426use nexus_types:: deployment:: ReconfiguratorConfigView ;
2527use omicron_common:: api:: external:: DataPageParams ;
@@ -142,22 +144,38 @@ impl DataStore {
142144 ) ) ;
143145 }
144146
147+ // This statement exists just to trigger compilation errors when the
148+ // `ReconfiguratorConfigView` type changes so that people are prompted
149+ // to fix this query. If you get a compiler error here, you probably
150+ // added or removed a field to this type, and you will need to adjust
151+ // the query below accordingly.
152+ let ReconfiguratorConfigView {
153+ version,
154+ config :
155+ ReconfiguratorConfig {
156+ planner_enabled,
157+ planner_config :
158+ PlannerConfig { add_zones_with_mupdate_override } ,
159+ tuf_repo_pruner_enabled,
160+ } ,
161+ time_modified,
162+ } = * switches;
163+
145164 sql_query (
146165 r"INSERT INTO reconfigurator_config
147166 (version, planner_enabled, time_modified,
148- add_zones_with_mupdate_override)
149- SELECT $1, $2, $3, $4
167+ add_zones_with_mupdate_override, tuf_repo_pruner_enabled )
168+ SELECT $1, $2, $3, $4, $5
150169 WHERE $1 - 1 IN (
151170 SELECT COALESCE(MAX(version), 0)
152171 FROM reconfigurator_config
153172 )" ,
154173 )
155- . bind :: < sql_types:: BigInt , SqlU32 > ( switches. version . into ( ) )
156- . bind :: < sql_types:: Bool , _ > ( switches. config . planner_enabled )
157- . bind :: < sql_types:: Timestamptz , _ > ( switches. time_modified )
158- . bind :: < sql_types:: Bool , _ > (
159- switches. config . planner_config . add_zones_with_mupdate_override ,
160- )
174+ . bind :: < sql_types:: BigInt , SqlU32 > ( version. into ( ) )
175+ . bind :: < sql_types:: Bool , _ > ( planner_enabled)
176+ . bind :: < sql_types:: Timestamptz , _ > ( time_modified)
177+ . bind :: < sql_types:: Bool , _ > ( add_zones_with_mupdate_override)
178+ . bind :: < sql_types:: Bool , _ > ( tuf_repo_pruner_enabled)
161179 . execute_async ( conn)
162180 . await
163181 . map_err ( |e| public_error_from_diesel ( e, ErrorHandler :: Server ) )
@@ -186,12 +204,13 @@ mod tests {
186204 . is_empty( )
187205 ) ;
188206
189- // Fail to insert a swtiches with version 0
207+ // Fail to insert version 0
190208 let mut switches = ReconfiguratorConfigParam {
191209 version : 0 ,
192210 config : ReconfiguratorConfig {
193211 planner_enabled : false ,
194212 planner_config : PlannerConfig :: default ( ) ,
213+ tuf_repo_pruner_enabled : true ,
195214 } ,
196215 } ;
197216
0 commit comments