Skip to content

Commit 125d1db

Browse files
committed
Autodetect readonly host FS
Assume that host client shutdown flag reflects readonly FS Signed-off-by: Alessandro Vinciguerra <alessandro.vinciguerra@postfinance.ch>
1 parent f2ec524 commit 125d1db

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/mig/reconfigure/reconfigure.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ package reconfigure
1919
import (
2020
"context"
2121
"encoding/json"
22+
"errors"
2223
"fmt"
2324
"os"
2425
"os/exec"
2526
"path/filepath"
2627
"strings"
28+
"syscall"
2729
"time"
2830

2931
log "github.com/sirupsen/logrus"
@@ -322,6 +324,10 @@ Environment="MIG_PARTED_SELECTED_CONFIG=%s"
322324

323325
// Write config to file
324326
if err := os.WriteFile(stateFilePath, []byte(config), 0600); err != nil {
327+
if errors.Is(err, syscall.EROFS) {
328+
log.Warn("Cannot persist to readonly host")
329+
return nil
330+
}
325331
return fmt.Errorf("failed to write config to state file: %w", err)
326332
}
327333

0 commit comments

Comments
 (0)