fix: operator v0.1.23 — BackoffLimit=2 в kaniko, пересоздание Failed функций; script: mod2 96→128

This commit is contained in:
“Naeel”
2026-03-11 12:26:06 +04:00
parent 3dc39ddc20
commit 59563eba76
4 changed files with 23 additions and 7 deletions
+15
View File
@@ -115,6 +115,21 @@ func (h *Handler) CreateFunction(w http.ResponseWriter, r *http.Request) {
}
if err := h.K8s.Create(r.Context(), fn); err != nil {
if errors.IsAlreadyExists(err) {
// Если существующая функция в статусе Failed (build провалился, terraform не
// добавил её в state) — удаляем её и пересоздаём, иначе клиент получит 409 навсегда.
existing := &slessv1alpha1.Function{}
if getErr := h.K8s.Get(r.Context(), client.ObjectKey{Name: req.Name, Namespace: ns}, existing); getErr == nil &&
existing.Status.Phase == slessv1alpha1.FunctionPhaseFailed {
_ = h.K8s.Delete(r.Context(), existing)
// Создаём заново с теми же параметрами
fn.ResourceVersion = ""
if createErr := h.K8s.Create(r.Context(), fn); createErr != nil {
writeJSON(w, http.StatusInternalServerError, errResp(createErr.Error()))
return
}
writeJSON(w, http.StatusCreated, fnToResponse(fn))
return
}
writeJSON(w, http.StatusConflict, errResp("function already exists"))
return
}