5757 * no-update-watch = false
5858 * For testing purposes, simulate missing job-info.update-watch service
5959 * in parent instance by sending to an invalid service name.
60+ *
61+ * rediscover = false
62+ * Force rediscovery of local resources via hwloc. Do not fetch R or hwloc
63+ * XML from the enclosing instance.
6064 */
6165static int parse_config (struct resource_ctx * ctx ,
6266 const flux_conf_t * conf ,
63- const char * * excludep ,
64- json_t * * R ,
65- bool * noverifyp ,
66- bool * norestrictp ,
67- bool * no_update_watchp ,
67+ struct resource_config * rconfig ,
6868 flux_error_t * errp )
6969{
7070 flux_error_t error ;
@@ -74,20 +74,22 @@ static int parse_config (struct resource_ctx *ctx,
7474 int noverify = 0 ;
7575 int norestrict = 0 ;
7676 int no_update_watch = 0 ;
77+ int rediscover = 0 ;
7778 json_t * o = NULL ;
7879 json_t * config = NULL ;
7980
8081 if (flux_conf_unpack (conf ,
8182 & error ,
82- "{s?{s?s s?s s?o s?s s?b s?b s?b !}}" ,
83+ "{s?{s?s s?s s?o s?s s?b s?b s?b s?b !}}" ,
8384 "resource" ,
8485 "path" , & path ,
8586 "scheduling" , & scheduling_path ,
8687 "config" , & config ,
8788 "exclude" , & exclude ,
8889 "norestrict" , & norestrict ,
8990 "noverify" , & noverify ,
90- "no-update-watch" , & no_update_watch ) < 0 ) {
91+ "no-update-watch" , & no_update_watch ,
92+ "rediscover" , & rediscover ) < 0 ) {
9193 errprintf (errp ,
9294 "error parsing [resource] configuration: %s" ,
9395 error .text );
@@ -143,16 +145,14 @@ static int parse_config (struct resource_ctx *ctx,
143145 return -1 ;
144146 }
145147 }
146- if (excludep )
147- * excludep = exclude ;
148- if (noverifyp )
149- * noverifyp = noverify ? true : false;
150- if (norestrictp )
151- * norestrictp = norestrict ? true : false;
152- if (no_update_watchp )
153- * no_update_watchp = no_update_watch ? true : false;
154- if (R )
155- * R = o ;
148+ if (rconfig ) {
149+ rconfig -> exclude_idset = exclude ;
150+ rconfig -> noverify = noverify ? true : false;
151+ rconfig -> norestrict = norestrict ? true : false;
152+ rconfig -> no_update_watch = no_update_watch ? true : false;
153+ rconfig -> rediscover = rediscover ? true : false;
154+ rconfig -> R = o ;
155+ }
156156 else
157157 json_decref (o );
158158 return 0 ;
@@ -174,7 +174,7 @@ static void config_reload_cb (flux_t *h,
174174
175175 if (flux_conf_reload_decode (msg , & conf ) < 0 )
176176 goto error ;
177- if (parse_config (ctx , conf , NULL , NULL , NULL , NULL , NULL , & error ) < 0 ) {
177+ if (parse_config (ctx , conf , NULL , & error ) < 0 ) {
178178 errstr = error .text ;
179179 goto error ;
180180 }
@@ -305,22 +305,19 @@ static int reload_eventlog (flux_t *h, json_t **eventlog)
305305 return -1 ;
306306}
307307
308- int parse_args (flux_t * h ,
309- int argc ,
308+ int parse_args (flux_t * h , int argc ,
310309 char * * argv ,
311- bool * monitor_force_up ,
312- bool * noverify ,
313- bool * no_update_watch )
310+ struct resource_config * config )
314311{
315312 int i ;
316313 for (i = 0 ; i < argc ; i ++ ) {
317314 /* Test option to force all ranks to be marked online in the initial
318315 * 'restart' event posted to resource.eventlog.
319316 */
320317 if (streq (argv [i ], "monitor-force-up" ))
321- * monitor_force_up = true;
318+ config -> monitor_force_up = true;
322319 else if (streq (argv [i ], "noverify" ))
323- * noverify = true;
320+ config -> noverify = true;
324321 else {
325322 flux_log (h , LOG_ERR , "unknown option: %s" , argv [i ]);
326323 errno = EINVAL ;
@@ -335,52 +332,31 @@ int mod_main (flux_t *h, int argc, char **argv)
335332{
336333 struct resource_ctx * ctx ;
337334 flux_error_t error ;
338- const char * exclude_idset ;
339335 json_t * eventlog = NULL ;
340- bool monitor_force_up = false;
341- bool noverify = false;
342- bool norestrict = false;
343- bool no_update_watch = false;
344- json_t * R_from_config ;
336+ struct resource_config config = {0 };
345337
346338 if (!(ctx = resource_ctx_create (h )))
347339 goto error ;
348340 if (flux_get_size (h , & ctx -> size ) < 0 )
349341 goto error ;
350342 if (flux_get_rank (h , & ctx -> rank ) < 0 )
351343 goto error ;
352- if (parse_config (ctx ,
353- flux_get_conf (h ),
354- & exclude_idset ,
355- & R_from_config ,
356- & noverify ,
357- & norestrict ,
358- & no_update_watch ,
359- & error ) < 0 ) {
344+ if (parse_config (ctx , flux_get_conf (h ), & config , & error ) < 0 ) {
360345 flux_log (h , LOG_ERR , "%s" , error .text );
361346 goto error ;
362347 }
363- if (parse_args (h ,
364- argc ,
365- argv ,
366- & monitor_force_up ,
367- & noverify ,
368- & no_update_watch ) < 0 )
348+ if (parse_args (h , argc , argv , & config ) < 0 )
369349 goto error ;
370350 if (flux_attr_get (ctx -> h , "broker.recovery-mode" ))
371- noverify = true;
351+ config . noverify = true;
372352
373353 /* Note: Order of creation of resource subsystems is important.
374354 * Create inventory on all ranks first, since it is required by
375355 * the exclude and drain subsystems on rank 0.
376356 */
377- if (!(ctx -> inventory = inventory_create (ctx ,
378- R_from_config ,
379- no_update_watch )))
357+ if (!(ctx -> inventory = inventory_create (ctx , & config )))
380358 goto error ;
381- /* Done with R_from_config now, so free it.
382- */
383- json_decref (R_from_config );
359+
384360 if (ctx -> rank == 0 ) {
385361 /* Create reslog and reload eventlog before initializing
386362 * acquire, exclude, and drain subsystems, since these
@@ -403,19 +379,19 @@ int mod_main (flux_t *h, int argc, char **argv)
403379 * the exclude idset to ensure drained ranks that are now
404380 * excluded are ignored.
405381 */
406- if (!(ctx -> exclude = exclude_create (ctx , exclude_idset )))
382+ if (!(ctx -> exclude = exclude_create (ctx , config . exclude_idset )))
407383 goto error ;
408384 if (!(ctx -> drain = drain_create (ctx , eventlog )))
409385 goto error ;
410386 }
411387 /* topology is initialized after exclude/drain etc since this
412388 * rank may attempt to drain itself due to a topology mismatch.
413389 */
414- if (!(ctx -> topology = topo_create (ctx , noverify , norestrict )))
390+ if (!(ctx -> topology = topo_create (ctx , & config )))
415391 goto error ;
416392 if (!(ctx -> monitor = monitor_create (ctx ,
417393 inventory_get_size (ctx -> inventory ),
418- monitor_force_up )))
394+ config . monitor_force_up )))
419395 goto error ;
420396 if (!(ctx -> status = status_create (ctx )))
421397 goto error ;
@@ -427,10 +403,12 @@ int mod_main (flux_t *h, int argc, char **argv)
427403 }
428404 resource_ctx_destroy (ctx );
429405 json_decref (eventlog );
406+ json_decref (config .R );
430407 return 0 ;
431408error :
432409 resource_ctx_destroy (ctx );
433410 ERRNO_SAFE_WRAP (json_decref , eventlog );
411+ ERRNO_SAFE_WRAP (json_decref , config .R );
434412 return -1 ;
435413}
436414
0 commit comments