still working on the UI error
Some checks failed
CI / test-build (push) Has been cancelled

This commit is contained in:
2025-12-18 12:33:08 +07:00
parent b335b0d9f3
commit d55206af82
3 changed files with 56 additions and 12 deletions

View File

@@ -76,19 +76,29 @@ func (a *App) handleCreatePool(w http.ResponseWriter, r *http.Request) {
req.Options = make(map[string]string)
}
if err := a.zfs.CreatePool(req.Name, req.VDEVs, req.Options); err != nil {
err := a.zfs.CreatePool(req.Name, req.VDEVs, req.Options)
// Always check if pool exists, even if creation reported an error
// Sometimes pool is created despite errors (e.g., mountpoint issues)
pool, getErr := a.zfs.GetPool(req.Name)
if getErr == nil {
// Pool exists - return success even if creation reported an error
if err != nil {
log.Printf("create pool reported error but pool exists: %v", err)
}
writeJSON(w, http.StatusCreated, pool)
return
}
// Pool doesn't exist - return the error
if err != nil {
log.Printf("create pool error: %v", err)
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
}
pool, err := a.zfs.GetPool(req.Name)
if err != nil {
writeJSON(w, http.StatusCreated, map[string]string{"message": "pool created", "name": req.Name})
return
}
writeJSON(w, http.StatusCreated, pool)
// No error but pool doesn't exist (shouldn't happen, but handle it)
writeJSON(w, http.StatusCreated, map[string]string{"message": "pool created", "name": req.Name})
}
func (a *App) handleGetPool(w http.ResponseWriter, r *http.Request) {