Wire tracing diagnostics through libazureinit-kvp - #319
Peyton Robertson (peytonr18) wants to merge 4 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #319 +/- ##
==========================================
+ Coverage 96.66% 99.34% +2.68%
==========================================
Files 29 29
Lines 9960 9673 -287
==========================================
- Hits 9628 9610 -18
+ Misses 332 63 -269 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
I can circle back to this and give it another shot, but there are pieces of I'll give updating coverage in these two files another shot, but I don't want to sacrifice better and clearer production code for the sake of hitting 100% coverage. I don't think there's value in that, though I'm open to suggestions if others disagree. In the meantime, I'll try my best to get us closer to 100% here. |
…ble helpers to improve coverage
dfcca71 to
2757b2a
Compare
Tracing, Diagnostics, and KVP Integration
Azure Init now uses
libazureinit-kvpfor diagnostics and provisioning reports instead of maintaining its own KVP encoder and writer. The reusable, synchronousDiagnosticsKvpbridge handles tracing; the application owns logging policy and report orchestration.Architecture
libazureinit-kvpDIAGencoding/chunking, the report model and writer, CLI, and optional tracing bridgelibazureinitwireservermoduleazure-initTwo KVP paths share the same store: diagnostics append operation history; the provisioning report replaces the final status. HTTP reporting is a separate transport.
flowchart TD APP["Azure Init"] --> TRACE["Tracing spans and events"] TRACE --> LAYER["DiagnosticsKvp Layer<br/>capture and emit"] LAYER --> WRITER["DiagnosticWriter<br/>validate, encode, chunk"] WRITER -->|append| STORE["KvpPoolStore<br/>flock + OFD fcntl"] APP --> RESULT["Provisioning result<br/>one typed report"] RESULT --> PUBLISH["publish_provisioning_report<br/>tokio::join!"] PUBLISH --> WRITE["write_report<br/>spawn_blocking"] PUBLISH --> HTTP["wireserver<br/>report_ready<br/>report_failure"] WRITE -->|upsert| STORE STORE --> POOL["Guest pool 1<br/>.kvp_pool_1"] POOL -. host reads later .-> HOST["hv_kvp_daemon<br/>kernel and Hyper-V host"] HTTP --> WS["Azure wireserver"]Runtime Behavior
Diagnostics:
on_new_spanandon_closeproduce start/finish records with a shared operation UUID;on_recordretains field updates. Events receive independent UUIDs, including events outside spans. Payloads contain the tracing target, level, and recorded fields as JSON text.Span outcomes use an explicit
diagnostic.result, otherwise infer failure from observed ERROR events and success when none were observed. Detected unwinding reports failure. This is tracing-based inference: filtering and missing instrumentation can hide errors.Synchronous delivery: callbacks write through
DiagnosticsKvp::emit()and the existingDiagnosticWritervalidation and framing. No runtime, worker, queue, or drain lifecycle is required by the bridge. Callback failures go to stderr to avoid recursive tracing. Lock contention can delay callers; successful local writes do not guarantee durability or host receipt.Final status: the binary constructs one
ProvisioningReportfrom the actual provisioning result and attempts KVP and HTTP delivery withtokio::join!.write_report(&store, &report)runs throughspawn_blockingand upsertsPROVISIONING_REPORT. Failure HTTP requests reuse the report's encoding and timestamp; successful HTTP requests remain state-only.Final reports bypass tracing filters and remain available if diagnostic-writer initialization fails after pool preparation. Both delivery results are observed without changing the provisioning exit code. Existing report-size and store-capacity limits remain in effect.
Startup and Configuration
mainuses a scoped stderr-only bootstrap subscriber while obtaining the VM ID and loading configuration.setup_layersruns throughspawn_blocking, prepares the log file, and performs explicit stale-pool cleanup when KVP is enabled.maininstalls the configured subscriber globally. Defaults are stderr at ERROR, the private0600log file at DEBUG, and KVP at INFO (INFO/WARN/ERROR).AZURE_INIT_LOGcontrols file/console verbosity independently. KVP filter precedence isAZURE_INIT_KVP_FILTER, thentelemetry.kvp_filter, theninfo; empty or invalid values fall through to the next source.telemetry.kvp_diagnostics = falsedisables KVP setup, cleanup, diagnostics, and final-report writes without disabling local logs or wireserver HTTP. The reusable bridge itself installs no subscriber, chooses no filter, and performs no implicit cleanup; it is available behind the crate'stracingfeature.Cleanup and CI
libazureinitKVP, health, and logging modules and their unused OpenTelemetry,fs2, andsysinfodependencies. The binary retainssysinfofor OS/kernel information.testinitCI step using scratch pools, without launching extra provisioning runs.