20260620 优化delta长尾控制面和PP cache快路径
This commit is contained in:
@@ -25,11 +25,12 @@ use crate::replay::archive::ReplayArchiveIndex;
|
||||
use crate::replay::delta_archive::ReplayDeltaArchiveIndex;
|
||||
use crate::report::{RfcRef, Warning};
|
||||
use crate::storage::{
|
||||
PackFile, PackTime, PublicationPointCacheChild, PublicationPointCacheProjection,
|
||||
RawByHashEntry, RocksStore, ValidatedCaInstanceResult, VcirArtifactKind, VcirArtifactRole,
|
||||
VcirArtifactValidationStatus, VcirAuditSummary, VcirCcrManifestProjection, VcirChildEntry,
|
||||
VcirInstanceGate, VcirLocalOutput, VcirLocalOutputPayload, VcirOutputType, VcirRelatedArtifact,
|
||||
VcirReplaceTimingBreakdown, VcirSourceObjectType, VcirSummary,
|
||||
PackFile, PackTime, PublicationPointCacheChild, PublicationPointCacheOutput,
|
||||
PublicationPointCacheProjection, RawByHashEntry, RocksStore, ValidatedCaInstanceResult,
|
||||
VcirArtifactKind, VcirArtifactRole, VcirArtifactValidationStatus, VcirAuditSummary,
|
||||
VcirCcrManifestProjection, VcirChildEntry, VcirInstanceGate, VcirLocalOutput,
|
||||
VcirLocalOutputPayload, VcirOutputType, VcirRelatedArtifact, VcirReplaceTimingBreakdown,
|
||||
VcirSourceObjectType, VcirSummary,
|
||||
};
|
||||
use crate::sync::repo::{
|
||||
sync_publication_point, sync_publication_point_replay, sync_publication_point_replay_delta,
|
||||
@@ -241,7 +242,7 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
}
|
||||
let projection = match self
|
||||
.store
|
||||
.get_publication_point_cache_projection(&ca.manifest_rsync_uri)
|
||||
.get_publication_point_cache_projection_cached(&ca.manifest_rsync_uri)
|
||||
{
|
||||
Ok(Some(projection)) => projection,
|
||||
Ok(None) => {
|
||||
@@ -526,16 +527,12 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
let output_reuse_count = projection.outputs.len() as u64;
|
||||
let child_reuse_count = projection.children.len() as u64;
|
||||
let related_object_reuse_count = projection.related_objects.len() as u64;
|
||||
let to_vcir_started = std::time::Instant::now();
|
||||
let mut vcir = projection.to_vcir_for_reuse(self.validation_time);
|
||||
let to_vcir_ms = self.record_publication_point_cache_phase_ms(
|
||||
"publication_point_cache_to_vcir_total",
|
||||
to_vcir_started,
|
||||
);
|
||||
vcir.parent_manifest_rsync_uri = ca.parent_manifest_rsync_uri.clone();
|
||||
let build_objects_started = std::time::Instant::now();
|
||||
let mut objects =
|
||||
build_objects_output_from_vcir(&vcir, self.validation_time, &mut warnings);
|
||||
let mut objects = build_objects_output_from_publication_point_cache_projection(
|
||||
&projection,
|
||||
self.validation_time,
|
||||
&mut warnings,
|
||||
);
|
||||
let build_objects_ms = self.record_publication_point_cache_phase_ms(
|
||||
"publication_point_cache_build_objects_total",
|
||||
build_objects_started,
|
||||
@@ -563,19 +560,18 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
ccr_append_started,
|
||||
);
|
||||
let audit_build_started = std::time::Instant::now();
|
||||
let audit = build_publication_point_audit_from_vcir(
|
||||
let audit = build_publication_point_audit_from_publication_point_cache_projection(
|
||||
ca,
|
||||
PublicationPointSource::PublicationPointCache,
|
||||
repo_sync_source,
|
||||
repo_sync_phase,
|
||||
Some(repo_sync_duration_ms),
|
||||
repo_sync_err,
|
||||
Some(&vcir),
|
||||
None,
|
||||
&projection,
|
||||
self.validation_time,
|
||||
&warnings,
|
||||
&objects,
|
||||
&child_audits,
|
||||
&[],
|
||||
);
|
||||
let audit_build_ms = self.record_publication_point_cache_phase_ms(
|
||||
"publication_point_cache_audit_build_total",
|
||||
@@ -614,7 +610,6 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
"children_reused": child_reuse_count,
|
||||
"related_objects_reused": related_object_reuse_count,
|
||||
"audit_objects_reused": audit_object_count,
|
||||
"to_vcir_ms": to_vcir_ms,
|
||||
"build_objects_ms": build_objects_ms,
|
||||
"restore_children_ms": restore_children_ms,
|
||||
"restore_children_workers": child_restore_workers,
|
||||
@@ -649,6 +644,27 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
nanos / 1_000_000
|
||||
}
|
||||
|
||||
pub(crate) fn record_publication_point_total_ms(&self, manifest_rsync_uri: &str, ms: u64) {
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_publication_point_nanos(manifest_rsync_uri, ms.saturating_mul(1_000_000));
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn record_publication_point_step_ms(
|
||||
&self,
|
||||
manifest_rsync_uri: &str,
|
||||
step: &'static str,
|
||||
ms: u64,
|
||||
) {
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_publication_point_step_nanos(
|
||||
manifest_rsync_uri,
|
||||
step,
|
||||
ms.saturating_mul(1_000_000),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn publication_point_cache_child_restore_worker_count(&self) -> usize {
|
||||
self.parallel_phase2_config
|
||||
.as_ref()
|
||||
@@ -772,6 +788,88 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
error,
|
||||
snapshot_prepare_ms,
|
||||
})?;
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_phase_nanos(
|
||||
"fresh_snapshot_prepare_total",
|
||||
snapshot_prepare_ms.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_snapshot_manifest_load_total",
|
||||
snapshot_prepare_timing
|
||||
.manifest_load_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_snapshot_manifest_decode_total",
|
||||
snapshot_prepare_timing
|
||||
.manifest_decode_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_snapshot_replay_guard_total",
|
||||
snapshot_prepare_timing
|
||||
.replay_guard_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_snapshot_manifest_entries_total",
|
||||
snapshot_prepare_timing
|
||||
.manifest_entries_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_snapshot_pack_files_total",
|
||||
snapshot_prepare_timing
|
||||
.pack_files_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_snapshot_ee_path_validate_total",
|
||||
snapshot_prepare_timing
|
||||
.ee_path_validate_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_count("fresh_publication_points", 1);
|
||||
timing.record_count(
|
||||
"fresh_manifest_files_total",
|
||||
snapshot_prepare_timing.manifest_file_count as u64,
|
||||
);
|
||||
}
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_snapshot_prepare",
|
||||
snapshot_prepare_ms,
|
||||
);
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_snapshot_manifest_load",
|
||||
snapshot_prepare_timing.manifest_load_ms,
|
||||
);
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_snapshot_manifest_decode",
|
||||
snapshot_prepare_timing.manifest_decode_ms,
|
||||
);
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_snapshot_replay_guard",
|
||||
snapshot_prepare_timing.replay_guard_ms,
|
||||
);
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_snapshot_manifest_entries",
|
||||
snapshot_prepare_timing.manifest_entries_ms,
|
||||
);
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_snapshot_pack_files",
|
||||
snapshot_prepare_timing.pack_files_ms,
|
||||
);
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_snapshot_ee_path_validate",
|
||||
snapshot_prepare_timing.ee_path_validate_ms,
|
||||
);
|
||||
|
||||
let child_discovery_started = std::time::Instant::now();
|
||||
let out = {
|
||||
@@ -800,6 +898,26 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
),
|
||||
};
|
||||
let child_discovery_ms = child_discovery_started.elapsed().as_millis() as u64;
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_phase_nanos(
|
||||
"fresh_child_discovery_total",
|
||||
child_discovery_ms.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_count(
|
||||
"fresh_children_discovered",
|
||||
discovered_children.len() as u64,
|
||||
);
|
||||
timing.record_count("fresh_child_audits", child_audits.len() as u64);
|
||||
timing.record_count(
|
||||
"fresh_router_keys_discovered",
|
||||
discovered_router_keys.len() as u64,
|
||||
);
|
||||
}
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_child_discovery",
|
||||
child_discovery_ms,
|
||||
);
|
||||
|
||||
Ok(FreshPublicationPointStage {
|
||||
fresh_point,
|
||||
@@ -829,6 +947,17 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
let snapshot_pack_started = std::time::Instant::now();
|
||||
let pack = fresh_point.to_publication_point_snapshot();
|
||||
let snapshot_pack_ms = snapshot_pack_started.elapsed().as_millis() as u64;
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_phase_nanos(
|
||||
"fresh_snapshot_pack_total",
|
||||
snapshot_pack_ms.saturating_mul(1_000_000),
|
||||
);
|
||||
}
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_snapshot_pack",
|
||||
snapshot_pack_ms,
|
||||
);
|
||||
|
||||
let persist_vcir_started = std::time::Instant::now();
|
||||
let persist_vcir_timing = if self.persist_vcir {
|
||||
@@ -850,6 +979,64 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
PersistVcirTimingBreakdown::default()
|
||||
};
|
||||
let persist_vcir_ms = persist_vcir_started.elapsed().as_millis() as u64;
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_phase_nanos(
|
||||
"fresh_persist_vcir_total",
|
||||
persist_vcir_ms.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_persist_embedded_store_total",
|
||||
persist_vcir_timing
|
||||
.embedded_store_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_persist_build_vcir_total",
|
||||
persist_vcir_timing.build_vcir_ms.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_persist_replace_vcir_total",
|
||||
persist_vcir_timing
|
||||
.replace_vcir_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_persist_local_outputs_total",
|
||||
persist_vcir_timing
|
||||
.build_vcir
|
||||
.local_outputs_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_persist_child_entries_total",
|
||||
persist_vcir_timing
|
||||
.build_vcir
|
||||
.child_entries_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_persist_related_artifacts_total",
|
||||
persist_vcir_timing
|
||||
.build_vcir
|
||||
.related_artifacts_ms
|
||||
.saturating_mul(1_000_000),
|
||||
);
|
||||
}
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_persist_vcir",
|
||||
persist_vcir_ms,
|
||||
);
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_persist_build_vcir",
|
||||
persist_vcir_timing.build_vcir_ms,
|
||||
);
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_persist_replace_vcir",
|
||||
persist_vcir_timing.replace_vcir_ms,
|
||||
);
|
||||
|
||||
// local_outputs_cache only exists to build/persist VCIR. Release it before the
|
||||
// publication point result is retained for the rest of the run.
|
||||
@@ -868,6 +1055,26 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
self.append_ccr_manifest_projection(&ccr_manifest_projection)?;
|
||||
ccr_append_ms = ccr_append_started.elapsed().as_millis() as u64;
|
||||
}
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_phase_nanos(
|
||||
"fresh_ccr_projection_build_total",
|
||||
ccr_projection_build_ms.saturating_mul(1_000_000),
|
||||
);
|
||||
timing.record_phase_nanos(
|
||||
"fresh_ccr_append_total",
|
||||
ccr_append_ms.saturating_mul(1_000_000),
|
||||
);
|
||||
}
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_ccr_projection_build",
|
||||
ccr_projection_build_ms,
|
||||
);
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_ccr_append",
|
||||
ccr_append_ms,
|
||||
);
|
||||
|
||||
let audit_build_started = std::time::Instant::now();
|
||||
let audit = build_publication_point_audit_from_snapshot(
|
||||
@@ -883,6 +1090,17 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
&child_audits,
|
||||
);
|
||||
let audit_build_ms = audit_build_started.elapsed().as_millis() as u64;
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_phase_nanos(
|
||||
"fresh_audit_build_total",
|
||||
audit_build_ms.saturating_mul(1_000_000),
|
||||
);
|
||||
}
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_audit_build",
|
||||
audit_build_ms,
|
||||
);
|
||||
|
||||
Ok(FreshPublicationPointFinalizeOutput {
|
||||
result: PublicationPointRunResult {
|
||||
@@ -1296,6 +1514,11 @@ impl<'a> PublicationPointRunner for Rpkiv1PublicationPointRunner<'a> {
|
||||
}
|
||||
};
|
||||
let objects_processing_ms = objects_processing_started.elapsed().as_millis() as u64;
|
||||
self.record_publication_point_step_ms(
|
||||
&ca.manifest_rsync_uri,
|
||||
"fresh_objects_processing",
|
||||
objects_processing_ms,
|
||||
);
|
||||
|
||||
objects.router_keys.extend(discovered_router_keys);
|
||||
objects
|
||||
@@ -2741,6 +2964,98 @@ fn build_publication_point_audit_from_vcir(
|
||||
}
|
||||
}
|
||||
|
||||
fn build_publication_point_audit_from_publication_point_cache_projection(
|
||||
ca: &CaInstanceHandle,
|
||||
source: PublicationPointSource,
|
||||
repo_sync_source: Option<&str>,
|
||||
repo_sync_phase: Option<&str>,
|
||||
repo_sync_duration_ms: Option<u64>,
|
||||
repo_sync_error: Option<&str>,
|
||||
projection: &PublicationPointCacheProjection,
|
||||
validation_time: time::OffsetDateTime,
|
||||
runner_warnings: &[Warning],
|
||||
objects: &crate::validation::objects::ObjectsOutput,
|
||||
child_audits: &[ObjectAuditEntry],
|
||||
) -> PublicationPointAudit {
|
||||
let mut warnings = Vec::new();
|
||||
warnings.extend(runner_warnings.iter().map(AuditWarning::from));
|
||||
warnings.extend(objects.warnings.iter().map(AuditWarning::from));
|
||||
|
||||
let mut audit_by_uri: HashMap<String, ObjectAuditEntry> = HashMap::new();
|
||||
for artifact in &projection.related_objects {
|
||||
let Some(uri) = artifact.uri.as_ref() else {
|
||||
continue;
|
||||
};
|
||||
audit_by_uri.insert(
|
||||
uri.clone(),
|
||||
ObjectAuditEntry {
|
||||
rsync_uri: uri.clone(),
|
||||
sha256_hex: artifact.sha256.clone(),
|
||||
kind: kind_from_vcir_artifact_kind(artifact.artifact_kind),
|
||||
result: audit_result_from_vcir_status(artifact.validation_status),
|
||||
detail: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
for entry in child_audits {
|
||||
audit_by_uri.insert(entry.rsync_uri.clone(), entry.clone());
|
||||
}
|
||||
for entry in &objects.audit {
|
||||
audit_by_uri.insert(entry.rsync_uri.clone(), entry.clone());
|
||||
}
|
||||
|
||||
let mut ordered_uris: Vec<String> = projection
|
||||
.related_objects
|
||||
.iter()
|
||||
.filter_map(|artifact| artifact.uri.clone())
|
||||
.collect();
|
||||
ordered_uris.sort();
|
||||
ordered_uris.dedup();
|
||||
|
||||
let mut objects_out: Vec<ObjectAuditEntry> = Vec::with_capacity(ordered_uris.len().max(1));
|
||||
if let Some(entry) = audit_by_uri.remove(&projection.manifest_rsync_uri) {
|
||||
objects_out.push(entry);
|
||||
} else {
|
||||
objects_out.push(ObjectAuditEntry {
|
||||
rsync_uri: projection.manifest_rsync_uri.clone(),
|
||||
sha256_hex: hex::encode(projection.manifest_sha256),
|
||||
kind: AuditObjectKind::Manifest,
|
||||
result: AuditObjectResult::Ok,
|
||||
detail: None,
|
||||
});
|
||||
}
|
||||
|
||||
for uri in ordered_uris {
|
||||
if uri == projection.manifest_rsync_uri {
|
||||
continue;
|
||||
}
|
||||
if let Some(entry) = audit_by_uri.remove(&uri) {
|
||||
objects_out.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
PublicationPointAudit {
|
||||
node_id: None,
|
||||
parent_node_id: None,
|
||||
discovered_from: None,
|
||||
rsync_base_uri: ca.rsync_base_uri.clone(),
|
||||
manifest_rsync_uri: ca.manifest_rsync_uri.clone(),
|
||||
publication_point_rsync_uri: ca.publication_point_rsync_uri.clone(),
|
||||
rrdp_notification_uri: ca.rrdp_notification_uri.clone(),
|
||||
source: source_label(source),
|
||||
repo_sync_source: repo_sync_source.map(ToString::to_string),
|
||||
repo_sync_phase: repo_sync_phase.map(ToString::to_string),
|
||||
repo_sync_duration_ms,
|
||||
repo_sync_error: repo_sync_error.map(ToString::to_string),
|
||||
repo_terminal_state: terminal_state_label(source).to_string(),
|
||||
this_update_rfc3339_utc: projection.manifest_this_update.rfc3339_utc.clone(),
|
||||
next_update_rfc3339_utc: projection.manifest_next_update.rfc3339_utc.clone(),
|
||||
verified_at_rfc3339_utc: PackTime::from_utc_offset_datetime(validation_time).rfc3339_utc,
|
||||
warnings,
|
||||
objects: objects_out,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_snapshot_time_value(pack_time: &PackTime) -> Result<time::OffsetDateTime, String> {
|
||||
time::OffsetDateTime::parse(
|
||||
&pack_time.rfc3339_utc,
|
||||
@@ -3160,6 +3475,202 @@ fn build_objects_output_from_vcir(
|
||||
output
|
||||
}
|
||||
|
||||
fn build_objects_output_from_publication_point_cache_projection(
|
||||
projection: &PublicationPointCacheProjection,
|
||||
validation_time: time::OffsetDateTime,
|
||||
warnings: &mut Vec<Warning>,
|
||||
) -> crate::validation::objects::ObjectsOutput {
|
||||
let mut output = empty_objects_output();
|
||||
let mut audit_by_uri: HashMap<String, ObjectAuditEntry> = HashMap::new();
|
||||
let mut roa_total: HashSet<String> = HashSet::new();
|
||||
let mut aspa_total: HashSet<String> = HashSet::new();
|
||||
let mut roa_ok: HashSet<String> = HashSet::new();
|
||||
let mut aspa_ok: HashSet<String> = HashSet::new();
|
||||
|
||||
for artifact in &projection.related_objects {
|
||||
if artifact.artifact_role != VcirArtifactRole::SignedObject {
|
||||
continue;
|
||||
}
|
||||
if let Some(uri) = artifact.uri.as_ref() {
|
||||
match artifact.artifact_kind {
|
||||
VcirArtifactKind::Roa => {
|
||||
roa_total.insert(uri.clone());
|
||||
}
|
||||
VcirArtifactKind::Aspa => {
|
||||
aspa_total.insert(uri.clone());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for projected in &projection.outputs {
|
||||
let effective_until = match parse_snapshot_time_value(&projected.item_effective_until) {
|
||||
Ok(value) => value,
|
||||
Err(err) => {
|
||||
warnings.push(
|
||||
Warning::new(format!(
|
||||
"publication-point cached local output has invalid item_effective_until: {err}"
|
||||
))
|
||||
.with_context(&projected.source_object_uri),
|
||||
);
|
||||
audit_by_uri.insert(
|
||||
projected.source_object_uri.clone(),
|
||||
ObjectAuditEntry {
|
||||
rsync_uri: projected.source_object_uri.clone(),
|
||||
sha256_hex: hex::encode(projected.source_object_hash),
|
||||
kind: audit_kind_for_vcir_output_type(projected.output_type),
|
||||
result: AuditObjectResult::Error,
|
||||
detail: Some(
|
||||
"publication-point cached local output has invalid item_effective_until"
|
||||
.to_string(),
|
||||
),
|
||||
},
|
||||
);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if validation_time > effective_until {
|
||||
audit_by_uri
|
||||
.entry(projected.source_object_uri.clone())
|
||||
.or_insert_with(|| ObjectAuditEntry {
|
||||
rsync_uri: projected.source_object_uri.clone(),
|
||||
sha256_hex: hex::encode(projected.source_object_hash),
|
||||
kind: audit_kind_for_vcir_output_type(projected.output_type),
|
||||
result: AuditObjectResult::Skipped,
|
||||
detail: Some(
|
||||
"skipped: publication-point cached local output expired".to_string(),
|
||||
),
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
match projected.output_type {
|
||||
VcirOutputType::Vrp => match parse_publication_point_cache_vrp_output(projected) {
|
||||
Ok(vrp) => {
|
||||
roa_ok.insert(projected.source_object_uri.clone());
|
||||
output.vrps.push(vrp);
|
||||
audit_by_uri.insert(
|
||||
projected.source_object_uri.clone(),
|
||||
ObjectAuditEntry {
|
||||
rsync_uri: projected.source_object_uri.clone(),
|
||||
sha256_hex: hex::encode(projected.source_object_hash),
|
||||
kind: AuditObjectKind::Roa,
|
||||
result: AuditObjectResult::Ok,
|
||||
detail: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
warnings.push(
|
||||
Warning::new(format!(
|
||||
"publication-point cached ROA local output parse failed: {err}"
|
||||
))
|
||||
.with_context(&projected.source_object_uri),
|
||||
);
|
||||
audit_by_uri.insert(
|
||||
projected.source_object_uri.clone(),
|
||||
ObjectAuditEntry {
|
||||
rsync_uri: projected.source_object_uri.clone(),
|
||||
sha256_hex: hex::encode(projected.source_object_hash),
|
||||
kind: AuditObjectKind::Roa,
|
||||
result: AuditObjectResult::Error,
|
||||
detail: Some(format!(
|
||||
"publication-point cached ROA local output parse failed: {err}"
|
||||
)),
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
VcirOutputType::Aspa => match parse_publication_point_cache_aspa_output(projected) {
|
||||
Ok(aspa) => {
|
||||
aspa_ok.insert(projected.source_object_uri.clone());
|
||||
output.aspas.push(aspa);
|
||||
audit_by_uri.insert(
|
||||
projected.source_object_uri.clone(),
|
||||
ObjectAuditEntry {
|
||||
rsync_uri: projected.source_object_uri.clone(),
|
||||
sha256_hex: hex::encode(projected.source_object_hash),
|
||||
kind: AuditObjectKind::Aspa,
|
||||
result: AuditObjectResult::Ok,
|
||||
detail: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
warnings.push(
|
||||
Warning::new(format!(
|
||||
"publication-point cached ASPA local output parse failed: {err}"
|
||||
))
|
||||
.with_context(&projected.source_object_uri),
|
||||
);
|
||||
audit_by_uri.insert(
|
||||
projected.source_object_uri.clone(),
|
||||
ObjectAuditEntry {
|
||||
rsync_uri: projected.source_object_uri.clone(),
|
||||
sha256_hex: hex::encode(projected.source_object_hash),
|
||||
kind: AuditObjectKind::Aspa,
|
||||
result: AuditObjectResult::Error,
|
||||
detail: Some(format!(
|
||||
"publication-point cached ASPA local output parse failed: {err}"
|
||||
)),
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
VcirOutputType::RouterKey => {
|
||||
match parse_publication_point_cache_router_key_output(projected) {
|
||||
Ok(router_key) => {
|
||||
output.router_keys.push(router_key);
|
||||
audit_by_uri.insert(
|
||||
projected.source_object_uri.clone(),
|
||||
ObjectAuditEntry {
|
||||
rsync_uri: projected.source_object_uri.clone(),
|
||||
sha256_hex: hex::encode(projected.source_object_hash),
|
||||
kind: AuditObjectKind::RouterCertificate,
|
||||
result: AuditObjectResult::Ok,
|
||||
detail: Some(
|
||||
"publication-point cached Router Key local output restored"
|
||||
.to_string(),
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
warnings.push(
|
||||
Warning::new(format!(
|
||||
"publication-point cached Router Key local output parse failed: {err}"
|
||||
))
|
||||
.with_context(&projected.source_object_uri),
|
||||
);
|
||||
audit_by_uri.insert(
|
||||
projected.source_object_uri.clone(),
|
||||
ObjectAuditEntry {
|
||||
rsync_uri: projected.source_object_uri.clone(),
|
||||
sha256_hex: hex::encode(projected.source_object_hash),
|
||||
kind: AuditObjectKind::RouterCertificate,
|
||||
result: AuditObjectResult::Error,
|
||||
detail: Some(format!(
|
||||
"publication-point cached Router Key local output parse failed: {err}"
|
||||
)),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output.stats.roa_total = roa_total.len();
|
||||
output.stats.roa_ok = roa_ok.len();
|
||||
output.stats.aspa_total = aspa_total.len();
|
||||
output.stats.aspa_ok = aspa_ok.len();
|
||||
let mut audit: Vec<_> = audit_by_uri.into_values().collect();
|
||||
audit.sort_by(|left, right| left.rsync_uri.cmp(&right.rsync_uri));
|
||||
output.audit = audit;
|
||||
output
|
||||
}
|
||||
|
||||
fn parse_vcir_vrp_output(local: &VcirLocalOutput) -> Result<Vrp, String> {
|
||||
match &local.payload {
|
||||
VcirLocalOutputPayload::Vrp {
|
||||
@@ -3213,6 +3724,65 @@ fn parse_vcir_router_key_output(local: &VcirLocalOutput) -> Result<RouterKeyPayl
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_publication_point_cache_vrp_output(
|
||||
projected: &PublicationPointCacheOutput,
|
||||
) -> Result<Vrp, String> {
|
||||
match &projected.payload {
|
||||
VcirLocalOutputPayload::Vrp {
|
||||
asn,
|
||||
afi,
|
||||
prefix_len,
|
||||
addr,
|
||||
max_length,
|
||||
} => Ok(Vrp {
|
||||
asn: *asn,
|
||||
prefix: crate::data_model::roa::IpPrefix {
|
||||
afi: *afi,
|
||||
prefix_len: *prefix_len,
|
||||
addr: *addr,
|
||||
},
|
||||
max_length: *max_length,
|
||||
}),
|
||||
_ => Err("publication-point cache output payload is not VRP".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_publication_point_cache_aspa_output(
|
||||
projected: &PublicationPointCacheOutput,
|
||||
) -> Result<AspaAttestation, String> {
|
||||
match &projected.payload {
|
||||
VcirLocalOutputPayload::Aspa {
|
||||
customer_as_id,
|
||||
provider_as_ids,
|
||||
} => Ok(AspaAttestation {
|
||||
customer_as_id: *customer_as_id,
|
||||
provider_as_ids: provider_as_ids.clone(),
|
||||
}),
|
||||
_ => Err("publication-point cache output payload is not ASPA".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_publication_point_cache_router_key_output(
|
||||
projected: &PublicationPointCacheOutput,
|
||||
) -> Result<RouterKeyPayload, String> {
|
||||
match &projected.payload {
|
||||
VcirLocalOutputPayload::RouterKey {
|
||||
as_id,
|
||||
ski,
|
||||
spki_der,
|
||||
} => Ok(RouterKeyPayload {
|
||||
as_id: *as_id,
|
||||
ski: ski.clone(),
|
||||
spki_der: spki_der.clone(),
|
||||
source_object_uri: projected.source_object_uri.clone(),
|
||||
source_object_hash: hex::encode(projected.source_object_hash),
|
||||
source_ee_cert_hash: hex::encode(projected.source_ee_cert_hash),
|
||||
item_effective_until: projected.item_effective_until.clone(),
|
||||
}),
|
||||
_ => Err("publication-point cache output payload is not Router Key".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
fn restore_children_from_vcir(
|
||||
store: &RocksStore,
|
||||
ca: &CaInstanceHandle,
|
||||
|
||||
Reference in New Issue
Block a user