2.7 KiB
Tubulus (Bolvanka) & Polling Logic Discovery
Overview
This document describes the critical discovery made regarding the Nubes Tubulus (Bolvanka) service and, more importantly, the strict polling logic required to interact with the Nubes API reliably.
The "Bolvanka" Service
Tubulus is a test service ("Bolvanka") that mimics long-running operations. It is used to test the provider's lifecycle management capabilities, including:
- Creating instances with delays.
- Handling failures at different stages (Start, InProgress).
- Soft Delete (Resume) logic.
Critical Polling Logic (The "Iron Logic")
After analyzing 14+ HAR files (HTTP Archives) from real API interactions, the following INVARIANT behavior was established for Instance Operations (instanceOperations):
1. The dtFinish Rule
- dtFinish is NULL while the operation is running (PENDING, IN_PROGRESS).
- dtFinish is NOT NULL (contains a timestamp) IMMEDIATELY when the operation finishes.
- IMPLICATION:
dtFinishis the ONLY reliable source of truth for completion. Do not rely onstatus,isInProgress, orisPending.
2. The Success/Failure Rule
Once dtFinish is detected (not null), the success is determined solely by isSuccessful:
- isSuccessful == true: Operation succeeded. Proceed to read instance.
- isSuccessful == false: Operation failed.
- isSuccessful == null: Operation failed (or indeterminate state treated as failure).
3. The Instance Status Rule
- Do NOT check instance status while the operation is running. It will be "not created" or "suspended".
- Only after Operation Success (dtFinish != nil && isSuccessful == true) should you expect the Instance status to be
running.
Parameter Submission Logic
To successfully execute an operation (run), parameters must be submitted correctly:
- Empty Maps/JSONs: Must be sent as
"{}". Sending""causes400 Bad Request. - Empty Lists: Must be sent as
"[]". - Mapping keys: The API returns parameters with
code,name, andsvcOperationCfsParam. Terraform resource attributes must be mapped to one of these (fallback order: Code -> Name -> SvcOperationCfsParam).
Terraform "Unknown" Values
The Terraform Provider Framework requires that all attributes marked as Computed have a known value after Apply.
- The Nubes API
readInstancedoes NOT return fields likefail_at_start,duration_ms, etc. - SOLUTION: In the
Createmethod, after reading the instance status, all optional computed fields that are stillUnknownmust be explicitly set toNull.
Reference Code
See internal/provider/tubulus_resource.go for the implementation.
DO NOT CHANGE THE POLLING OR PARAMETER LOGIC WITHOUT REVIEWING THIS DOCUMENT.