diff --git a/compute_tools/src/compute.rs b/compute_tools/src/compute.rs index 1e0ddeab6a..ddcfe12330 100644 --- a/compute_tools/src/compute.rs +++ b/compute_tools/src/compute.rs @@ -679,6 +679,23 @@ impl ComputeNode { }); } + // Configure and start rsyslog if necessary + if let ComputeAudit::Hipaa = pspec.spec.audit_log_level { + let remote_endpoint = std::env::var("AUDIT_LOGGING_ENDPOINT").unwrap_or("".to_string()); + if remote_endpoint.is_empty() { + anyhow::bail!("AUDIT_LOGGING_ENDPOINT is empty"); + } + + let log_directory_path = Path::new(&self.params.pgdata).join("log"); + // TODO: make this more robust + // now rsyslog starts once and there is no monitoring or restart if it fails + configure_and_start_rsyslog( + log_directory_path.to_str().unwrap(), + "hipaa", + &remote_endpoint, + )?; + } + // Launch remaining service threads let _monitor_handle = launch_monitor(self); let _configurator_handle = launch_configurator(self); @@ -1640,21 +1657,6 @@ impl ComputeNode { } self.post_apply_config()?; - // Configure rsyslog for HIPAA audit logging - if let ComputeAudit::Hipaa = pspec.spec.audit_log_level { - let remote_endpoint = std::env::var("AUDIT_LOGGING_ENDPOINT").unwrap_or("".to_string()); - if remote_endpoint.is_empty() { - anyhow::bail!("AUDIT_LOGGING_ENDPOINT is empty"); - } - - let log_directory_path = Path::new(&self.params.pgdata).join("log"); - configure_and_start_rsyslog( - log_directory_path.to_str().unwrap(), - "hipaa", - &remote_endpoint, - )?; - } - Ok(()) } diff --git a/compute_tools/src/config.rs b/compute_tools/src/config.rs index d578a80748..0760568ff8 100644 --- a/compute_tools/src/config.rs +++ b/compute_tools/src/config.rs @@ -1,5 +1,4 @@ use anyhow::Result; -use base64::write; use std::fmt::Write as FmtWrite; use std::fs::{File, OpenOptions}; use std::io; diff --git a/compute_tools/src/spec_apply.rs b/compute_tools/src/spec_apply.rs index a8ba97ba5e..dbc02c8d02 100644 --- a/compute_tools/src/spec_apply.rs +++ b/compute_tools/src/spec_apply.rs @@ -277,6 +277,8 @@ impl ComputeNode { phases.push(FinalizeDropLogicalSubscriptions); } + // Keep DisablePostgresDBPgAudit phase at the end, + // so that all config operations are audit logged. match spec.audit_log_level { ComputeAudit::Hipaa => {