feat(core): surface PVE task warnings from VM/container operations#2761
feat(core): surface PVE task warnings from VM/container operations#2761
Conversation
Introduces TaskResult to carry both the task error and any warning lines from the task log, enabling callers to surface warnings as Terraform diagnostics in subsequent tasks. Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Replace the `error` return type with `*TaskResult` so callers can surface both the error and any task-log warnings to Terraform diagnostics. Rename logTaskWarnings → getTaskWarnings (returns []string) and taskFailedError → taskFailedResult (returns *TaskResult). Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Change CreateContainer, CloneContainer, StartContainer, and CloneVM to return *tasks.TaskResult instead of error, capturing the full TaskResult from WaitForTask closures. Update all callers in SDK resources, Framework resources, and tests to surface warnings as Terraform diagnostics. Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
- Filter out "TASK WARNINGS: N" summary line from warnings (noise) - Add nil-receiver safety to TaskResult methods - Standardize warning format in SDK VM resource (one diagnostic per warning) - Revert unrelated doc change Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
There was a problem hiding this comment.
Code Review
This pull request introduces a centralized TaskResult type to capture Proxmox task outcomes, enabling the provider to surface warnings from task logs as Terraform diagnostics. The changes refactor WaitForTask and various VM/container lifecycle methods across the fwprovider and proxmoxtf packages to handle these results. Review feedback suggests improving consistency in StartVM by utilizing task options for warning suppression and refactoring duplicated log-parsing logic into a shared helper method.
- Extract filterWarnings helper to deduplicate warning line extraction - Simplify StartVM to use WithIgnoreWarnings() for consistency Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new TaskResult type to handle Proxmox task outcomes, allowing for the propagation of task warnings as Terraform diagnostics instead of silently ignoring them. The changes update various API methods to return this new TaskResult and adjust the corresponding resource logic to surface these warnings. I have provided feedback regarding potential improvements to log fetching, consistency in handling warnings across different VM operations, and ensuring warnings are preserved during error scenarios.
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new TaskResult type to capture and surface Proxmox task warnings as Terraform diagnostics, refactoring the task execution logic across multiple API clients. Review feedback highlights several locations where WithIgnoreWarnings() should be applied to ensure warnings are correctly propagated rather than causing fatal errors, and suggests using TaskFailedWithWarnings to prevent data loss when status checks fail. Further improvements are recommended to ensure helper functions and legacy SDK resources consistently handle and report these warnings.
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a TaskResult structure to capture and surface warnings from Proxmox tasks, updating the API clients and both the Framework and SDK providers to report these as Terraform diagnostics. The review feedback identifies several locations where warnings are discarded if an error occurs due to early returns, and suggests implementing a fallback warning message when task logs do not yield specific filtered results despite a warning exit code.
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a structured TaskResult type to capture and surface Proxmox task warnings as Terraform diagnostics, replacing simple error returns across the VM, container, and ACME API clients. The implementation updates both the Framework and SDK providers to utilize helper methods for accumulating these warnings, ensuring they are visible to users rather than silently ignored. Feedback highlighted a potential limitation where the 50-line log-fetching default might miss warnings in longer task outputs.
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new TaskResult type to better handle Proxmox task outcomes, specifically allowing for the capture and propagation of non-fatal warnings from task logs to Terraform diagnostics. The changes involve refactoring numerous API methods across the proxmox and fwprovider packages to return TaskResult instead of a simple error. While the framework-based resources in fwprovider have been updated to use the new AddDiags helper, several locations in the legacy proxmoxtf (SDK) resources still only check the error field of the TaskResult, causing task warnings to be silently dropped. Feedback is provided to ensure consistent warning propagation across all resource types.
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements a centralized TaskResult system to capture and surface Proxmox task warnings as Terraform diagnostics, ensuring that warnings in task logs are no longer silently ignored. The changes span both the modern framework (fwprovider/) and legacy SDK (proxmoxtf/) providers, refactoring VM, container, and ACME certificate resources to utilize the new result type. Additionally, the task-waiting logic in the Proxmox client was updated to fetch logs and filter for warning strings. Feedback suggests moving the SDK-specific diagnostic helpers to a more central location within the legacy resource package to improve modularity and consistency.
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new TaskResult type to standardize the handling of Proxmox task outcomes, including the ability to capture and surface task log warnings as Terraform diagnostics. It refactors various API client methods to return this TaskResult instead of raw errors, and updates the corresponding resource logic in both the Framework and SDK providers to properly accumulate and report these diagnostics. I have provided feedback regarding the need for consistent diagnostic handling in the migrateNonHAVM function to ensure all task warnings are correctly surfaced.
Signed-off-by: Pavel Boldyrev <pavel@bpg.sh>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new TaskResult type to capture and surface Proxmox task warnings as Terraform diagnostics across the provider. It refactors VM, container, and storage clients to return this new type, allowing for more granular error and warning reporting in both the modern Framework and legacy SDK providers. Additionally, it ensures that non-fatal failures during resource deletion, such as VM shutdown issues, are reported as warnings rather than errors. I have no feedback to provide as no review comments were submitted.
What does this PR do?
When a Proxmox task completes with warnings (e.g.,
WARNINGS: 1) or fails, the provider now fetches the task log and includes it in the error message or surfaces warnings as Terraform diagnostics. Previously, warnings were either silently ignored (WithIgnoreWarnings) or produced an opaque error liketask "UPID:..." failed to complete with exit code: WARNINGS: 1with no indication of what went wrong.Introduces a
TaskResulttype that replaces theerrorreturn fromWaitForTaskand the([]string, error)return fromStartVM. This allows callers to propagate task warnings through the call stack and surface them as Terraform diagnostic warnings visible intofu applyoutput.Closes #2597
Closes #2702
Contributor's Note
make lintand fixed any issues.make docs; SDK: manual/docs/edits).!in PR title).make exampleto verify the change works (mainly for SDK / provider config changes).Proof of Work
Unit Tests (7/7 passing)
Acceptance tests (full suite)
make example— Warnings Surfaced in Terraform OutputPVE task history shows

Warning: 1on all three container operations (Create, Clone, Start):Terraform output now surfaces these warnings:
Before / After
Before: Container creation with systemd warnings either:
task "UPID:..." failed to complete with exit code: WARNINGS: 1WithIgnoreWarnings) with no indication of the warningAfter:
tofu applyoutput)TASK WARNINGS: Nsummary noise filtered from warning outputCommunity Note