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

@@ -185,6 +185,10 @@ func (s *Service) CreatePool(name string, vdevs []string, options map[string]str
options = make(map[string]string)
}
// Add -f flag to force creation even if devices have existing filesystems
// This handles cases where devices are "in use" or contain "unknown filesystem"
args = append(args, "-f")
// If mountpoint is not explicitly set, use dedicated storage directory
mountpoint := options["mountpoint"]
if mountpoint == "" {
@@ -218,8 +222,26 @@ func (s *Service) CreatePool(name string, vdevs []string, options map[string]str
// Create the pool
_, err := s.execCommand(s.zpoolPath, args...)
// Even if creation reports an error, check if pool actually exists
// Sometimes ZFS reports errors but pool is still created
if err != nil {
return err
// Check if pool exists despite the error
if existingPools, listErr := s.ListPools(); listErr == nil {
for _, pool := range existingPools {
if pool.Name == name {
// Pool exists! Log the original error but don't fail
log.Printf("warning: pool creation reported error but pool %s exists: %v", name, err)
err = nil // Clear error since pool was created
break
}
}
}
// If pool doesn't exist and we still have an error, return it
if err != nil {
return err
}
}
// Pool created successfully - now try to set mountpoint and mount if needed