@@ -11,6 +11,7 @@ use cap_std::fs::{Dir, MetadataExt};
11
11
use cap_std_ext:: cap_std;
12
12
use cap_std_ext:: dirext:: CapStdExtDirExt ;
13
13
use fn_error_context:: context;
14
+ use libsystemd:: logging:: Priority ;
14
15
use ostree:: { gio, glib} ;
15
16
use ostree_container:: OstreeImageReference ;
16
17
use ostree_ext:: container as ostree_container;
@@ -99,7 +100,7 @@ pub(crate) fn check_bootc_label(config: &ostree_ext::oci_spec::image::ImageConfi
99
100
match label. as_str ( ) {
100
101
crate :: metadata:: COMPAT_LABEL_V1 => { }
101
102
o => crate :: journal:: journal_print (
102
- libsystemd :: logging :: Priority :: Warning ,
103
+ Priority :: Warning ,
103
104
& format ! (
104
105
"notice: Unknown {} value {}" ,
105
106
crate :: metadata:: BOOTC_COMPAT_LABEL ,
@@ -109,7 +110,7 @@ pub(crate) fn check_bootc_label(config: &ostree_ext::oci_spec::image::ImageConfi
109
110
}
110
111
} else {
111
112
crate :: journal:: journal_print (
112
- libsystemd :: logging :: Priority :: Warning ,
113
+ Priority :: Warning ,
113
114
& format ! (
114
115
"notice: Image is missing label: {}" ,
115
116
crate :: metadata:: BOOTC_COMPAT_LABEL
@@ -423,11 +424,27 @@ pub(crate) async fn pull_from_prepared(
423
424
let imgref_canonicalized = imgref. clone ( ) . canonicalize ( ) ?;
424
425
tracing:: debug!( "Canonicalized image reference: {imgref_canonicalized:#}" ) ;
425
426
427
+ // Log successful import completion
428
+ const IMPORT_COMPLETE_JOURNAL_ID : & str = "4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f9a8" ;
429
+ let msg = format ! ( "Successfully imported image: {}" , imgref) ;
430
+ crate :: journal:: journal_send (
431
+ Priority :: Info ,
432
+ & msg,
433
+ [
434
+ ( "MESSAGE_ID" , IMPORT_COMPLETE_JOURNAL_ID ) ,
435
+ ( "BOOTC_IMAGE_REFERENCE" , & imgref. image ) ,
436
+ ( "BOOTC_IMAGE_TRANSPORT" , & imgref. transport ) ,
437
+ ( "BOOTC_MANIFEST_DIGEST" , import. manifest_digest . as_ref ( ) ) ,
438
+ ( "BOOTC_OSTREE_COMMIT" , & import. merge_commit ) ,
439
+ ]
440
+ . into_iter ( ) ,
441
+ ) ;
442
+
426
443
if let Some ( msg) =
427
444
ostree_container:: store:: image_filtered_content_warning ( & import. filtered_files )
428
445
. context ( "Image content warning" ) ?
429
446
{
430
- crate :: journal:: journal_print ( libsystemd :: logging :: Priority :: Notice , & msg) ;
447
+ crate :: journal:: journal_print ( Priority :: Notice , & msg) ;
431
448
}
432
449
Ok ( Box :: new ( ( * import) . into ( ) ) )
433
450
}
@@ -440,9 +457,51 @@ pub(crate) async fn pull(
440
457
quiet : bool ,
441
458
prog : ProgressWriter ,
442
459
) -> Result < Box < ImageState > > {
460
+ // Log the pull operation to systemd journal
461
+ const PULL_JOURNAL_ID : & str = "5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f9" ;
462
+ let msg = format ! ( "Pulling container image: {}" , imgref) ;
463
+ crate :: journal:: journal_send (
464
+ Priority :: Info ,
465
+ & msg,
466
+ [
467
+ ( "MESSAGE_ID" , PULL_JOURNAL_ID ) ,
468
+ ( "BOOTC_IMAGE_REFERENCE" , & imgref. image ) ,
469
+ ( "BOOTC_IMAGE_TRANSPORT" , & imgref. transport ) ,
470
+ ]
471
+ . into_iter ( ) ,
472
+ ) ;
473
+
443
474
match prepare_for_pull ( repo, imgref, target_imgref) . await ? {
444
- PreparedPullResult :: AlreadyPresent ( existing) => Ok ( existing) ,
475
+ PreparedPullResult :: AlreadyPresent ( existing) => {
476
+ // Log that the image was already present
477
+ let msg = format ! ( "Image already present: {}" , imgref) ;
478
+ crate :: journal:: journal_send (
479
+ Priority :: Debug ,
480
+ & msg,
481
+ [
482
+ ( "MESSAGE_ID" , PULL_JOURNAL_ID ) ,
483
+ ( "BOOTC_IMAGE_REFERENCE" , & imgref. image ) ,
484
+ ( "BOOTC_IMAGE_TRANSPORT" , & imgref. transport ) ,
485
+ ( "BOOTC_STATUS" , "already_present" ) ,
486
+ ]
487
+ . into_iter ( ) ,
488
+ ) ;
489
+ Ok ( existing)
490
+ }
445
491
PreparedPullResult :: Ready ( prepared_image_meta) => {
492
+ // Log that we're pulling a new image
493
+ let msg = format ! ( "Pulling new image: {}" , imgref) ;
494
+ crate :: journal:: journal_send (
495
+ Priority :: Info ,
496
+ & msg,
497
+ [
498
+ ( "MESSAGE_ID" , PULL_JOURNAL_ID ) ,
499
+ ( "BOOTC_IMAGE_REFERENCE" , & imgref. image ) ,
500
+ ( "BOOTC_IMAGE_TRANSPORT" , & imgref. transport ) ,
501
+ ( "BOOTC_STATUS" , "pulling_new" ) ,
502
+ ]
503
+ . into_iter ( ) ,
504
+ ) ;
446
505
Ok ( pull_from_prepared ( imgref, quiet, prog, prepared_image_meta) . await ?)
447
506
}
448
507
}
@@ -460,6 +519,19 @@ pub(crate) async fn wipe_ostree(sysroot: Sysroot) -> Result<()> {
460
519
}
461
520
462
521
pub ( crate ) async fn cleanup ( sysroot : & Storage ) -> Result < ( ) > {
522
+ // Log the cleanup operation to systemd journal
523
+ const CLEANUP_JOURNAL_ID : & str = "2f1a0b9c8d7e6f5a4b3c2d1e0f9a8b7c6" ;
524
+ let msg = "Starting cleanup of old images and deployments" ;
525
+ crate :: journal:: journal_send (
526
+ Priority :: Info ,
527
+ msg,
528
+ [
529
+ ( "MESSAGE_ID" , CLEANUP_JOURNAL_ID ) ,
530
+ ( "BOOTC_OPERATION" , "cleanup" ) ,
531
+ ]
532
+ . into_iter ( ) ,
533
+ ) ;
534
+
463
535
let bound_prune = prune_container_store ( sysroot) ;
464
536
465
537
// We create clones (just atomic reference bumps) here to move to the thread.
@@ -608,6 +680,22 @@ pub(crate) async fn stage(
608
680
spec : & RequiredHostSpec < ' _ > ,
609
681
prog : ProgressWriter ,
610
682
) -> Result < ( ) > {
683
+ // Log the staging operation to systemd journal
684
+ const STAGE_JOURNAL_ID : & str = "8f7a2b1c3d4e5f6a7b8c9d0e1f2a3b4c" ;
685
+ let msg = format ! ( "Staging image for deployment: {}" , spec. image) ;
686
+ crate :: journal:: journal_send (
687
+ Priority :: Info ,
688
+ & msg,
689
+ [
690
+ ( "MESSAGE_ID" , STAGE_JOURNAL_ID ) ,
691
+ ( "BOOTC_IMAGE_REFERENCE" , & spec. image . image ) ,
692
+ ( "BOOTC_IMAGE_TRANSPORT" , & spec. image . transport ) ,
693
+ ( "BOOTC_MANIFEST_DIGEST" , image. manifest_digest . as_ref ( ) ) ,
694
+ ( "BOOTC_STATEROOT" , stateroot) ,
695
+ ]
696
+ . into_iter ( ) ,
697
+ ) ;
698
+
611
699
let mut subtask = SubTaskStep {
612
700
subtask : "merging" . into ( ) ,
613
701
description : "Merging Image" . into ( ) ,
@@ -763,19 +851,39 @@ pub(crate) async fn rollback(sysroot: &Storage) -> Result<()> {
763
851
let rollback_image = rollback_status
764
852
. query_image ( repo) ?
765
853
. ok_or_else ( || anyhow ! ( "Rollback is not container image based" ) ) ?;
854
+
855
+ // Get current booted image for comparison
856
+ let current_image = host
857
+ . status
858
+ . booted
859
+ . as_ref ( )
860
+ . and_then ( |b| b. query_image ( repo) . ok ( ) ?) ;
861
+
766
862
let msg = format ! ( "Rolling back to image: {}" , rollback_image. manifest_digest) ;
767
- libsystemd :: logging :: journal_send (
768
- libsystemd :: logging :: Priority :: Info ,
863
+ crate :: journal :: journal_send (
864
+ Priority :: Info ,
769
865
& msg,
770
866
[
771
867
( "MESSAGE_ID" , ROLLBACK_JOURNAL_ID ) ,
772
868
(
773
869
"BOOTC_MANIFEST_DIGEST" ,
774
870
rollback_image. manifest_digest . as_ref ( ) ,
775
871
) ,
872
+ ( "BOOTC_OSTREE_COMMIT" , & rollback_image. merge_commit ) ,
873
+ (
874
+ "BOOTC_ROLLBACK_TYPE" ,
875
+ if reverting { "revert" } else { "rollback" } ,
876
+ ) ,
877
+ (
878
+ "BOOTC_CURRENT_MANIFEST_DIGEST" ,
879
+ current_image
880
+ . as_ref ( )
881
+ . map ( |i| i. manifest_digest . as_ref ( ) )
882
+ . unwrap_or ( "none" ) ,
883
+ ) ,
776
884
]
777
885
. into_iter ( ) ,
778
- ) ? ;
886
+ ) ;
779
887
// SAFETY: If there's a rollback status, then there's a deployment
780
888
let rollback_deployment = deployments. rollback . expect ( "rollback deployment" ) ;
781
889
let new_deployments = if reverting {
@@ -823,6 +931,21 @@ fn find_newest_deployment_name(deploysdir: &Dir) -> Result<String> {
823
931
824
932
// Implementation of `bootc switch --in-place`
825
933
pub ( crate ) fn switch_origin_inplace ( root : & Dir , imgref : & ImageReference ) -> Result < String > {
934
+ // Log the in-place switch operation to systemd journal
935
+ const SWITCH_INPLACE_JOURNAL_ID : & str = "3e2f1a0b9c8d7e6f5a4b3c2d1e0f9a8b7" ;
936
+ let msg = format ! ( "Performing in-place switch to image: {}" , imgref) ;
937
+ crate :: journal:: journal_send (
938
+ Priority :: Info ,
939
+ & msg,
940
+ [
941
+ ( "MESSAGE_ID" , SWITCH_INPLACE_JOURNAL_ID ) ,
942
+ ( "BOOTC_IMAGE_REFERENCE" , & imgref. image ) ,
943
+ ( "BOOTC_IMAGE_TRANSPORT" , & imgref. transport ) ,
944
+ ( "BOOTC_SWITCH_TYPE" , "in_place" ) ,
945
+ ]
946
+ . into_iter ( ) ,
947
+ ) ;
948
+
826
949
// First, just create the new origin file
827
950
let origin = origin_from_imageref ( imgref) ?;
828
951
let serialized_origin = origin. to_data ( ) ;
0 commit comments