@@ -18,7 +18,6 @@ use anyhow::{anyhow, bail, Result};
1818use buildomat_common:: OutputExt ;
1919use slog:: { debug, error, info, o, warn, Logger } ;
2020
21- const FMRI : & str = "svc:/site/buildomat/hubris-agent:default" ;
2221const SERVICE : & str = "site/buildomat/hubris-agent" ;
2322
2423pub ( crate ) async fn workload_worker ( c : Arc < Central > ) -> Result < ( ) > {
@@ -56,7 +55,7 @@ async fn workload_worker_one(
5655 * service bundle.
5756 */
5857 let svc = loc
59- . get_service ( "site/buildomat/hubris-agent" ) ?
58+ . get_service ( SERVICE ) ?
6059 . ok_or_else ( || anyhow ! ( "could not locate service {SERVICE:?}" ) ) ?;
6160
6261 /*
@@ -338,7 +337,7 @@ async fn instance_worker_one(
338337 let mut scf = smf:: Scf :: new ( ) ?;
339338 let loc = scf. scope_local ( ) ?;
340339 let svc = loc
341- . get_service ( "site/buildomat/hubris-agent" ) ?
340+ . get_service ( SERVICE ) ?
342341 . ok_or_else ( || anyhow ! ( "could not locate service {SERVICE:?}" ) ) ?;
343342
344343 match i. state {
@@ -352,7 +351,30 @@ async fn instance_worker_one(
352351 scrub_tmp ( log, build_user) ?;
353352
354353 /*
355- * XXX Make sure we have an MCU-Link available.
354+ * XXX We need to confirm that power control is available for the
355+ * things that we intend to control here, and that the devices under
356+ * test begin in the OFF state.
357+ */
358+
359+ /*
360+ * XXX Make sure we have hardware devices available.
361+ *
362+ * We need configuration here; looms, like in manufacturing,
363+ * to be able to specify a "gimlet", "sidecar", and "psc" target.
364+ *
365+ * We should select a loom here (which would include a list of
366+ * vid/pid/serial pairs for dongles) and commit to it for the
367+ * duration of this "instance".
368+ *
369+ * We should power up each device in sequence and ensure they are
370+ * flashed with stock images, confirm on some level that they are
371+ * working, and then power them back off.
372+ *
373+ * We need to be able to generate a humility environment file here
374+ * as part of the hand-off to the job.
375+ *
376+ * XXX Really this should actually happen before we've even promised
377+ * to start the job -- this should be part of the "slot" definition.
356378 */
357379 let mculink =
358380 c. usb . mculink ( ) . ok_or_else ( || anyhow ! ( "no MCU-Link found?" ) ) ?;
@@ -418,10 +440,9 @@ async fn instance_worker_one(
418440 InstanceState :: Configured => {
419441 let mut scf = smf:: Scf :: new ( ) ?;
420442 let loc = scf. scope_local ( ) ?;
421- let svc =
422- loc. get_service ( "site/buildomat/hubris-agent" ) ?. ok_or_else (
423- || anyhow ! ( "could not locate service {SERVICE:?}" ) ,
424- ) ?;
443+ let svc = loc. get_service ( SERVICE ) ?. ok_or_else ( || {
444+ anyhow ! ( "could not locate service {SERVICE:?}" )
445+ } ) ?;
425446
426447 let smfi = svc. get_instance ( & svcname) ?. ok_or_else ( || {
427448 anyhow ! ( "could not locate SMF instance {svcname:?}" )
@@ -475,12 +496,14 @@ async fn instance_worker_one(
475496 * This is a terminal state and we can delete the
476497 * service instance.
477498 */
499+ info ! ( log, "deleting SMF service" ) ;
500+ smfi. delete ( ) ?;
478501 }
479502 other => {
480503 /*
481504 * Try to disable the service.
482505 */
483- warn ! ( log, "SMF state: {other:?} --> disable! " ) ;
506+ info ! ( log, "disabling SMF service " ) ;
484507 smfi. disable ( true ) ?;
485508 return Ok ( DoNext :: Sleep ) ;
486509 }
@@ -490,13 +513,24 @@ async fn instance_worker_one(
490513 } ;
491514
492515 /*
493- * XXX we need to ensure all processes owned by the builder
494- * uid are killed... see: sigsend(2) / sigsendset(2)
516+ * While we have disabled the service, it is possible that some
517+ * processes could have been created outside the contract. Ensure
518+ * all processes for the build user are terminated and then remove
519+ * any files left behind.
495520 */
496521 kill_all ( log, build_user) ?;
497522 dataset_destroy ( log, build_user) ?;
498523 scrub_tmp ( log, build_user) ?;
499524
525+ /*
526+ * XXX We need to confirm that we are able to shut off the power for
527+ * the devices under test here.
528+ */
529+
530+ /*
531+ * XXX Change ownership of any USB devices back to root
532+ */
533+
500534 c. db . instance_new_state ( & id, InstanceState :: Destroyed ) ?;
501535 Ok ( DoNext :: Immediate )
502536 }
0 commit comments