feat(service): timeout_sec без дефолта; 0=нет таймаута; operator v0.1.48
- api/v1alpha1/service_types.go: убрать +kubebuilder:default=30
- invoke.go: TimeoutSec=0 → &http.Client{} (без таймаута)
- services.go: валидация timeout_sec < 0 || > 900 → HTTP 400
- service_resource.go: TF schema Optional (без Computed); 0 → Int64Null()
- deployments/k8s/operator.yaml: v0.1.47 → v0.1.48
- doc/: progress.md + api/design.md (модель Service) + decisions/log.md
- examples/POSTGRES/: bug_hunter.sh, chaos_marathon.sh, chaos_marathon.tf
This commit is contained in:
@@ -46,15 +46,15 @@ var hopByHopHeaders = map[string]bool{
|
||||
"Upgrade": true,
|
||||
}
|
||||
|
||||
// invokeHTTPClient создаёт http.Client с таймаутом под конкретный вызов.
|
||||
// timeout = TimeoutSec + 5s буфер на сетевые задержки.
|
||||
// Если TimeoutSec == 0 (не задан), используем 35s по умолчанию.
|
||||
// invokeHTTPClient создаёт http.Client под конкретный вызов.
|
||||
// timeoutSec == 0 → Timeout: 0 = без ограничения (пользователь не установил лимит).
|
||||
// timeoutSec > 0 → Timeout: timeoutSec + 5s буфер на сетевые задержки.
|
||||
func invokeHTTPClient(timeoutSec int32) *http.Client {
|
||||
t := time.Duration(timeoutSec)*time.Second + 5*time.Second
|
||||
if timeoutSec <= 0 {
|
||||
t = 35 * time.Second
|
||||
// http.Client{Timeout: 0} в Go означает отсутствие таймаута.
|
||||
return &http.Client{}
|
||||
}
|
||||
return &http.Client{Timeout: t}
|
||||
return &http.Client{Timeout: time.Duration(timeoutSec)*time.Second + 5*time.Second}
|
||||
}
|
||||
|
||||
// InvokeFunction обрабатывает вызов /fn/{namespace}/{name}[/**].
|
||||
|
||||
@@ -113,6 +113,11 @@ func (h *Handler) CreateService(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusBadRequest, errResp("memory_mb must be between 1 and 4096"))
|
||||
return
|
||||
}
|
||||
// timeout_sec: 0 = нет ограничения (допустимо), отрицательное — ошибка.
|
||||
if req.TimeoutSec < 0 || req.TimeoutSec > 900 {
|
||||
writeJSON(w, http.StatusBadRequest, errResp("timeout_sec must be 0 (no limit) or 1–900"))
|
||||
return
|
||||
}
|
||||
|
||||
svc := &slessv1alpha1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -202,6 +207,11 @@ func (h *Handler) UpdateService(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusBadRequest, errResp("memory_mb must be between 1 and 4096"))
|
||||
return
|
||||
}
|
||||
// timeout_sec: 0 = нет ограничения (допустимо), отрицательное — ошибка.
|
||||
if req.TimeoutSec < 0 || req.TimeoutSec > 900 {
|
||||
writeJSON(w, http.StatusBadRequest, errResp("timeout_sec must be 0 (no limit) or 1–900"))
|
||||
return
|
||||
}
|
||||
|
||||
svc.Spec.Runtime = req.Runtime
|
||||
svc.Spec.Entrypoint = req.Entrypoint
|
||||
|
||||
Reference in New Issue
Block a user