main #1

Closed
othman.suseno wants to merge 25 commits from main into development
Showing only changes of commit 4b11d839ec - Show all commits

View File

@@ -82,7 +82,7 @@ func (s *Service) execCommand(name string, args ...string) (string, error) {
if err != nil && useSudo {
// Log that sudo failed
log.Printf("sudo command failed, trying direct execution: %s %v (error: %v, stderr: %s)", name, args, err, stderr.String())
// If sudo failed, try running the command directly
// (user might already have permissions or be root)
directCmd := exec.Command(name, args...)
@@ -90,7 +90,8 @@ func (s *Service) execCommand(name string, args ...string) (string, error) {
directCmd.Stdout = &directStdout
directCmd.Stderr = &directStderr
if directErr := directCmd.Run(); directErr == nil {
directErr := directCmd.Run()
if directErr == nil {
// Direct execution succeeded, return that result
log.Printf("direct command execution succeeded (without sudo)")
return strings.TrimSpace(directStdout.String()), nil
@@ -231,7 +232,7 @@ func (s *Service) CreatePool(name string, vdevs []string, options map[string]str
}
args = append(args, name)
// Normalize vdev paths - ensure they start with /dev/ if they don't already
normalizedVdevs := make([]string, 0, len(vdevs))
for _, vdev := range vdevs {
@@ -245,11 +246,11 @@ func (s *Service) CreatePool(name string, vdevs []string, options map[string]str
}
normalizedVdevs = append(normalizedVdevs, vdev)
}
if len(normalizedVdevs) == 0 {
return fmt.Errorf("no valid vdevs provided after normalization")
}
args = append(args, normalizedVdevs...)
// Log the command we're about to run for debugging