probeNFSServer checks the NFS server's reachability before the mount call.
(serverExport string)
| 392 | |
| 393 | // probeNFSServer checks the NFS server's reachability before the mount call. |
| 394 | func (n *NFSClientSetup) probeNFSServer(serverExport string) error { |
| 395 | host, _, ok := strings.Cut(serverExport, ":") |
| 396 | if !ok || host == "" { |
| 397 | return fmt.Errorf("invalid server export %q (expected <server>:<path>)", serverExport) |
| 398 | } |
| 399 | |
| 400 | // Ping to test if ip/hostname is reachable. |
| 401 | pingStart := time.Now() |
| 402 | if _, err := cmd.NewExecutor("", "ping", "-c", "1", "-W", "3", host).ExecuteOutput(); err != nil { |
| 403 | return fmt.Errorf("NFS server %q is not reachable (ping failed in %s); check the IP/hostname and the network -> %w", host, time.Since(pingStart).Truncate(time.Millisecond), err) |
| 404 | } |
| 405 | |
| 406 | return nil |
| 407 | } |
| 408 | |
| 409 | // checkServerTools verifies that all system packages needed by server setup are installed. |
| 410 | func checkServerTools() error { |
no test coverage detected