fix: P0.2 — auto-cleanup not_created orphan instances on adopt
This commit is contained in:
@@ -130,7 +130,13 @@ func adoptExistingInstanceOnCreate(ctx context.Context, client *core.UniversalCl
|
|||||||
}
|
}
|
||||||
status := normalizeStatus(existing.ExplainedStatus)
|
status := normalizeStatus(existing.ExplainedStatus)
|
||||||
if isStatusNotCreated(status) {
|
if isStatusNotCreated(status) {
|
||||||
return "", fmt.Errorf("инстанс с resource_name %s найден в состоянии Not Created; удалите его в Личном кабинете (Управление облаком) и повторите apply. %s", displayName, formatInstanceDetails(existing, serviceID, displayName))
|
// P0.2: авто-cleanup orphan-инстанса при adopt_existing_on_create=true.
|
||||||
|
// Вместо «удалите вручную в ЛК» — удаляем сами и создаём новый.
|
||||||
|
if err := client.RunInstanceOperationUniversal(ctx, existing.InstanceUid, "delete", nil); err != nil {
|
||||||
|
return "", fmt.Errorf("не удалось авто-удалить orphan-инстанс %s (статус: %s): %w. %s",
|
||||||
|
existing.InstanceUid, status, err, formatInstanceDetails(existing, serviceID, displayName))
|
||||||
|
}
|
||||||
|
return client.CreateGenericInstanceUniversalV6(ctx, serviceID, displayName, params)
|
||||||
}
|
}
|
||||||
if isStatusRunning(status) {
|
if isStatusRunning(status) {
|
||||||
// Валидация ref-параметров для running инстанса при adopt
|
// Валидация ref-параметров для running инстанса при adopt
|
||||||
|
|||||||
Reference in New Issue
Block a user