-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stop logging cloud_init_bytes
in sled-agent
#6439
Changes from all commits
10a2895
556c49b
102b1df
37188e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,3 +118,27 @@ where | |
async fn never_bail() -> Result<bool, Error> { | ||
Ok(false) | ||
} | ||
|
||
/// A wrapper struct that does nothing other than elide the inner value from | ||
/// [`std::fmt::Debug`] output. | ||
/// | ||
/// We define this within Omicron instead of using one of the many available | ||
/// crates that do the same thing because it's trivial to do so, and we want the | ||
/// flexibility to add traits to this type without needing to wait on upstream | ||
/// to add an optional dependency. | ||
/// | ||
/// If you want to use this for secrets, consider that it might not do | ||
/// everything you expect (it does not zeroize memory on drop, nor get in the | ||
/// way of you removing the inner value from this wrapper struct). | ||
#[derive( | ||
Clone, Copy, serde::Deserialize, serde::Serialize, schemars::JsonSchema, | ||
)] | ||
#[repr(transparent)] | ||
#[serde(transparent)] | ||
Comment on lines
+136
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. world's most transparent type :) |
||
pub struct NoDebug<T>(pub T); | ||
|
||
impl<T> std::fmt::Debug for NoDebug<T> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "..") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ use omicron_common::api::internal::{ | |
DhcpConfig, NetworkInterface, ResolvedVpcFirewallRule, SourceNatConfig, | ||
}, | ||
}; | ||
use omicron_common::NoDebug; | ||
use omicron_uuid_kinds::InstanceUuid; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
@@ -60,7 +61,7 @@ pub struct InstanceHardware { | |
pub dhcp_config: DhcpConfig, | ||
// TODO: replace `propolis_client::*` with locally-modeled request type | ||
pub disks: Vec<propolis_client::types::DiskRequest>, | ||
pub cloud_init_bytes: Option<String>, | ||
pub cloud_init_bytes: Option<NoDebug<String>>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An alternative solution, rather than adding a no-debug wrapper type, could be to manually implement I'm not sure which is better off the top of my head --- the wrapper type seems a bit unfortunate: the "actual" type is Incidentally, there is nice technique for avoiding issues where new fields aren't added to a manual impl fmt::Debug for InstanceHardware {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let Self {
properties,
nics,
source_nat,
ephemeral_ip,
floating_ips,
firewall_rules,
dhcp_config,
disks,
cloud_init_bytes,
} = self;
f.debug_struct("InstanceHardware")
.field("properties", properties)
.field("nics", nics)
// ... and so on ...
.finish()
}
} and, because the destructuring pattern binds all the fields (since it doesn't have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW I prefer the wrapper struct over the two other alternatives I'm aware of, the manual impl you mentioned and the derive-more crate. But there are definitely places where I'd use one of the other approaches. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the record, the wrapper struct is fine with me! |
||
} | ||
|
||
/// Metadata used to track statistics about an instance. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote https://docs.rs/debug-ignore a bit ago which we use :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trick is that it must also implement
JsonSchema
for this particular use case, and anything else we ever want to use it in a struct for as well. For that reason it seems to make sense to keep it within Omicron so we can adjust it as needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sighhhh, yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Could you add a comment about this?)