-
Notifications
You must be signed in to change notification settings - Fork 16
feat(kvp): add store trait and Hyper-V KVP storage crate #288
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
Open
peytonr18
wants to merge
10
commits into
Azure:main
Choose a base branch
from
peytonr18:probertson/kvp-store-trait
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f435f70
feat(kvp): add store trait and Hyper-V KVP storage crate
peytonr18 5226e32
add Azure autodetect limits selection for HyperVKvpStore
peytonr18 c1440c9
Improving libazurekvp.md clarity
peytonr18 d63dd42
feat(kvp): harden Hyper-V record decode and refactor stale truncate t…
peytonr18 62a52fe
Refactor libazureinit-kvp: KvpStore trait, KvpError, HyperV/Azure spl…
peytonr18 498d136
Flatten implementation such that there is one trait and one implement…
peytonr18 b93a5d3
Merge branch 'main' into probertson/kvp-store-trait
peytonr18 e681b59
Refactor libazureinit-kvp: simplify KvpStore trait, add upsert semant…
peytonr18 ae03af6
Refactor libazureinit-kvp: replace flock-based locking with fcntl OFD…
peytonr18 8445370
feat(kvp): split insert and append semantics for pool store
peytonr18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # PR: Add `libazureinit-kvp` with unified KVP pool store | ||
|
|
||
| ## Summary | ||
|
|
||
| - Adds workspace member `libazureinit-kvp` in root `Cargo.toml` | ||
| - Adds `libazureinit-kvp/Cargo.toml` | ||
| - Adds `libazureinit-kvp/src/lib.rs` and `libazureinit-kvp/src/kvp_pool.rs` | ||
|
|
||
| ## Crate Design | ||
|
|
||
| - One trait: `KvpStore` | ||
| - One implementation: `KvpPoolStore` | ||
|
|
||
| `KvpStore` splits each operation into a `backend_*` method (raw I/O, | ||
| provided by the implementor) and a public method (`write`, `read`, | ||
| `clear`) that validates inputs then delegates to the backend. | ||
|
|
||
| Public API: | ||
|
|
||
| - `write`, `read` (validate then delegate to `backend_write`/`backend_read`) | ||
| - `entries`, `entries_raw` | ||
| - `delete`, `clear` | ||
| - `is_stale` | ||
|
|
||
| Validation is centralized in trait default methods and policy-aware via: | ||
|
|
||
| - `max_key_size(&self)` | ||
| - `max_value_size(&self)` | ||
|
|
||
| `KvpPoolStore` is file-backed using Hyper-V KVP wire format | ||
| (fixed-size 512-byte key + 2048-byte value records), with lock-based concurrency. | ||
|
|
||
| ## Policy and Limits | ||
|
|
||
| Constructor: | ||
|
|
||
| - `new(path: Option<PathBuf>, mode: PoolMode, truncate_on_stale: bool)` | ||
|
|
||
| `PoolMode`: | ||
|
|
||
| - `Restricted` (default): key <= 254 bytes, value <= 1022 bytes | ||
| - `Full`: key <= 512 bytes, value <= 2048 bytes | ||
|
|
||
| Behavior: | ||
|
|
||
| - Default path when `None`: `/var/lib/hyperv/.kvp_pool_1` | ||
| - Unique key cap: 1024 | ||
| - new key beyond cap is rejected | ||
| - overwrite of existing key at cap is allowed | ||
| - `clear()` truncates the store | ||
| - `truncate_on_stale` keeps truncation caller-controlled | ||
|
|
||
| ## Errors | ||
|
|
||
| `KvpError` includes explicit variants: | ||
|
|
||
| - `EmptyKey` | ||
| - `KeyContainsNull` | ||
| - `KeyTooLarge { max, actual }` | ||
| - `ValueTooLarge { max, actual }` | ||
| - `MaxUniqueKeysExceeded { max }` | ||
| - `Io(io::Error)` | ||
|
|
||
| ## Testing | ||
|
|
||
| 17 tests covering: | ||
|
|
||
| - restricted/full key/value boundary checks | ||
| - default and explicit path behavior | ||
| - mode getter | ||
| - unique-key cap behavior (including overwrite-at-cap and add-after-delete) | ||
| - `entries` last-write-wins and `entries_raw` duplicate preservation | ||
| - `delete`, `clear`, and stale checks | ||
| - key validation (empty and null-byte) | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| [package] | ||
| name = "libazureinit-kvp" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| rust-version = "1.88" | ||
| repository = "https://github.com/Azure/azure-init/" | ||
| homepage = "https://github.com/Azure/azure-init/" | ||
| license = "MIT" | ||
| description = "Hyper-V KVP (Key-Value Pair) storage library for azure-init." | ||
|
|
||
| [dependencies] | ||
| libc = "0.2" | ||
| serde = { version = "1", features = ["derive"] } | ||
| serde_json = "1" | ||
| sysinfo = "0.38" | ||
|
|
||
| [dev-dependencies] | ||
| tempfile = "3" | ||
|
|
||
| [lib] | ||
| name = "libazureinit_kvp" | ||
| path = "src/lib.rs" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file seems out of date - is it going to be deleted?