v5.0.62: fix modify 500 (remove WithDefaults GET ?fields=cfsParams) + tests

This commit is contained in:
“Naeel”
2026-07-06 22:43:19 +04:00
parent 5696be934c
commit d9f2c60e90
7 changed files with 50 additions and 14 deletions
@@ -87,3 +87,44 @@ tf_provider/
- [x] yaml-generator → lib
- [ ] resource-generator → lib
- [ ] docs-generator → lib
---
## ⚠️ BUG: modify падает с 500 — GET ?fields=cfsParams вызывает getResourceRealmConfig
**Симптом:** `terraform apply` при modify возвращает:
```
не удалось получить детали операции: ошибка API 500: Invalid call of the function [getResourceRealmConfig], first Argument [resourceRealm] is of invalid type, Cannot cast Object type [Struct] to a value of type [string]
```
**Причина:** `RunInstanceOperationUniversalWithDefaults` (client.go:384) делает GET `/instanceOperations/{opUid}?fields=cfsParams`. Бэкенд (ColdFusion) при вычислении cfsParams вызывает `getResourceRealmConfig` через `expression_parser.cfc:184`. Если `resourceRealm` в контексте инстанса — Struct (объект), а не string, функция падает.
**Где проявляется:**
- `client.go:420``RunInstanceOperationUniversalWithDefaults` (modify/create/delete с дефолтами)
- `client.go:1399``RunInstanceOperationUniversalByCode` (операции по code)
- `client.go:224``CreateGenericInstanceUniversalV6` (CREATE flow) — работает на новых инстансах
**Почему на одних инстансах падает, на других нет:**
- Новые инстансы: `resourceRealm` = string → OK
- Старые/модифицированные: `resourceRealm` = Struct → 500
**Исправление (v5.0.62):**
- `crud.go:58`: `UpdateResourceWithTimeout``RunInstanceOperationUniversal` (без GET)
- GET не нужен для modify — все параметры уже известны из конфига
**Статус:** ✅ FIXED v5.0.62
**Файлы:**
- `/home/naeel/tf_provider/provider/internal/resources_core/crud.go:58`
- `/home/naeel/tf_provider/provider/internal/core/client.go:384` (WithDefaults — не используется в modify)
**Тесты (v5.0.62):**
- ✅ CREATE postgres — OK
- ✅ MODIFY postgres (replicas, backup_config, access_config) — OK
- ✅ CREATE/DELETE user — OK
- ✅ CREATE/DELETE database — OK
- ✅ Invalid role → 400 c понятным сообщением — OK
- ✅ No-change plan (идемпотентность) — OK
**Остаётся риск:**
- `RunInstanceOperationUniversalByCode` (client.go:1399) всё ещё делает GET — может упасть для service_operation_resource на проблемных инстансах
- `CreateGenericInstanceUniversalV6` (client.go:224) — CREATE на инстансах где resourceRealm = Struct может упасть
+2 -1
View File
@@ -1,6 +1,7 @@
# =============================================================================
# PostgreSQL — основной ресурс
# =============================================================================
resource "nubes_postgres" "npg" {
resource_name = "pg4tf033777" # ← ЗАМЕНИ на своё имя
@@ -14,7 +15,7 @@ resource "nubes_postgres" "npg" {
cpu = "500" # ← милликоры (1000 = 1 vCPU)
memory = "512" # ← MB
replicas = "1" # ← количество нод (1 = без реплики)
disk = "10" # ← GB
disk = "11" # ← GB
})
# ── Сетевой доступ ──
+1 -1
View File
@@ -2,7 +2,7 @@ terraform {
required_providers {
nubes = {
source = "terra.k8c.ru/nubes-test/nubes"
version = "5.0.59"
version = "5.0.62"
}
}
}
+3 -9
View File
@@ -1,5 +1,5 @@
resource "nubes_postgres" "npg" {
resource_name = "pg4tf033"
resource_name = "pgtst00"
startup_configuration = jsonencode({
resourceRealm = var.realm
@@ -14,7 +14,7 @@ resource "nubes_postgres" "npg" {
access_configuration = jsonencode({
masterIpSpace = "no-needed"
masterAccessList = []
masterAccessList = ["10.0.0.0/8"]
slaveIpSpace = "no-needed"
slaveAccessList = []
})
@@ -35,7 +35,7 @@ resource "nubes_postgres" "npg" {
backup_configuration = jsonencode({
s3Uid = var.s3_uid
retain = "7"
retain = "14"
schedule = "0 0 * * *"
})
@@ -57,10 +57,4 @@ resource "nubes_postgres_user" "pg_user" {
adopt_existing_on_create = true
}
resource "nubes_postgres_database" "db2_app" {
postgres_id = nubes_postgres.npg.id
db_name = "dbterra"
db_owner = nubes_postgres_user.pg_user.username
adopt_existing_on_create = true
}
+1 -1
View File
@@ -3,7 +3,7 @@ NUBES_API_ENDPOINT="https://lk-api-gateway-test.ngcloud.ru/api/v1/svc"
TOKEN_FILE="secrets/test.token"
# Version
VERSION="5.0.61"
VERSION="5.0.62"
# Docs generation — ONLY from docs_gen/<stand>/ (never from docs/)
DOCS_GEN_DIR="provider/docs_gen/test"
+1 -1
View File
@@ -55,7 +55,7 @@ func UpdateResourceWithTimeout(ctx context.Context, client *core.UniversalClient
if err != nil {
return err
}
return client.RunInstanceOperationUniversalWithDefaults(ctxWithTimeout, instanceID, "modify", params)
return client.RunInstanceOperationUniversal(ctxWithTimeout, instanceID, "modify", params)
}
// DeleteResource runs destroy behavior (suspend/state-only) for instance resources.
+1 -1
View File
@@ -17,7 +17,7 @@ import (
)
var (
version string = "5.0.61"
version string = "5.0.62"
)
func main() {