This commit is contained in:
@@ -77,18 +77,23 @@ func (a *App) handleCreatePool(w http.ResponseWriter, r *http.Request) {
|
||||
req.Options = make(map[string]string)
|
||||
}
|
||||
|
||||
log.Printf("creating pool: name=%s, vdevs=%v, options=%v", req.Name, req.VDEVs, req.Options)
|
||||
|
||||
err := a.zfs.CreatePool(req.Name, req.VDEVs, req.Options)
|
||||
|
||||
// CRITICAL: Always check if pool exists, regardless of reported error
|
||||
// ZFS often reports mountpoint errors but pool is still created
|
||||
// The CreatePool function already does retries, but we double-check here
|
||||
// Wait a brief moment for pool to be fully registered
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
|
||||
pool, getErr := a.zfs.GetPool(req.Name)
|
||||
if getErr == nil {
|
||||
// Pool exists - this is success!
|
||||
if err != nil {
|
||||
log.Printf("info: pool %s created successfully despite reported error: %v", req.Name, err)
|
||||
log.Printf("info: pool %s created successfully despite CreatePool reporting error: %v", req.Name, err)
|
||||
} else {
|
||||
log.Printf("info: pool %s created successfully", req.Name)
|
||||
}
|
||||
// Set cache-control headers
|
||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
@@ -98,15 +103,21 @@ func (a *App) handleCreatePool(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Pool doesn't exist - return the error
|
||||
// Pool doesn't exist - return the error with detailed context
|
||||
if err != nil {
|
||||
log.Printf("create pool error: %v", err)
|
||||
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||
log.Printf("error: pool %s creation failed - CreatePool error: %v, GetPool error: %v", req.Name, err, getErr)
|
||||
writeJSON(w, http.StatusInternalServerError, map[string]string{
|
||||
"error": err.Error(),
|
||||
"details": fmt.Sprintf("Pool '%s' was not created. Check logs for zpool command output.", req.Name),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 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})
|
||||
log.Printf("warning: pool %s creation reported no error but pool was not found", req.Name)
|
||||
writeJSON(w, http.StatusInternalServerError, map[string]string{
|
||||
"error": fmt.Sprintf("Pool '%s' creation reported success but pool was not found", req.Name),
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) handleGetPool(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user