@@ -15,6 +15,7 @@ use ostree_ext::oci_spec;
15
15
use ostree_ext:: ostree;
16
16
17
17
use crate :: cli:: OutputFormat ;
18
+ use crate :: spec:: FilesystemOverlay ;
18
19
use crate :: spec:: { BootEntry , BootOrder , Host , HostSpec , HostStatus , HostType } ;
19
20
use crate :: spec:: { ImageReference , ImageSignature } ;
20
21
use crate :: store:: { CachedImageStatus , ContainerImageStore , Storage } ;
@@ -225,6 +226,12 @@ pub(crate) fn get_status(
225
226
} else {
226
227
BootOrder :: Default
227
228
} ;
229
+ let usr_overlay = FilesystemOverlay :: from_ostree_deployment_state (
230
+ & booted_deployment
231
+ . as_ref ( )
232
+ . expect ( "Expected a booted deployment" )
233
+ . unlocked ( ) ,
234
+ ) ;
228
235
tracing:: debug!( "Rollback queued={rollback_queued:?}" ) ;
229
236
let other = {
230
237
related_deployments. extend ( other_deployments) ;
@@ -260,6 +267,7 @@ pub(crate) fn get_status(
260
267
. map ( |img| HostSpec {
261
268
image : Some ( img. image . clone ( ) ) ,
262
269
boot_order,
270
+ usr_overlay,
263
271
} )
264
272
. unwrap_or_default ( ) ;
265
273
@@ -280,6 +288,7 @@ pub(crate) fn get_status(
280
288
booted,
281
289
rollback,
282
290
rollback_queued,
291
+ usr_overlay,
283
292
ty,
284
293
} ;
285
294
Ok ( ( deployments, host) )
@@ -331,7 +340,7 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
331
340
Ok ( ( ) )
332
341
}
333
342
334
- #[ derive( Debug ) ]
343
+ #[ derive( Debug , PartialEq ) ]
335
344
pub enum Slot {
336
345
Staged ,
337
346
Booted ,
@@ -363,6 +372,7 @@ fn human_render_imagestatus(
363
372
mut out : impl Write ,
364
373
slot : Slot ,
365
374
image : & crate :: spec:: ImageStatus ,
375
+ host : & crate :: spec:: HostStatus ,
366
376
) -> Result < ( ) > {
367
377
let transport = & image. image . transport ;
368
378
let imagename = & image. image . image ;
@@ -407,10 +417,24 @@ fn human_render_imagestatus(
407
417
writeln ! ( out, "{timestamp}" ) ?;
408
418
}
409
419
420
+ if let Some ( usr_overlay) = & host. usr_overlay {
421
+ // Only show the usr filesystem overlay state if we are booted and not the default
422
+ // read-only mode.
423
+ if slot == Slot :: Booted && * usr_overlay != FilesystemOverlay :: Readonly {
424
+ write_row_name ( & mut out, "Usr overlay" , prefix_len) ?;
425
+ writeln ! ( out, "{}" , usr_overlay. to_human_string( ) ) ?;
426
+ }
427
+ }
428
+
410
429
Ok ( ( ) )
411
430
}
412
431
413
- fn human_render_ostree ( mut out : impl Write , slot : Slot , ostree_commit : & str ) -> Result < ( ) > {
432
+ fn human_render_ostree (
433
+ mut out : impl Write ,
434
+ slot : Slot ,
435
+ ostree_commit : & str ,
436
+ host : & crate :: spec:: HostStatus ,
437
+ ) -> Result < ( ) > {
414
438
// TODO consider rendering more ostree stuff here like rpm-ostree status does
415
439
let prefix = match slot {
416
440
Slot :: Staged => " Staged ostree" . into ( ) ,
@@ -421,6 +445,16 @@ fn human_render_ostree(mut out: impl Write, slot: Slot, ostree_commit: &str) ->
421
445
writeln ! ( out, "{prefix}" ) ?;
422
446
write_row_name ( & mut out, "Commit" , prefix_len) ?;
423
447
writeln ! ( out, "{ostree_commit}" ) ?;
448
+
449
+ if let Some ( usr_overlay) = & host. usr_overlay {
450
+ // Only show the usr filesystem overlay state if we are booted and not the default
451
+ // read-only mode.
452
+ if slot == Slot :: Booted && * usr_overlay != FilesystemOverlay :: Readonly {
453
+ write_row_name ( & mut out, "Usr overlay" , prefix_len) ?;
454
+ writeln ! ( out, "{}" , usr_overlay. to_human_string( ) ) ?;
455
+ }
456
+ }
457
+
424
458
Ok ( ( ) )
425
459
}
426
460
@@ -438,9 +472,9 @@ fn human_readable_output_booted(mut out: impl Write, host: &Host) -> Result<()>
438
472
writeln ! ( out) ?;
439
473
}
440
474
if let Some ( image) = & host_status. image {
441
- human_render_imagestatus ( & mut out, slot_name, image) ?;
475
+ human_render_imagestatus ( & mut out, slot_name, image, & host . status ) ?;
442
476
} else if let Some ( ostree) = host_status. ostree . as_ref ( ) {
443
- human_render_ostree ( & mut out, slot_name, & ostree. checksum ) ?;
477
+ human_render_ostree ( & mut out, slot_name, & ostree. checksum , & host . status ) ?;
444
478
} else {
445
479
writeln ! ( out, "Current {slot_name} state is unknown" ) ?;
446
480
}
@@ -480,7 +514,7 @@ mod tests {
480
514
Staged image: quay.io/example/someimage:latest
481
515
Digest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566 (arm64)
482
516
Version: nightly (2023-10-14T19:22:15Z)
483
-
517
+
484
518
● Booted image: quay.io/example/someimage:latest
485
519
Digest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34 (arm64)
486
520
Version: nightly (2023-09-30T19:22:16Z)
@@ -498,7 +532,7 @@ mod tests {
498
532
let expected = indoc:: indoc! { r"
499
533
Staged ostree
500
534
Commit: 1c24260fdd1be20f72a4a97a75c582834ee3431fbb0fa8e4f482bb219d633a45
501
-
535
+
502
536
● Booted ostree
503
537
Commit: f9fa3a553ceaaaf30cf85bfe7eed46a822f7b8fd7e14c1e3389cbc3f6d27f791
504
538
" } ;
@@ -514,7 +548,7 @@ mod tests {
514
548
Staged image: quay.io/centos-bootc/centos-bootc:stream9
515
549
Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38 (s390x)
516
550
Version: stream9.20240807.0
517
-
551
+
518
552
● Booted ostree
519
553
Commit: f9fa3a553ceaaaf30cf85bfe7eed46a822f7b8fd7e14c1e3389cbc3f6d27f791
520
554
" } ;
0 commit comments