From 29d7d2f53b8be3db6c602697fa25cf978cd0bc13 Mon Sep 17 00:00:00 2001 From: Erikson Tung Date: Tue, 14 Mar 2023 16:25:59 -0700 Subject: [PATCH] pubsys: surface AWS API service error code in error log This surfaces the actual AWS API service error code in the error log message. --- tools/pubsys/src/aws/ami/mod.rs | 6 +++++- tools/pubsys/src/aws/publish_ami/mod.rs | 18 +++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tools/pubsys/src/aws/ami/mod.rs b/tools/pubsys/src/aws/ami/mod.rs index 23a26792a3a..e19a2edd0a3 100644 --- a/tools/pubsys/src/aws/ami/mod.rs +++ b/tools/pubsys/src/aws/ami/mod.rs @@ -358,7 +358,11 @@ async fn _run(args: &Args, ami_args: &AmiArgs) -> Result> } Err(e) => { saw_error = true; - error!("Copy to {} failed: {}", region, e); + error!( + "Copy to {} failed: {}", + region, + e.into_service_error().code().unwrap_or("unknown") + ); } } } diff --git a/tools/pubsys/src/aws/publish_ami/mod.rs b/tools/pubsys/src/aws/publish_ami/mod.rs index 7aea3cbce8c..27b1fce17b5 100644 --- a/tools/pubsys/src/aws/publish_ami/mod.rs +++ b/tools/pubsys/src/aws/publish_ami/mod.rs @@ -399,12 +399,14 @@ pub(crate) async fn modify_regional_snapshots( } Err(e) => { error_count += 1; - error!( - "Failed to modify permissions in {} for snapshots [{}]: {}", - region.as_ref(), - snapshot_ids.join(", "), - e - ); + if let Error::ModifyImageAttribute { source: err, .. } = e { + error!( + "Failed to modify permissions in {} for snapshots [{}]: {:?}", + region.as_ref(), + snapshot_ids.join(", "), + err.into_service_error().code().unwrap_or("unknown"), + ); + } } } } @@ -483,7 +485,9 @@ pub(crate) async fn modify_regional_images( error_count += 1; error!( "Modifying permissions of {} in {} failed: {}", - image_id, region, e + image_id, + region, + e.into_service_error().code().unwrap_or("unknown"), ); } }