1.9 KiB
1.9 KiB
02. Tubulus Stabilization & The "Iron Logic" of Polling
Date: 2026-01-27 Operator: GitHub Copilot (Gemini 3 Pro) Task: Fix Tubulus Creation and Polling
The Problem
The nubes_tubulus_instance resource was unstable:
- Timeouts: Operations would finish, but the provider kept waiting until the hard timeout.
- Bad Requests: Valid inputs (empty maps) were rejected by the API.
- Terraform Errors: "Provider returned invalid result object" (Unknown values) after Apply.
The Investigation (HAR Analysis)
We analyzed 14 HAR files covering various scenarios (Success, Failure, Fast, Slow).
Key finding: The API has a strict contract regarding dtFinish.
dtFinishappears exactly when the operation ends.- Waiting for
status="COMPLETED"or similar text fields is unreliable. isSuccessfulis only valid afterdtFinishis present.
The Solution
-
Refactored Polling (
waitForOperationAndInstanceStatus):- Implemented strict check: If
dtFinish != nil, stop waiting. - If
isSuccessfulis true -> Success. Else -> Error. - Removed arbitrary sleeps and secondary status checks.
- Implemented strict check: If
-
Fixed Parameter Submission (
submitOperationParams):- Restored logic to send
"{}"for empty map/json types. - Added fallback mapping using
SvcOperationCfsParamkey.
- Restored logic to send
-
Fixed Instance Reading (
readInstance):- Added
?fields=...explainedStatusto GET request to ensure status is returned. - Updated
InstanceResponsestruct to match API wrapper{"instance": {...}}.
- Added
-
Fixed Terraform State (
Create):- Explicitly set all
Unknowncomputed fields toNullat the end of resource creation to satisfy Terraform's safety checks.
- Explicitly set all
Outcome
Test 014 (Lifecycle Create) passed successfully in 33 seconds.
Directives for Future
- DO NOT TOUCH
tubulus_resource.gopolling logic. It is based on hard evidence. - Always check
dtFinishfor Nubes operations.