Skip to content

Commit

Permalink
Merge ed9709a into backport/gh-19720-empty-server-metadata/implicitly…
Browse files Browse the repository at this point in the history
…-apt-vulture
  • Loading branch information
hc-github-team-consul-core authored Jan 5, 2024
2 parents 3b98692 + ed9709a commit 9ddeb0e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -4570,12 +4570,15 @@ func (a *Agent) persistServerMetadata() {
continue
}

sf := f.(*safeio.File)
if err := sf.Commit(); err != nil {
a.logger.Error("failed to commit server metadata", "error", err)
continue
// Use safeio.File to ensure the file is written to disk atomically
if sf, ok := f.(*safeio.File); ok {
if err := sf.Commit(); err != nil {
sf.Close()
a.logger.Error("failed to commit server metadata", "error", err)
continue
}
}
sf.Close()
f.Close()
case <-a.shutdownCh:
return
}
Expand Down

0 comments on commit 9ddeb0e

Please sign in to comment.