Skip to content

client: offer a json backend for the state store#28040

Draft
schmichael wants to merge 3 commits into
mainfrom
f-jsondb
Draft

client: offer a json backend for the state store#28040
schmichael wants to merge 3 commits into
mainfrom
f-jsondb

Conversation

@schmichael
Copy link
Copy Markdown
Member

@schmichael schmichael commented May 22, 2026

Description

Inspired by @pkazmierczak's work in #27934 and Tailscale, I wanted to explore the "simplest" possible client state solution that was still reasonably safe. So here's a json backend for our client state that has to perform like complete garbage. If only I had written the bolt de-duplication layer in c0d1b63 generically so it could be reused here. 🤷

Testing & Reproduction steps

No tests. Do Not merge.

Should probably fsync the directory itself to ensure crash safety like raft-wal does: https://github.com/hashicorp/raft-wal/blob/f9846d205596489efa6a2a04d72a564a7fecbe44/fs/fs.go#L117-L128

Easiest way to test is to edit this line to return NewJsonDB:

return NewBoltStateDB

Contributor Checklist

  • Changelog Entry If this PR changes user-facing behavior, please generate and add a
    changelog entry using the make cl command.
  • Testing Please add tests to cover any new functionality or to demonstrate bug fixes and
    ensure regressions will be caught.
  • Documentation If the change impacts user-facing functionality such as the CLI, API, UI,
    and job configuration, please update the Nomad product documentation, which is stored in the
    web-unified-docs repo. Refer to the web-unified-docs contributor guide for docs guidelines.
    Please also consider whether the change requires notes within the upgrade
    guide
    . If you would like help with the docs, tag the nomad-docs team in this PR.

Reviewer Checklist

  • Backport Labels Please add the correct backport labels as described by the internal
    backporting document.
  • Commit Type Ensure the correct merge method is selected which should be "squash and merge"
    in the majority of situations. The main exceptions are long-lived feature branches or merges where
    history should be preserved.
  • Enterprise PRs If this is an enterprise only PR, please add any required changelog entry
    within the public repository.
  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

writes clients state to a file as json

uses a temporary file + rename to perform an atomic write on unix

uses a lock file to hopefully prevent disaster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant