Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(overlord): pebble hangs with a read-only file system when starting the daemon #481

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internals/overlord/overlord.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ func New(opts *Options) (*Overlord, error) {
if !osutil.IsDir(o.pebbleDir) {
return nil, fmt.Errorf("directory %q does not exist", o.pebbleDir)
}
if !osutil.IsWritable(o.pebbleDir) {
return nil, fmt.Errorf("directory %q not writable", o.pebbleDir)
}

statePath := filepath.Join(o.pebbleDir, cmd.StateFile)

backend := &overlordStateBackend{
Expand Down Expand Up @@ -256,7 +260,6 @@ func loadState(statePath string, restartHandler restart.Handler, backend state.B
patch.Init(s)
return s, restartMgr, nil
}

r, err := os.Open(statePath)
if err != nil {
return nil, nil, fmt.Errorf("cannot read the state file: %s", err)
Expand Down
4 changes: 3 additions & 1 deletion internals/overlord/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ func (s *State) Unlocker() (unlock func() (relock func())) {
// After too many unsuccessful checkpoint attempts, it panics.
func (s *State) Unlock() {
defer s.unlock()

if !s.modified || s.backend == nil {
return
}
Expand All @@ -293,6 +292,9 @@ func (s *State) Unlock() {
s.modified = false
return
}

logger.Noticef("Cannot write state file, retrying: %v", err)

time.Sleep(unlockCheckpointRetryInterval)
}
logger.Panicf("cannot checkpoint even after %v of retries every %v: %v", unlockCheckpointRetryMaxTime, unlockCheckpointRetryInterval, err)
Expand Down
Loading