Increase upload multipart limit for raw export bundles

This commit is contained in:
Mikhail Chusavitin
2026-02-24 17:42:49 +03:00
parent 6f66a8b2a1
commit 752b063613

View File

@@ -14,6 +14,7 @@ import (
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
"time"
@@ -46,8 +47,7 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
}
func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) {
// Max 100MB file
if err := r.ParseMultipartForm(100 << 20); err != nil {
if err := r.ParseMultipartForm(uploadMultipartMaxBytes()); err != nil {
jsonError(w, "File too large", http.StatusBadRequest)
return
}
@@ -143,6 +143,29 @@ func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) {
})
}
func uploadMultipartMaxBytes() int64 {
// Large Redfish raw bundles can easily exceed 100 MiB once raw trees and logs
// are embedded. Keep the default high but bounded for a normal workstation.
const (
defMB = 512
minMB = 100
maxMB = 2048
)
mb := defMB
if v := strings.TrimSpace(os.Getenv("LOGPILE_UPLOAD_MAX_MB")); v != "" {
if n, err := strconv.Atoi(v); err == nil {
if n < minMB {
n = minMB
}
if n > maxMB {
n = maxMB
}
mb = n
}
}
return int64(mb) << 20
}
func (s *Server) reanalyzeRawExportPackage(pkg *RawExportPackage) (*models.AnalysisResult, string, error) {
if pkg == nil {
return nil, "", fmt.Errorf("empty package")