-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 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 93c290b
Improve KVP pool duplicate handling and API docs
peytonr18 cfc44ac
Updating KvpPoolStore to reflect new API design
peytonr18 4809bc5
Refactor libazureinit-kvp: split into error/store modules, improve co…
peytonr18 9d18e30
test(kvp): achieve 100% line and function coverage
peytonr18 2a73f01
Refactor KvpPoolStore: decouple free functions and alphabetize methods
peytonr18 38f7e39
Refactor KvpPoolStore: unify validation, relax read/delete key checks
peytonr18 c5531ac
Refactor KvpPoolStore: collapse KvpStore trait, surface unlock errors
peytonr18 d925931
Address PR feedback: dual flock+fcntl locking, explicit unlock, cleanup
peytonr18 1871cdd
libazureinit-kvp: add atomic populate() and consolidate tests with rs…
peytonr18 1761abb
Merge branch 'main' into probertson/kvp-store-trait
peytonr18 18a13b0
Updating utf size comments and remove_current comments for clarity
peytonr18 f9404b1
Refine KVP store locking and validation behavior
peytonr18 5f64e86
Adding tests to reach 100% code coverage
peytonr18 34f5f93
Merge branch 'main' into probertson/kvp-store-trait
peytonr18 386f496
test(kvp): consolidate tests via rstest and improve write-path coverage
peytonr18 3b3668e
fix(kvp): reject empty/null keys on read and delete
peytonr18 7518bfa
test(kvp-store): reach 100% region/line coverage via SysOps/Handle mocks
b6582a3
Merge branch 'main' into probertson/kvp-store-trait
cjp256 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 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,21 @@ | ||
| [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" | ||
| tracing = "0.1.40" | ||
|
|
||
| [dev-dependencies] | ||
| rstest = { version = "0.23", default-features = false } | ||
| tempfile = "3" | ||
|
|
||
| [lib] | ||
| name = "libazureinit_kvp" | ||
| path = "src/lib.rs" |
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,65 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| use std::fmt; | ||
| use std::io; | ||
|
|
||
| /// Errors returned by [`KvpPoolStore`](crate::KvpPoolStore) operations. | ||
| #[derive(Debug)] | ||
| pub enum KvpError { | ||
| /// The key was empty. | ||
| EmptyKey, | ||
| /// An underlying I/O error. | ||
| Io(io::Error), | ||
| /// The key contains a null byte, which is incompatible with the | ||
| /// on-disk format (null-padded fixed-width fields). | ||
| KeyContainsNull, | ||
| /// The key exceeds the store's maximum key size. | ||
| KeyTooLarge { max: usize, actual: usize }, | ||
| /// The store already has the maximum allowed number of unique keys. | ||
| MaxUniqueKeysExceeded { max: usize }, | ||
| /// The value exceeds the store's maximum value size. | ||
| ValueTooLarge { max: usize, actual: usize }, | ||
| /// The value contains a null byte, which is incompatible with the | ||
| /// null-padded KVP wire format. | ||
| ValueContainsNull, | ||
| } | ||
|
|
||
| impl fmt::Display for KvpError { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| match self { | ||
| Self::EmptyKey => write!(f, "KVP key must not be empty"), | ||
| Self::Io(e) => write!(f, "{e}"), | ||
| Self::KeyContainsNull => { | ||
| write!(f, "KVP key must not contain null bytes") | ||
| } | ||
| Self::KeyTooLarge { max, actual } => { | ||
| write!(f, "KVP key length ({actual}) exceeds maximum ({max})") | ||
| } | ||
| Self::MaxUniqueKeysExceeded { max } => { | ||
| write!(f, "KVP unique key count exceeded maximum ({max})") | ||
| } | ||
| Self::ValueTooLarge { max, actual } => { | ||
| write!(f, "KVP value length ({actual}) exceeds maximum ({max})") | ||
| } | ||
| Self::ValueContainsNull => { | ||
| write!(f, "KVP value must not contain null bytes") | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl std::error::Error for KvpError { | ||
| fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { | ||
| match self { | ||
| Self::Io(e) => Some(e), | ||
| _ => None, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<io::Error> for KvpError { | ||
| fn from(err: io::Error) -> Self { | ||
| Self::Io(err) | ||
| } | ||
| } | ||
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,14 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| //! `libazureinit-kvp` provides a unified KVP pool file store for | ||
| //! Hyper-V/Azure guests. | ||
| //! | ||
| //! - [`KvpPoolStore`]: KVP pool file store with | ||
| //! [`PoolMode`]-based policy. | ||
|
|
||
| mod error; | ||
| mod store; | ||
|
|
||
| pub use error::KvpError; | ||
| pub use store::{KvpPool, KvpPoolStore, PoolMode}; |
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.
Uh oh!
There was an error while loading. Please reload this page.