Azure / Azure/azure-init

[RFE] Decouple `azure-init` Main Flow from `report_ready` / `report_failure`

Open
#266 0 comments 0 reactions 1 assignee Claimed by @peytonr18 View on GitHub
feature
Dominant language
Rust
Stars
16
Forks
20
Avg merge
2d 14h
Merged PRs (30d)
1

Description

## Description
Currently, the `azure-init` main flow in `main.rs` tightly couples provisioning logic with reporting success or failure to the health endpoint. Specifically:

- On provisioning success, `report_ready()` is called immediately.
- On provisioning failure, `report_failure()` is called immediately.
- Configuration load errors trigger `report_failure()` inline.

This design makes reporting dependent on provisioning, which limits flexibility for future enhancements such as exposing APIs for `report_ready` and `report_failure`.

## Problem
- Reporting logic is embedded directly in the main provisioning flow.
- Cannot invoke `report_ready` or `report_failure` independently of provisioning.
- Harder to support external consumers or APIs that need reporting without full provisioning.

## Solution
- Remove inline calls to `report_ready()` and `report_failure` from `main.rs`.
- Update `Provision::provision()` to return status without forcing reporting.

## Relevant Code
The current coupling occurs in `main.rs`:
```rust
match provision(config, &vm_id, opts).await {
Ok(_) => {
let report_result =
report_ready(&clone_config, &vm_id, None).await;
.....
ExitCode::SUCCESS
}
Err(e) => {
...
let report_result =
report_failure(report_str, &clone_config).await;
....
tracing::error!("Provisioning failed with error: {e:?}");
....
}
}
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.