From 8b35a946d9f6b31b26b9783acbfab984316051f4 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 23 Feb 2024 17:09:47 +0100 Subject: [PATCH 01/73] Allow external HTTP client --- src/k2v-client/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/k2v-client/lib.rs b/src/k2v-client/lib.rs index 852274a7..5b6d7f58 100644 --- a/src/k2v-client/lib.rs +++ b/src/k2v-client/lib.rs @@ -72,6 +72,16 @@ impl K2vClient { .enable_http2() .build(); let client = HttpClient::builder(TokioExecutor::new()).build(connector); + Self::new_with_client(config, client) + } + + /// Create a new K2V client with an external client. + /// Useful for example if you plan on creating many clients but you want to mutualize the + /// underlying thread pools & co. + pub fn new_with_client( + config: K2vClientConfig, + client: HttpClient, Body>, + ) -> Result { let user_agent: std::borrow::Cow = match &config.user_agent { Some(ua) => ua.into(), None => format!("k2v/{}", env!("CARGO_PKG_VERSION")).into(), From 9053782d71432b07ae8a3da5510ea5dfb343330c Mon Sep 17 00:00:00 2001 From: Joker9944 <9194199+Joker9944@users.noreply.github.com> Date: Sat, 15 Mar 2025 00:32:18 +0100 Subject: [PATCH 02/73] doc: add instructions on how to increase PVC size --- doc/book/cookbook/kubernetes.md | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/doc/book/cookbook/kubernetes.md b/doc/book/cookbook/kubernetes.md index dfeb3281..af04e94d 100644 --- a/doc/book/cookbook/kubernetes.md +++ b/doc/book/cookbook/kubernetes.md @@ -86,3 +86,62 @@ helm delete --namespace garage garage ``` Note that this will leave behind custom CRD `garagenodes.deuxfleurs.fr`, which must be removed manually if desired. + +## Increase PVC size on running Garage instances + +Since the Garage Helm chart creates the data and meta PVC based on `StatefulSet` templates, increasing the PVC size can be a bit tricky. + +### Confirm the `StorageClass` used for Garage supports volume expansion + +Confirm the storage class used for garage. + +```bash +kubectl -n garage get pvc +NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE +data-garage-0 Bound pvc-080360c9-8ce3-4acf-8579-1701e57b7f3f 30Gi RWO longhorn-local 77d +data-garage-1 Bound pvc-ab8ba697-6030-4fc7-ab3c-0d6df9e3dbc0 30Gi RWO longhorn-local 5d8h +data-garage-2 Bound pvc-3ab37551-0231-4604-986d-136d0fd950ec 30Gi RWO longhorn-local 5d5h +meta-garage-0 Bound pvc-3b457302-3023-4169-846e-c928c5f2ea65 3Gi RWO longhorn-local 77d +meta-garage-1 Bound pvc-49ace2b9-5c85-42df-9247-51c4cf64b460 3Gi RWO longhorn-local 5d8h +meta-garage-2 Bound pvc-99e2e50f-42b4-4128-ae2f-b52629259723 3Gi RWO longhorn-local 5d5h +``` + +In this case, the storage class is `longhorn-local`. Now, check if `ALLOWVOLUMEEXPANSION` is true for the used `StorageClass`. + +```bash +kubectl get storageclasses.storage.k8s.io longhorn-local +NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE +longhorn-local driver.longhorn.io Delete Immediate true 103d +``` + +If your `StorageClass` does not support volume expansion, double check if you can enable it. Otherwise, your only real option is to spin up a new Garage cluster with increased size and migrate all data over. + +If your `StorageClass` supports expansion, you are free to continue. + +### Increase the size of the PVCs + +Increase the size of all PVCs to your desired size. + +```bash +kubectl -n garage edit pvc data-garage-0 +kubectl -n garage edit pvc data-garage-1 +kubectl -n garage edit pvc data-garage-2 +kubectl -n garage edit pvc meta-garage-0 +kubectl -n garage edit pvc meta-garage-1 +kubectl -n garage edit pvc meta-garage-2 +``` + +### Increase the size of the `StatefulSet` PVC template + +This is an optional step, but if not done, future instances of Garage will be created with the original size from the template. + +```bash +kubectl -n garage delete sts --cascade=orphan garage +statefulset.apps "garage" deleted +``` + +This will remove the Garage `StatefulSet` but leave the pods running. It may seem destructive but needs to be done this way since edits to the size of PVC templates are prohibited. + +### Redeploy the `StatefulSet` + +Now the size of future PVCs can be increased, and the Garage Helm chart can be upgraded. The new `StatefulSet` should take ownership of the orphaned pods again. From dd20e5d22afd0b68cfc1b2b435fdf5c6486a0392 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 20 Mar 2025 13:36:01 +0100 Subject: [PATCH 03/73] update cargo dependencies --- Cargo.lock | 1068 ++++++++++++++++++++++++++++++++++------------------ Cargo.toml | 2 +- 2 files changed, 712 insertions(+), 358 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b56b72bb..c5a2a138 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 4 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aead" @@ -62,7 +62,7 @@ dependencies = [ "getrandom 0.2.15", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -97,15 +97,16 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] @@ -126,28 +127,29 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "once_cell", + "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "arc-swap" @@ -185,9 +187,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.18" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df895a515f70646414f4b45c0b79082783b80552b373a68283012928df56f522" +checksum = "c0cf008e5e1a9e9e22a7d3c9a4992e21a350290069e36d8fb72304ed17e8f2d2" dependencies = [ "futures-core", "memchr", @@ -216,20 +218,26 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] name = "async-trait" -version = "0.1.86" +version = "0.1.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.4.0" @@ -238,9 +246,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-credential-types" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e8f6b615cb5fc60a98132268508ad104310f0cfb25a1c22eee76efdf9154da" +checksum = "4471bef4c22a06d2c7a1b6492493d3fdf24a805323109d6874f9c94d5906ac14" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", @@ -249,10 +257,33 @@ dependencies = [ ] [[package]] -name = "aws-runtime" -version = "1.5.5" +name = "aws-lc-rs" +version = "1.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76dd04d39cc12844c0994f2c9c5a6f5184c22e9188ec1ff723de41910a21dcad" +checksum = "dabb68eb3a7aa08b46fddfd59a3d55c978243557a90ab804769f7e20e67d2b01" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77926887776171ced7d662120a75998e444d3750c951abfe07f90da130514b1f" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", +] + +[[package]] +name = "aws-runtime" +version = "1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aff45ffe35196e593ea3b9dd65b320e51e2dda95aff4390bc459e461d09c6ad" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -276,9 +307,9 @@ dependencies = [ [[package]] name = "aws-sdk-config" -version = "1.62.0" +version = "1.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f94d79b8eef608af51b5415d13f5c670dec177880c6f78cd27bea968e5c9b76" +checksum = "2645fb2c8b9876a46a3d79f06aad47063baf054085ea887a1e6d6f159e8a7501" dependencies = [ "aws-credential-types", "aws-runtime", @@ -298,9 +329,9 @@ dependencies = [ [[package]] name = "aws-sdk-s3" -version = "1.68.0" +version = "1.79.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5ddf1dc70287dc9a2f953766a1fe15e3e74aef02fd1335f2afa475c9b4f4fc" +checksum = "a8f63ba8f5fca32061c7d62d866ef65470edde38d4c5f8a0ebb8ff40a0521e1c" dependencies = [ "aws-credential-types", "aws-runtime", @@ -320,6 +351,7 @@ dependencies = [ "hex", "hmac", "http 0.2.12", + "http 1.3.1", "http-body 0.4.6", "lru", "once_cell", @@ -332,9 +364,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.9" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bfe75fad52793ce6dec0dc3d4b1f388f038b5eb866c8d4d7f3a8e21b5ea5051" +checksum = "69d03c3c05ff80d54ff860fe38c726f6f494c639ae975203a101335f223386db" dependencies = [ "aws-credential-types", "aws-smithy-eventstream", @@ -347,7 +379,7 @@ dependencies = [ "hex", "hmac", "http 0.2.12", - "http 1.2.0", + "http 1.3.1", "once_cell", "p256", "percent-encoding", @@ -361,9 +393,9 @@ dependencies = [ [[package]] name = "aws-smithy-async" -version = "1.2.4" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa59d1327d8b5053c54bf2eaae63bf629ba9e904434d0835a28ed3c0ed0a614e" +checksum = "1e190749ea56f8c42bf15dd76c65e14f8f765233e6df9b0506d9d934ebef867c" dependencies = [ "futures-util", "pin-project-lite", @@ -372,15 +404,16 @@ dependencies = [ [[package]] name = "aws-smithy-checksums" -version = "0.60.13" +version = "0.63.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1a71073fca26775c8b5189175ea8863afb1c9ea2cceb02a5de5ad9dfbaa795" +checksum = "b65d21e1ba6f2cdec92044f904356a19f5ad86961acf015741106cdfafd747c0" dependencies = [ "aws-smithy-http", "aws-smithy-types", "bytes", "crc32c", "crc32fast", + "crc64fast-nvme", "hex", "http 0.2.12", "http-body 0.4.6", @@ -393,9 +426,9 @@ dependencies = [ [[package]] name = "aws-smithy-eventstream" -version = "0.60.6" +version = "0.60.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b18559a41e0c909b77625adf2b8c50de480a8041e5e4a3f5f7d177db70abc5a" +checksum = "7c45d3dddac16c5c59d553ece225a88870cf81b7b813c9cc17b78cf4685eac7a" dependencies = [ "aws-smithy-types", "bytes", @@ -404,9 +437,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.60.12" +version = "0.62.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7809c27ad8da6a6a68c454e651d4962479e81472aa19ae99e59f9aba1f9713cc" +checksum = "c5949124d11e538ca21142d1fba61ab0a2a2c1bc3ed323cdb3e4b878bfb83166" dependencies = [ "aws-smithy-eventstream", "aws-smithy-runtime-api", @@ -415,6 +448,7 @@ dependencies = [ "bytes-utils", "futures-core", "http 0.2.12", + "http 1.3.1", "http-body 0.4.6", "once_cell", "percent-encoding", @@ -424,52 +458,77 @@ dependencies = [ ] [[package]] -name = "aws-smithy-json" -version = "0.61.2" +name = "aws-smithy-http-client" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "623a51127f24c30776c8b374295f2df78d92517386f77ba30773f15a30ce1422" +checksum = "0497ef5d53065b7cd6a35e9c1654bd1fefeae5c52900d91d1b188b0af0f29324" +dependencies = [ + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "h2 0.4.8", + "http 0.2.12", + "http 1.3.1", + "http-body 0.4.6", + "hyper 0.14.32", + "hyper 1.6.0", + "hyper-rustls 0.24.2", + "hyper-rustls 0.27.5", + "hyper-util", + "pin-project-lite", + "rustls 0.21.12", + "rustls 0.23.25", + "rustls-native-certs 0.8.1", + "rustls-pki-types", + "tokio", + "tower 0.5.2", + "tracing", +] + +[[package]] +name = "aws-smithy-json" +version = "0.61.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92144e45819cae7dc62af23eac5a038a58aa544432d2102609654376a900bd07" dependencies = [ "aws-smithy-types", ] [[package]] name = "aws-smithy-runtime" -version = "1.7.8" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d526a12d9ed61fadefda24abe2e682892ba288c2018bcb38b1b4c111d13f6d92" +checksum = "f6328865e36c6fd970094ead6b05efd047d3a80ec5fc3be5e743910da9f2ebf8" dependencies = [ "aws-smithy-async", "aws-smithy-http", + "aws-smithy-http-client", "aws-smithy-runtime-api", "aws-smithy-types", "bytes", "fastrand", - "h2 0.3.24", "http 0.2.12", + "http 1.3.1", "http-body 0.4.6", "http-body 1.0.1", - "httparse", - "hyper 0.14.32", - "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", "pin-utils", - "rustls 0.21.10", "tokio", "tracing", ] [[package]] name = "aws-smithy-runtime-api" -version = "1.7.3" +version = "1.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92165296a47a812b267b4f41032ff8069ab7ff783696d217f0994a0d7ab585cd" +checksum = "3da37cf5d57011cb1753456518ec76e31691f1f474b73934a284eb2a1c76510f" dependencies = [ "aws-smithy-async", "aws-smithy-types", "bytes", "http 0.2.12", - "http 1.2.0", + "http 1.3.1", "pin-project-lite", "tokio", "tracing", @@ -478,16 +537,16 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.13" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7b8a53819e42f10d0821f56da995e1470b199686a1809168db6ca485665f042" +checksum = "836155caafba616c0ff9b07944324785de2ab016141c3550bd1c07882f8cee8f" dependencies = [ "base64-simd", "bytes", "bytes-utils", "futures-core", "http 0.2.12", - "http 1.2.0", + "http 1.3.1", "http-body 0.4.6", "http-body 1.0.1", "http-body-util", @@ -499,7 +558,7 @@ dependencies = [ "serde", "time", "tokio", - "tokio-util 0.7.13", + "tokio-util 0.7.14", ] [[package]] @@ -513,9 +572,9 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.3.5" +version = "1.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbd0a668309ec1f66c0f6bda4840dd6d4796ae26d699ebc266d7cc95c6d040f" +checksum = "3873f8deed8927ce8d04487630dc9ff73193bab64742a61d050e57a68dec4125" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -538,17 +597,17 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -587,9 +646,9 @@ dependencies = [ [[package]] name = "base64ct" -version = "1.6.0" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +checksum = "89e25b6adfb930f02d1981565a6e5d9c547ac15a96606256d3b59040e5cd4ca3" [[package]] name = "bincode" @@ -600,6 +659,29 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.9.0", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.100", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -608,9 +690,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "blake2" @@ -632,15 +714,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "bytemuck" -version = "1.21.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" [[package]] name = "byteorder" @@ -650,9 +732,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "bytes-utils" @@ -666,21 +748,30 @@ dependencies = [ [[package]] name = "bytesize" -version = "1.3.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" +checksum = "2d2c12f985c78475a6b8d629afd0c360260ef34cfef52efccdcfd31972f81c2e" [[package]] name = "cc" -version = "1.2.11" +version = "1.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf" +checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" dependencies = [ "jobserver", "libc", "shlex", ] +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -701,9 +792,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "android-tzdata", "iana-time-zone", @@ -711,7 +802,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.0", + "windows-link", ] [[package]] @@ -724,6 +815,17 @@ dependencies = [ "inout", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "2.34.0" @@ -737,9 +839,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.27" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796" +checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" dependencies = [ "clap_builder", "clap_derive", @@ -747,9 +849,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.27" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" +checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" dependencies = [ "anstream", "anstyle", @@ -759,14 +861,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.24" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -775,6 +877,15 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" +[[package]] +name = "cmake" +version = "0.1.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +dependencies = [ + "cc", +] + [[package]] name = "colorchoice" version = "1.0.3" @@ -797,6 +908,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -812,6 +933,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32c" version = "0.6.8" @@ -830,6 +966,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crc64fast-nvme" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4955638f00a809894c947f85a024020a20815b65a5eea633798ea7924edab2b3" +dependencies = [ + "crc", +] + [[package]] name = "crossbeam-channel" version = "0.5.14" @@ -917,7 +1062,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -928,7 +1073,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -953,9 +1098,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.11" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", ] @@ -990,14 +1135,20 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] -name = "dyn-clone" -version = "1.0.17" +name = "dunce" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "dyn-clone" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" [[package]] name = "ecdsa" @@ -1013,9 +1164,9 @@ dependencies = [ [[package]] name = "either" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "elliptic-curve" @@ -1061,9 +1212,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "err-derive" @@ -1086,7 +1237,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1131,9 +1282,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "form_urlencoded" @@ -1148,6 +1299,12 @@ dependencies = [ name = "format_table" version = "0.1.1" +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.31" @@ -1204,7 +1361,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -1267,7 +1424,7 @@ dependencies = [ "git-version", "hex", "hmac", - "http 1.2.0", + "http 1.3.1", "http-body-util", "hyper 1.6.0", "hyper-util", @@ -1305,7 +1462,7 @@ dependencies = [ "garage_table", "garage_util", "hex", - "http 1.2.0", + "http 1.3.1", "hyper 1.6.0", "opentelemetry", "opentelemetry-prometheus", @@ -1334,7 +1491,7 @@ dependencies = [ "garage_util", "hex", "hmac", - "http 1.2.0", + "http 1.3.1", "http-body-util", "hyper 1.6.0", "hyper-util", @@ -1363,7 +1520,7 @@ dependencies = [ "garage_model", "garage_table", "garage_util", - "http 1.2.0", + "http 1.3.1", "http-body-util", "hyper 1.6.0", "opentelemetry", @@ -1397,7 +1554,7 @@ dependencies = [ "garage_table", "garage_util", "hex", - "http 1.2.0", + "http 1.3.1", "http-body-util", "http-range", "httpdate", @@ -1415,7 +1572,7 @@ dependencies = [ "sha2", "tokio", "tokio-stream", - "tokio-util 0.7.13", + "tokio-util 0.7.14", "tracing", "url", ] @@ -1440,7 +1597,7 @@ dependencies = [ "rand", "serde", "tokio", - "tokio-util 0.7.13", + "tokio-util 0.7.14", "tracing", "zstd", ] @@ -1475,7 +1632,7 @@ dependencies = [ "garage_table", "garage_util", "hex", - "http 1.2.0", + "http 1.3.1", "parse_duration", "rand", "serde", @@ -1507,7 +1664,7 @@ dependencies = [ "serde", "tokio", "tokio-stream", - "tokio-util 0.7.13", + "tokio-util 0.7.14", ] [[package]] @@ -1578,7 +1735,7 @@ dependencies = [ "garage_net", "hex", "hexdump", - "http 1.2.0", + "http 1.3.1", "hyper 1.6.0", "lazy_static", "mktemp", @@ -1605,7 +1762,7 @@ dependencies = [ "garage_model", "garage_table", "garage_util", - "http 1.2.0", + "http 1.3.1", "http-body-util", "hyper 1.6.0", "opentelemetry", @@ -1647,14 +1804,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if", "libc", - "wasi 0.13.3+wasi-0.2.2", - "windows-targets 0.52.0", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", ] [[package]] @@ -1669,9 +1826,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "git-version" @@ -1690,9 +1847,15 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + [[package]] name = "group" version = "0.12.1" @@ -1706,9 +1869,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -1716,29 +1879,29 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.7.1", + "indexmap 2.8.0", "slab", "tokio", - "tokio-util 0.7.13", + "tokio-util 0.7.14", "tracing", ] [[package]] name = "h2" -version = "0.4.2" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d030e59af851932b72ceebadf4a2b5986dba4c3b99dd2493f8273a0f151943" +checksum = "5017294ff4bb30944501348f6f8e42e6ad28f42c8bbef7a74029aff064a4e3c2" dependencies = [ + "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", - "http 1.2.0", - "indexmap 2.7.1", + "http 1.3.1", + "indexmap 2.8.0", "slab", "tokio", - "tokio-util 0.7.13", + "tokio-util 0.7.14", "tracing", ] @@ -1839,9 +2002,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hermit-abi" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" +checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" [[package]] name = "hex" @@ -1869,11 +2032,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1889,9 +2052,9 @@ dependencies = [ [[package]] name = "http" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" dependencies = [ "bytes", "fnv", @@ -1916,18 +2079,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.2.0", + "http 1.3.1", ] [[package]] name = "http-body-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", - "futures-util", - "http 1.2.0", + "futures-core", + "http 1.3.1", "http-body 1.0.1", "pin-project-lite", ] @@ -1946,9 +2109,9 @@ checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" [[package]] name = "httparse" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "httpdate" @@ -1958,9 +2121,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humantime" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" [[package]] name = "hyper" @@ -1972,7 +2135,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.24", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -1995,8 +2158,8 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.2", - "http 1.2.0", + "h2 0.4.8", + "http 1.3.1", "http-body 1.0.1", "httparse", "httpdate", @@ -2017,7 +2180,7 @@ dependencies = [ "http 0.2.12", "hyper 0.14.32", "log", - "rustls 0.21.10", + "rustls 0.21.12", "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.24.1", @@ -2030,11 +2193,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" dependencies = [ "futures-util", - "http 1.2.0", + "http 1.3.1", "hyper 1.6.0", "hyper-util", "log", - "rustls 0.22.2", + "rustls 0.22.4", "rustls-native-certs 0.7.3", "rustls-pki-types", "tokio", @@ -2042,6 +2205,24 @@ dependencies = [ "tower-service", ] +[[package]] +name = "hyper-rustls" +version = "0.27.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" +dependencies = [ + "futures-util", + "http 1.3.1", + "hyper 1.6.0", + "hyper-util", + "rustls 0.23.25", + "rustls-native-certs 0.8.1", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.2", + "tower-service", +] + [[package]] name = "hyper-timeout" version = "0.4.1" @@ -2063,7 +2244,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.2.0", + "http 1.3.1", "http-body 1.0.1", "hyper 1.6.0", "pin-project-lite", @@ -2211,7 +2392,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -2263,9 +2444,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" dependencies = [ "equivalent", "hashbrown 0.15.2", @@ -2273,9 +2454,9 @@ dependencies = [ [[package]] name = "inout" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ "generic-array", ] @@ -2306,15 +2487,21 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.15" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" +checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ - "hermit-abi 0.4.0", + "hermit-abi 0.5.0", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -2335,9 +2522,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jobserver" @@ -2389,10 +2576,10 @@ dependencies = [ "aws-sdk-config", "aws-sigv4", "base64 0.21.7", - "clap 4.5.27", + "clap 4.5.32", "format_table", "hex", - "http 1.2.0", + "http 1.3.1", "http-body-util", "hyper 1.6.0", "hyper-rustls 0.26.0", @@ -2455,7 +2642,7 @@ dependencies = [ "kube-core", "pem", "pin-project", - "rustls 0.21.10", + "rustls 0.21.12", "rustls-pemfile 1.0.4", "secrecy", "serde", @@ -2463,8 +2650,8 @@ dependencies = [ "serde_yaml", "thiserror 1.0.69", "tokio", - "tokio-util 0.7.13", - "tower", + "tokio-util 0.7.14", + "tower 0.4.13", "tower-http", "tracing", ] @@ -2497,7 +2684,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -2522,7 +2709,7 @@ dependencies = [ "smallvec", "thiserror 1.0.69", "tokio", - "tokio-util 0.7.13", + "tokio-util 0.7.14", "tracing", ] @@ -2557,10 +2744,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] -name = "libc" -version = "0.2.169" +name = "lazycell" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.171" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" + +[[package]] +name = "libloading" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +dependencies = [ + "cfg-if", + "windows-targets 0.52.6", +] [[package]] name = "libsodium-sys" @@ -2592,10 +2795,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] -name = "litemap" -version = "0.7.4" +name = "linux-raw-sys" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" +checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" + +[[package]] +name = "litemap" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" [[package]] name = "lmdb-rkv-sys" @@ -2620,9 +2829,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" [[package]] name = "lru" @@ -2672,11 +2881,11 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -2708,7 +2917,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-util", - "http 1.2.0", + "http 1.3.1", "httparse", "memchr", "mime", @@ -2728,7 +2937,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "cfg-if", "cfg_aliases 0.2.1", "libc", @@ -2854,18 +3063,18 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.20.2" +version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" [[package]] name = "opaque-debug" @@ -3026,9 +3235,9 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.8", + "redox_syscall 0.5.10", "smallvec", - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -3061,9 +3270,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pem" -version = "3.0.4" +version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" dependencies = [ "base64 0.22.1", "serde", @@ -3082,7 +3291,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 2.0.11", + "thiserror 2.0.12", "ucd-trie", ] @@ -3106,7 +3315,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -3127,27 +3336,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.7.1", + "indexmap 2.8.0", ] [[package]] name = "pin-project" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfe2e71e1471fe07709406bf725f710b02927c9c54b2b5b2ec0e8087d97c327d" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e859e6e5bd50440ab63c47e3ebabc90f26251f7c73c3d3e837b74a1cc3fa67" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -3174,9 +3383,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "pnet_base" @@ -3230,11 +3439,11 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "zerocopy", + "zerocopy 0.8.23", ] [[package]] @@ -3247,6 +3456,16 @@ dependencies = [ "log", ] +[[package]] +name = "prettyplease" +version = "0.2.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" +dependencies = [ + "proc-macro2", + "syn 2.0.100", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -3273,9 +3492,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -3366,13 +3585,19 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "r2d2" version = "0.8.10" @@ -3436,11 +3661,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -3504,7 +3729,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.3.24", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.32", @@ -3516,7 +3741,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.10", + "rustls 0.21.12", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -3546,15 +3771,14 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.8" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", "getrandom 0.2.15", "libc", - "spin", "untrusted", "windows-sys 0.52.0", ] @@ -3593,7 +3817,7 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -3607,6 +3831,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.4.1" @@ -3622,18 +3852,31 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "errno", "libc", - "linux-raw-sys", - "windows-sys 0.52.0", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96" +dependencies = [ + "bitflags 2.9.0", + "errno", + "libc", + "linux-raw-sys 0.9.3", + "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", @@ -3643,9 +3886,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.2" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", "ring", @@ -3655,6 +3898,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls" +version = "0.23.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "822ee9188ac4ec04a2f0531e55d035fb2de73f18b41a63c70c2712503b6fb13c" +dependencies = [ + "aws-lc-rs", + "once_cell", + "rustls-pki-types", + "rustls-webpki 0.103.0", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -3664,7 +3921,7 @@ dependencies = [ "openssl-probe", "rustls-pemfile 1.0.4", "schannel", - "security-framework", + "security-framework 2.11.1", ] [[package]] @@ -3677,7 +3934,19 @@ dependencies = [ "rustls-pemfile 2.2.0", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 2.11.1", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework 3.2.0", ] [[package]] @@ -3726,16 +3995,28 @@ dependencies = [ ] [[package]] -name = "rustversion" -version = "1.0.19" +name = "rustls-webpki" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" +checksum = "0aa4eeac2588ffff23e9d7a7e9b3f971c5fb5b7ebc9452745e0c232c64f83b2f" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "same-file" @@ -3748,11 +4029,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3766,9 +4047,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.21" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" dependencies = [ "dyn-clone", "schemars_derive", @@ -3778,14 +4059,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.21" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -3834,8 +4115,21 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.8.0", - "core-foundation", + "bitflags 2.9.0", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" +dependencies = [ + "bitflags 2.9.0", + "core-foundation 0.10.0", "core-foundation-sys", "libc", "security-framework-sys", @@ -3853,15 +4147,15 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] @@ -3878,22 +4172,22 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.15" +version = "0.11.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" +checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -3904,14 +4198,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -3946,7 +4240,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.7.1", + "indexmap 2.8.0", "itoa", "ryu", "serde", @@ -4020,9 +4314,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "socket2" @@ -4133,9 +4427,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.98" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -4177,7 +4471,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -4198,7 +4492,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys", ] @@ -4214,16 +4508,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.16.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" dependencies = [ - "cfg-if", "fastrand", - "getrandom 0.3.1", + "getrandom 0.3.2", "once_cell", - "rustix", - "windows-sys 0.52.0", + "rustix 1.0.3", + "windows-sys 0.59.0", ] [[package]] @@ -4255,11 +4548,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.11", + "thiserror-impl 2.0.12", ] [[package]] @@ -4270,18 +4563,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -4296,9 +4589,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.37" +version = "0.3.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +checksum = "9d9c75b47bdff86fa3334a3db91356b8d7d86a9b839dab7d0bdc5c3d3a077618" dependencies = [ "deranged", "num-conv", @@ -4310,15 +4603,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "time-macros" -version = "0.2.19" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +checksum = "29aa485584182073ed57fd5004aa09c371f021325014694e432313345865fd04" dependencies = [ "num-conv", "time-core", @@ -4342,9 +4635,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" +checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" dependencies = [ "tinyvec_macros", ] @@ -4357,9 +4650,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.43.0" +version = "1.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" dependencies = [ "backtrace", "bytes", @@ -4391,7 +4684,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -4400,7 +4693,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.10", + "rustls 0.21.12", "tokio", ] @@ -4410,11 +4703,21 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.22.2", + "rustls 0.22.4", "rustls-pki-types", "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +dependencies = [ + "rustls 0.23.25", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.17" @@ -4442,9 +4745,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" +checksum = "6b9590b93e6fcc1739458317cccd391ad3955e2bde8913edf6f95f9e65a8f034" dependencies = [ "bytes", "futures-core", @@ -4457,9 +4760,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "serde", "serde_spanned", @@ -4478,11 +4781,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.23" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ - "indexmap 2.7.1", + "indexmap 2.8.0", "serde", "serde_spanned", "toml_datetime", @@ -4501,7 +4804,7 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "h2 0.3.24", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.32", @@ -4513,7 +4816,7 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util 0.6.10", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -4546,12 +4849,22 @@ dependencies = [ "rand", "slab", "tokio", - "tokio-util 0.7.13", + "tokio-util 0.7.14", "tower-layer", "tower-service", "tracing", ] +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "tower-layer", + "tower-service", +] + [[package]] name = "tower-http" version = "0.4.4" @@ -4559,7 +4872,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ "base64 0.21.7", - "bitflags 2.8.0", + "bitflags 2.9.0", "bytes", "futures-core", "futures-util", @@ -4605,7 +4918,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] @@ -4665,9 +4978,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "ucd-trie" @@ -4683,9 +4996,9 @@ checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-normalization" @@ -4826,9 +5139,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi" -version = "0.13.3+wasi-0.2.2" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ "wit-bindgen-rt", ] @@ -4855,7 +5168,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", "wasm-bindgen-shared", ] @@ -4890,7 +5203,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4923,7 +5236,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix", + "rustix 0.38.44", ] [[package]] @@ -4948,7 +5261,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4963,9 +5276,15 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] +[[package]] +name = "windows-link" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" + [[package]] name = "windows-sys" version = "0.48.0" @@ -4981,7 +5300,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -5001,17 +5329,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -5022,9 +5351,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -5034,9 +5363,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -5046,9 +5375,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -5058,9 +5393,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -5070,9 +5405,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -5082,9 +5417,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -5094,15 +5429,15 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" +checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" dependencies = [ "memchr", ] @@ -5119,11 +5454,11 @@ dependencies = [ [[package]] name = "wit-bindgen-rt" -version = "0.33.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -5170,7 +5505,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", "synstructure 0.13.1", ] @@ -5180,8 +5515,16 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +dependencies = [ + "zerocopy-derive 0.8.23", ] [[package]] @@ -5192,27 +5535,38 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", ] [[package]] name = "zerofrom" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", "synstructure 0.13.1", ] @@ -5241,32 +5595,32 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn 2.0.100", ] [[package]] name = "zstd" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "7.2.1" +version = "7.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" +checksum = "f3051792fbdc2e1e143244dc28c60f73d8470e93f3f9cbd0ead44da5ed802722" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.13+zstd.1.5.6" +version = "2.0.14+zstd.1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +checksum = "8fb060d4926e4ac3a3ad15d864e99ceb5f343c6b34f5bd6d81ae6ed417311be5" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index 41f91228..2d84c838 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,7 +142,7 @@ assert-json-diff = "2.0" rustc_version = "0.4.0" static_init = "1.0" aws-sdk-config = "1.62" -aws-sdk-s3 = "=1.68" +aws-sdk-s3 = "1.79" [profile.dev] #lto = "thin" # disabled for now, adds 2-4 min to each CI build From a7d845a9994fcc9a317fe14ff9061a64a5647b70 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 20 Mar 2025 13:56:31 +0100 Subject: [PATCH 04/73] change aws-sdk features to avoid using aws-lc which doesn't compile on i686/arm --- Cargo.lock | 415 +----------------------------------------- Cargo.toml | 9 +- src/garage/Cargo.toml | 1 + 3 files changed, 13 insertions(+), 412 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c5a2a138..bd5a1f9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -256,29 +256,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "aws-lc-rs" -version = "1.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dabb68eb3a7aa08b46fddfd59a3d55c978243557a90ab804769f7e20e67d2b01" -dependencies = [ - "aws-lc-sys", - "zeroize", -] - -[[package]] -name = "aws-lc-sys" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77926887776171ced7d662120a75998e444d3750c951abfe07f90da130514b1f" -dependencies = [ - "bindgen", - "cc", - "cmake", - "dunce", - "fs_extra", -] - [[package]] name = "aws-runtime" version = "1.5.6" @@ -374,21 +351,16 @@ dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types", "bytes", - "crypto-bigint 0.5.5", "form_urlencoded", "hex", "hmac", "http 0.2.12", "http 1.3.1", "once_cell", - "p256", "percent-encoding", - "ring", "sha2", - "subtle", "time", "tracing", - "zeroize", ] [[package]] @@ -468,20 +440,12 @@ dependencies = [ "aws-smithy-types", "h2 0.4.8", "http 0.2.12", - "http 1.3.1", "http-body 0.4.6", "hyper 0.14.32", - "hyper 1.6.0", "hyper-rustls 0.24.2", - "hyper-rustls 0.27.5", - "hyper-util", "pin-project-lite", "rustls 0.21.12", - "rustls 0.23.25", - "rustls-native-certs 0.8.1", - "rustls-pki-types", "tokio", - "tower 0.5.2", "tracing", ] @@ -610,12 +574,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - [[package]] name = "base64" version = "0.13.1" @@ -659,29 +617,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bindgen" -version = "0.69.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" -dependencies = [ - "bitflags 2.9.0", - "cexpr", - "clang-sys", - "itertools 0.12.1", - "lazy_static", - "lazycell", - "log", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.100", - "which", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -763,15 +698,6 @@ dependencies = [ "shlex", ] -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - [[package]] name = "cfg-if" version = "1.0.0" @@ -815,17 +741,6 @@ dependencies = [ "inout", ] -[[package]] -name = "clang-sys" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "2.34.0" @@ -877,27 +792,12 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" -[[package]] -name = "cmake" -version = "0.1.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" -dependencies = [ - "cc", -] - [[package]] name = "colorchoice" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "core-foundation" version = "0.9.4" @@ -908,16 +808,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-foundation" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -999,28 +889,6 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "rand_core", - "subtle", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -1086,16 +954,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "zeroize", -] - [[package]] name = "deranged" version = "0.4.0" @@ -1138,56 +996,18 @@ dependencies = [ "syn 2.0.100", ] -[[package]] -name = "dunce" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" - [[package]] name = "dyn-clone" version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", -] - [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct", - "crypto-bigint 0.4.9", - "der", - "digest", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "zeroize", -] - [[package]] name = "encoding_rs" version = "0.8.35" @@ -1258,16 +1078,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core", - "subtle", -] - [[package]] name = "fixedbitset" version = "0.4.2" @@ -1299,12 +1109,6 @@ dependencies = [ name = "format_table" version = "0.1.1" -[[package]] -name = "fs_extra" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" - [[package]] name = "futures" version = "0.3.31" @@ -1401,6 +1205,7 @@ dependencies = [ "assert-json-diff", "async-trait", "aws-sdk-s3", + "aws-smithy-runtime", "backtrace", "base64 0.21.7", "bytes", @@ -1850,23 +1655,6 @@ dependencies = [ "syn 2.0.100", ] -[[package]] -name = "glob" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" - -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - [[package]] name = "h2" version = "0.3.26" @@ -2196,7 +1984,6 @@ dependencies = [ "http 1.3.1", "hyper 1.6.0", "hyper-util", - "log", "rustls 0.22.4", "rustls-native-certs 0.7.3", "rustls-pki-types", @@ -2205,24 +1992,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-rustls" -version = "0.27.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" -dependencies = [ - "futures-util", - "http 1.3.1", - "hyper 1.6.0", - "hyper-util", - "rustls 0.23.25", - "rustls-native-certs 0.8.1", - "rustls-pki-types", - "tokio", - "tokio-rustls 0.26.2", - "tower-service", -] - [[package]] name = "hyper-timeout" version = "0.4.1" @@ -2651,7 +2420,7 @@ dependencies = [ "thiserror 1.0.69", "tokio", "tokio-util 0.7.14", - "tower 0.4.13", + "tower", "tower-http", "tracing", ] @@ -2743,28 +2512,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" -[[package]] -name = "libloading" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" -dependencies = [ - "cfg-if", - "windows-targets 0.52.6", -] - [[package]] name = "libsodium-sys" version = "0.2.7" @@ -3171,17 +2924,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "p256" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" -dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2", -] - [[package]] name = "page_size" version = "0.4.2" @@ -3371,16 +3113,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der", - "spki", -] - [[package]] name = "pkg-config" version = "0.3.32" @@ -3456,16 +3188,6 @@ dependencies = [ "log", ] -[[package]] -name = "prettyplease" -version = "0.2.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" -dependencies = [ - "proc-macro2", - "syn 2.0.100", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -3758,17 +3480,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint 0.4.9", - "hmac", - "zeroize", -] - [[package]] name = "ring" version = "0.17.14" @@ -3831,12 +3542,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc_version" version = "0.4.1" @@ -3890,7 +3595,6 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ - "log", "ring", "rustls-pki-types", "rustls-webpki 0.102.8", @@ -3898,20 +3602,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls" -version = "0.23.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "822ee9188ac4ec04a2f0531e55d035fb2de73f18b41a63c70c2712503b6fb13c" -dependencies = [ - "aws-lc-rs", - "once_cell", - "rustls-pki-types", - "rustls-webpki 0.103.0", - "subtle", - "zeroize", -] - [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -3921,7 +3611,7 @@ dependencies = [ "openssl-probe", "rustls-pemfile 1.0.4", "schannel", - "security-framework 2.11.1", + "security-framework", ] [[package]] @@ -3934,19 +3624,7 @@ dependencies = [ "rustls-pemfile 2.2.0", "rustls-pki-types", "schannel", - "security-framework 2.11.1", -] - -[[package]] -name = "rustls-native-certs" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" -dependencies = [ - "openssl-probe", - "rustls-pki-types", - "schannel", - "security-framework 3.2.0", + "security-framework", ] [[package]] @@ -3994,18 +3672,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "rustls-webpki" -version = "0.103.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aa4eeac2588ffff23e9d7a7e9b3f971c5fb5b7ebc9452745e0c232c64f83b2f" -dependencies = [ - "aws-lc-rs", - "ring", - "rustls-pki-types", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.20" @@ -4085,20 +3751,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - [[package]] name = "secrecy" version = "0.8.0" @@ -4116,20 +3768,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.9.0", - "core-foundation 0.9.4", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" -dependencies = [ - "bitflags 2.9.0", - "core-foundation 0.10.0", + "core-foundation", "core-foundation-sys", "libc", "security-framework-sys", @@ -4293,16 +3932,6 @@ dependencies = [ "libc", ] -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest", - "rand_core", -] - [[package]] name = "slab" version = "0.4.9" @@ -4334,16 +3963,6 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -4492,7 +4111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", - "core-foundation 0.9.4", + "core-foundation", "system-configuration-sys", ] @@ -4708,16 +4327,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" -dependencies = [ - "rustls 0.23.25", - "tokio", -] - [[package]] name = "tokio-stream" version = "0.1.17" @@ -4816,7 +4425,7 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util 0.6.10", - "tower 0.4.13", + "tower", "tower-layer", "tower-service", "tracing", @@ -4855,16 +4464,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" -dependencies = [ - "tower-layer", - "tower-service", -] - [[package]] name = "tower-http" version = "0.4.4" diff --git a/Cargo.toml b/Cargo.toml index 2d84c838..732f6f05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,8 +132,8 @@ opentelemetry-contrib = "0.9" prometheus = "0.13" # used by the k2v-client crate only -aws-sigv4 = { version = "1.1" } -hyper-rustls = { version = "0.26", features = ["http2"] } +aws-sigv4 = { version = "1.1", default-features = false } +hyper-rustls = { version = "0.26", default-features = false, features = ["http1", "http2", "ring", "rustls-native-certs"] } log = "0.4" thiserror = "1.0" @@ -141,8 +141,9 @@ thiserror = "1.0" assert-json-diff = "2.0" rustc_version = "0.4.0" static_init = "1.0" -aws-sdk-config = "1.62" -aws-sdk-s3 = "1.79" +aws-smithy-runtime = { version = "1.8", default-features = false, features = ["tls-rustls"] } +aws-sdk-config = { version = "1.62", default-features = false } +aws-sdk-s3 = { version = "1.79", default-features = false, features = ["rt-tokio"] } [profile.dev] #lto = "thin" # disabled for now, adds 2-4 min to each CI build diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index 53a5a447..f03c7331 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -62,6 +62,7 @@ syslog-tracing = { workspace = true, optional = true } garage_api_common.workspace = true aws-sdk-s3.workspace = true +aws-smithy-runtime.workspace = true chrono.workspace = true http.workspace = true hmac.workspace = true From 9ec3f8cc3c09329761f711e35475b6272b6257ed Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Sat, 12 Apr 2025 23:18:50 +0200 Subject: [PATCH 05/73] metadata: Create compact LMDB snapshots See #1006 LMDB files never shrink, so we can end up with a large database that contains a smaller amount of actual data. Compacting the snapshots is an easy win: it will write faster to disk, take less space, and if needed you can reimport an already-compacted snapshot as the main database. --- src/db/lmdb_adapter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs index 40f1c867..259aa566 100644 --- a/src/db/lmdb_adapter.rs +++ b/src/db/lmdb_adapter.rs @@ -109,7 +109,7 @@ impl IDb for LmdbDb { let mut path = to.clone(); path.push("data.mdb"); self.db - .copy_to_path(path, heed::CompactionOption::Disabled)?; + .copy_to_path(path, heed::CompactionOption::Enabled)?; Ok(()) } From 02498a93d0d5fee5540420345f87a7c4e44635b9 Mon Sep 17 00:00:00 2001 From: Zoob Date: Sat, 19 Apr 2025 18:46:36 +0000 Subject: [PATCH 06/73] doc: fix Docker run volume mappings --- doc/book/quick-start/_index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/book/quick-start/_index.md b/doc/book/quick-start/_index.md index 41867b19..2db4211b 100644 --- a/doc/book/quick-start/_index.md +++ b/doc/book/quick-start/_index.md @@ -129,9 +129,9 @@ docker run \ -d \ --name garaged \ -p 3900:3900 -p 3901:3901 -p 3902:3902 -p 3903:3903 \ - -v /etc/garage.toml:/path/to/garage.toml \ - -v /var/lib/garage/meta:/path/to/garage/meta \ - -v /var/lib/garage/data:/path/to/garage/data \ + -v /path/to/garage.toml:/etc/garage.toml \ + -v /path/to/garage/meta:/var/lib/garage/meta \ + -v /path/to/garage/data:/var/lib/garage/data \ dxflrs/garage:v1.1.0 ``` From 9b38cba6f318192eefa8db871fc1367b197cfe6d Mon Sep 17 00:00:00 2001 From: babykart Date: Sat, 22 Mar 2025 20:44:45 +0100 Subject: [PATCH 07/73] helm-chart: Add livenessProbe & readinessProbe Signed-off-by: babykart --- script/helm/garage/README.md | 4 +++- script/helm/garage/templates/workload.yaml | 17 ++++++++--------- script/helm/garage/values.yaml | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/script/helm/garage/README.md b/script/helm/garage/README.md index c2eb086f..c9b54acd 100644 --- a/script/helm/garage/README.md +++ b/script/helm/garage/README.md @@ -1,6 +1,6 @@ # garage -![Version: 0.6.0](https://img.shields.io/badge/Version-0.6.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.0.1](https://img.shields.io/badge/AppVersion-v1.0.1-informational?style=flat-square) +![Version: 0.7.0](https://img.shields.io/badge/Version-0.7.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.1.0](https://img.shields.io/badge/AppVersion-v1.1.0-informational?style=flat-square) S3-compatible object store for small self-hosted geo-distributed deployments @@ -49,6 +49,7 @@ S3-compatible object store for small self-hosted geo-distributed deployments | initImage.pullPolicy | string | `"IfNotPresent"` | | | initImage.repository | string | `"busybox"` | | | initImage.tag | string | `"stable"` | | +| livenessProbe | object | `{}` | Specifies a livenessProbe | | monitoring.metrics.enabled | bool | `false` | If true, a service for monitoring is created with a prometheus.io/scrape annotation | | monitoring.metrics.serviceMonitor.enabled | bool | `false` | If true, a ServiceMonitor CRD is created for a prometheus operator https://github.com/coreos/prometheus-operator | | monitoring.metrics.serviceMonitor.interval | string | `"15s"` | | @@ -71,6 +72,7 @@ S3-compatible object store for small self-hosted geo-distributed deployments | podSecurityContext.runAsGroup | int | `1000` | | | podSecurityContext.runAsNonRoot | bool | `true` | | | podSecurityContext.runAsUser | int | `1000` | | +| readinessProbe | object | `{}` | Specifies a readinessProbe | | resources | object | `{}` | | | securityContext.capabilities | object | `{"drop":["ALL"]}` | The default security context is heavily restricted, feel free to tune it to your requirements | | securityContext.readOnlyRootFilesystem | bool | `true` | | diff --git a/script/helm/garage/templates/workload.yaml b/script/helm/garage/templates/workload.yaml index cb9e76a2..d144cb41 100644 --- a/script/helm/garage/templates/workload.yaml +++ b/script/helm/garage/templates/workload.yaml @@ -78,15 +78,14 @@ spec: {{- with .Values.extraVolumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} - # TODO - # livenessProbe: - # httpGet: - # path: / - # port: 3900 - # readinessProbe: - # httpGet: - # path: / - # port: 3900 + {{- with .Values.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} volumes: diff --git a/script/helm/garage/values.yaml b/script/helm/garage/values.yaml index 38715e38..0a6a45c5 100644 --- a/script/helm/garage/values.yaml +++ b/script/helm/garage/values.yaml @@ -191,6 +191,21 @@ resources: {} # cpu: 100m # memory: 512Mi +# -- Specifies a livenessProbe +livenessProbe: {} + #httpGet: + # path: /health + # port: 3903 + #initialDelaySeconds: 5 + #periodSeconds: 30 +# -- Specifies a readinessProbe +readinessProbe: {} + #httpGet: + # path: /health + # port: 3903 + #initialDelaySeconds: 5 + #periodSeconds: 30 + nodeSelector: {} tolerations: [] From e6e4e051a1a6b005e9baa4875e1a65b9d4b04dcb Mon Sep 17 00:00:00 2001 From: babykart Date: Sat, 22 Mar 2025 20:49:48 +0100 Subject: [PATCH 08/73] helm-chart: Add metadata_auto_snapshot_interval Signed-off-by: babykart --- script/helm/garage/README.md | 1 + script/helm/garage/templates/configmap.yaml | 4 ++++ script/helm/garage/values.yaml | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/script/helm/garage/README.md b/script/helm/garage/README.md index c9b54acd..1a187c84 100644 --- a/script/helm/garage/README.md +++ b/script/helm/garage/README.md @@ -23,6 +23,7 @@ S3-compatible object store for small self-hosted geo-distributed deployments | garage.existingConfigMap | string | `""` | if not empty string, allow using an existing ConfigMap for the garage.toml, if set, ignores garage.toml | | garage.garageTomlString | string | `""` | String Template for the garage configuration if set, ignores above values. Values can be templated, see https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/ | | garage.kubernetesSkipCrd | bool | `false` | Set to true if you want to use k8s discovery but install the CRDs manually outside of the helm chart, for example if you operate at namespace level without cluster ressources | +| garage.metadataAutoSnapshotInterval | string | `""` | If this value is set, Garage will automatically take a snapshot of the metadata DB file at a regular interval and save it in the metadata directory. https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#metadata_auto_snapshot_interval | | garage.replicationMode | string | `"3"` | Default to 3 replicas, see the replication_mode section at https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#replication-mode | | garage.rpcBindAddr | string | `"[::]:3901"` | | | garage.rpcSecret | string | `""` | If not given, a random secret will be generated and stored in a Secret object | diff --git a/script/helm/garage/templates/configmap.yaml b/script/helm/garage/templates/configmap.yaml index 81ca205e..ab5b84db 100644 --- a/script/helm/garage/templates/configmap.yaml +++ b/script/helm/garage/templates/configmap.yaml @@ -19,6 +19,10 @@ data: compression_level = {{ .Values.garage.compressionLevel }} + {{- if .Values.garage.metadataAutoSnapshotInterval }} + metadata_auto_snapshot_interval = {{ .Values.garage.metadataAutoSnapshotInterval | quote }} + {{- end }} + rpc_bind_addr = "{{ .Values.garage.rpcBindAddr }}" # rpc_secret will be populated by the init container from a k8s secret object rpc_secret = "__RPC_SECRET_REPLACE__" diff --git a/script/helm/garage/values.yaml b/script/helm/garage/values.yaml index 0a6a45c5..bbb60db2 100644 --- a/script/helm/garage/values.yaml +++ b/script/helm/garage/values.yaml @@ -21,6 +21,10 @@ garage: # https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#compression-level compressionLevel: "1" + # -- If this value is set, Garage will automatically take a snapshot of the metadata DB file at a regular interval and save it in the metadata directory. + # https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#metadata_auto_snapshot_interval + metadataAutoSnapshotInterval: "" + rpcBindAddr: "[::]:3901" # -- If not given, a random secret will be generated and stored in a Secret object rpcSecret: "" From 3c20984a08528f1a6672c8afc83d2306a0361e40 Mon Sep 17 00:00:00 2001 From: babykart Date: Sat, 22 Mar 2025 20:52:47 +0100 Subject: [PATCH 09/73] helm-chart: Cosmetic changes Signed-off-by: babykart --- script/helm/garage/Chart.yaml | 30 ++++++++++++------------------ script/helm/garage/README.md | 6 ++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/script/helm/garage/Chart.yaml b/script/helm/garage/Chart.yaml index 1a3e27e0..7a89409e 100644 --- a/script/helm/garage/Chart.yaml +++ b/script/helm/garage/Chart.yaml @@ -1,24 +1,18 @@ apiVersion: v2 name: garage description: S3-compatible object store for small self-hosted geo-distributed deployments - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) version: 0.7.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. appVersion: "v1.1.0" +home: https://garagehq.deuxfleurs.fr/ +icon: https://garagehq.deuxfleurs.fr/images/garage-logo.svg + +keywords: +- geo-distributed +- read-after-write-consistency +- s3-compatible + +sources: +- https://git.deuxfleurs.fr/Deuxfleurs/garage.git + +maintainers: [] \ No newline at end of file diff --git a/script/helm/garage/README.md b/script/helm/garage/README.md index 1a187c84..fcf988ca 100644 --- a/script/helm/garage/README.md +++ b/script/helm/garage/README.md @@ -4,6 +4,12 @@ S3-compatible object store for small self-hosted geo-distributed deployments +**Homepage:** + +## Source Code + +* + ## Values | Key | Type | Default | Description | From ad151cb1dc2c657db4c969a306349bc077ed648a Mon Sep 17 00:00:00 2001 From: "Maximilien R." Date: Wed, 23 Apr 2025 23:30:16 +0200 Subject: [PATCH 10/73] Fix #1007: hint that region can be changed depending on cluster config --- doc/book/connect/apps/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/book/connect/apps/index.md b/doc/book/connect/apps/index.md index 14868373..5ec9686c 100644 --- a/doc/book/connect/apps/index.md +++ b/doc/book/connect/apps/index.md @@ -69,7 +69,7 @@ $CONFIG = array( 'hostname' => '127.0.0.1', // Can also be a domain name, eg. garage.example.com 'port' => 3900, // Put your reverse proxy port or your S3 API port 'use_ssl' => false, // Set it to true if you have a TLS enabled reverse proxy - 'region' => 'garage', // Garage has only one region named "garage" + 'region' => 'garage', // Garage default region is named "garage", edit according to your cluster config 'use_path_style' => true // Garage supports only path style, must be set to true ], ], @@ -135,7 +135,7 @@ bucket but doesn't also know the secret encryption key. *Click on the picture to zoom* Add a new external storage. Put what you want in "folder name" (eg. "shared"). Select "Amazon S3". Keep "Access Key" for the Authentication field. -In Configuration, put your bucket name (eg. nextcloud), the host (eg. 127.0.0.1), the port (eg. 3900 or 443), the region (garage). Tick the SSL box if you have put an HTTPS proxy in front of garage. You must tick the "Path access" box and you must leave the "Legacy authentication (v2)" box empty. Put your Key ID (eg. GK...) and your Secret Key in the last two input boxes. Finally click on the tick symbol on the right of your screen. +In Configuration, put your bucket name (eg. nextcloud), the host (eg. 127.0.0.1), the port (eg. 3900 or 443), the region ("garage" if you use the default, or the one your configured in your `garage.toml`). Tick the SSL box if you have put an HTTPS proxy in front of garage. You must tick the "Path access" box and you must leave the "Legacy authentication (v2)" box empty. Put your Key ID (eg. GK...) and your Secret Key in the last two input boxes. Finally click on the tick symbol on the right of your screen. Now go to your "Files" app and a new "linked folder" has appeared with the name you chose earlier (eg. "shared"). @@ -238,7 +238,7 @@ object_storage: # Put localhost only if you have a garage instance running on that node endpoint: 'http://localhost:3900' # or "garage.example.com" if you have TLS on port 443 - # Garage supports only one region for now, named garage + # Garage default region is named "garage", edit according to your config region: 'garage' credentials: @@ -441,7 +441,7 @@ media_storage_providers: store_synchronous: True # do we want to wait that the file has been written before returning? config: bucket: matrix # the name of our bucket, we chose matrix earlier - region_name: garage # only "garage" is supported for the region field + region_name: garage # "garage" by default, edit according to your cluster config endpoint_url: http://localhost:3900 # the path to the S3 endpoint access_key_id: "GKxxx" # your Key ID secret_access_key: "xxxx" # your Secret Key From 14274bc13c2bc39ad54c3a36f5c6473897762009 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Thu, 8 May 2025 10:27:53 +0200 Subject: [PATCH 11/73] doc: Add systemd example to increase file descriptors limit --- doc/book/cookbook/systemd.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/book/cookbook/systemd.md b/doc/book/cookbook/systemd.md index c0ed7d1f..ebff8c15 100644 --- a/doc/book/cookbook/systemd.md +++ b/doc/book/cookbook/systemd.md @@ -28,6 +28,7 @@ StateDirectory=garage DynamicUser=true ProtectHome=true NoNewPrivileges=true +LimitNOFILE=42000 [Install] WantedBy=multi-user.target From 539af12d21567a39a074d3a73c893d98275c70d4 Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Mon, 19 May 2025 18:07:04 +0200 Subject: [PATCH 12/73] allow punnycode in bucket name --- src/api/admin/bucket.rs | 4 ++-- src/api/s3/bucket.rs | 2 +- src/garage/admin/bucket.rs | 2 +- src/model/bucket_alias_table.rs | 18 ++++++++---------- src/model/helper/locked.rs | 7 +++---- src/util/config.rs | 4 ++++ 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/api/admin/bucket.rs b/src/api/admin/bucket.rs index 2537bfc9..6cc21938 100644 --- a/src/api/admin/bucket.rs +++ b/src/api/admin/bucket.rs @@ -277,7 +277,7 @@ pub async fn handle_create_bucket( let helper = garage.locked_helper().await; if let Some(ga) = &req.global_alias { - if !is_valid_bucket_name(ga) { + if !is_valid_bucket_name(ga, garage.config.allow_punnycode) { return Err(Error::bad_request(format!( "{}: {}", ga, INVALID_BUCKET_NAME_MESSAGE @@ -292,7 +292,7 @@ pub async fn handle_create_bucket( } if let Some(la) = &req.local_alias { - if !is_valid_bucket_name(&la.alias) { + if !is_valid_bucket_name(&la.alias, garage.config.allow_punnycode) { return Err(Error::bad_request(format!( "{}: {}", la.alias, INVALID_BUCKET_NAME_MESSAGE diff --git a/src/api/s3/bucket.rs b/src/api/s3/bucket.rs index 3a09e769..d2a36c18 100644 --- a/src/api/s3/bucket.rs +++ b/src/api/s3/bucket.rs @@ -172,7 +172,7 @@ pub async fn handle_create_bucket( } // Create the bucket! - if !is_valid_bucket_name(&bucket_name) { + if !is_valid_bucket_name(&bucket_name, garage.config.allow_punnycode) { return Err(Error::bad_request(format!( "{}: {}", bucket_name, INVALID_BUCKET_NAME_MESSAGE diff --git a/src/garage/admin/bucket.rs b/src/garage/admin/bucket.rs index 1bdc6086..1ed0ebd8 100644 --- a/src/garage/admin/bucket.rs +++ b/src/garage/admin/bucket.rs @@ -126,7 +126,7 @@ impl AdminRpcHandler { #[allow(clippy::ptr_arg)] async fn handle_create_bucket(&self, name: &String) -> Result { - if !is_valid_bucket_name(name) { + if !is_valid_bucket_name(name, self.garage.config.allow_punnycode) { return Err(Error::BadRequest(format!( "{}: {}", name, INVALID_BUCKET_NAME_MESSAGE diff --git a/src/model/bucket_alias_table.rs b/src/model/bucket_alias_table.rs index 8bbe4118..04d808e8 100644 --- a/src/model/bucket_alias_table.rs +++ b/src/model/bucket_alias_table.rs @@ -22,14 +22,10 @@ mod v08 { pub use v08::*; impl BucketAlias { - pub fn new(name: String, ts: u64, bucket_id: Option) -> Option { - if !is_valid_bucket_name(&name) { - None - } else { - Some(BucketAlias { - name, - state: crdt::Lww::raw(ts, bucket_id), - }) + pub fn new(name: String, ts: u64, bucket_id: Option) -> Self { + BucketAlias { + name, + state: crdt::Lww::raw(ts, bucket_id), } } @@ -80,7 +76,7 @@ impl TableSchema for BucketAliasTable { /// In the case of Garage, bucket names must not be hex-encoded /// 32 byte string, which is excluded thanks to the /// maximum length of 63 bytes given in the spec. -pub fn is_valid_bucket_name(n: &str) -> bool { +pub fn is_valid_bucket_name(n: &str, punny: bool) -> bool { // Bucket names must be between 3 and 63 characters n.len() >= 3 && n.len() <= 63 // Bucket names must be composed of lowercase letters, numbers, @@ -92,7 +88,9 @@ pub fn is_valid_bucket_name(n: &str) -> bool { // Bucket names must not be formatted as an IP address && n.parse::().is_err() // Bucket names must not start with "xn--" - && !n.starts_with("xn--") + && (!n.starts_with("xn--") || punny) + // We are a bit stricter, to properly restrict punnycode in all labels + && (!n.contains(".xn--") || punny) // Bucket names must not end with "-s3alias" && !n.ends_with("-s3alias") } diff --git a/src/model/helper/locked.rs b/src/model/helper/locked.rs index 482e91b0..16b0bafc 100644 --- a/src/model/helper/locked.rs +++ b/src/model/helper/locked.rs @@ -57,7 +57,7 @@ impl<'a> LockedHelper<'a> { bucket_id: Uuid, alias_name: &String, ) -> Result<(), Error> { - if !is_valid_bucket_name(alias_name) { + if !is_valid_bucket_name(alias_name, self.0.config.allow_punnycode) { return Err(Error::InvalidBucketName(alias_name.to_string())); } @@ -88,8 +88,7 @@ impl<'a> LockedHelper<'a> { // writes are now done and all writes use timestamp alias_ts let alias = match alias { - None => BucketAlias::new(alias_name.clone(), alias_ts, Some(bucket_id)) - .ok_or_else(|| Error::InvalidBucketName(alias_name.clone()))?, + None => BucketAlias::new(alias_name.clone(), alias_ts, Some(bucket_id)), Some(mut a) => { a.state = Lww::raw(alias_ts, Some(bucket_id)); a @@ -218,7 +217,7 @@ impl<'a> LockedHelper<'a> { ) -> Result<(), Error> { let key_helper = KeyHelper(self.0); - if !is_valid_bucket_name(alias_name) { + if !is_valid_bucket_name(alias_name, self.0.config.allow_punnycode) { return Err(Error::InvalidBucketName(alias_name.to_string())); } diff --git a/src/util/config.rs b/src/util/config.rs index 73fc4ff4..f128177b 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -135,6 +135,10 @@ pub struct Config { /// Configuration for the admin API endpoint #[serde(default = "Default::default")] pub admin: AdminConfig, + + /// Allow punnycode in bucket names + #[serde(default)] + pub allow_punnycode: bool, } /// Value for data_dir: either a single directory or a list of dirs with attributes From a605a8080659b73939f6b3ff60bc0847ed0fb3c5 Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Mon, 19 May 2025 18:11:55 +0200 Subject: [PATCH 13/73] support punnycode in api/web endpoint --- Cargo.lock | 43 +-------------------------------------- Cargo.toml | 1 - src/api/common/Cargo.toml | 1 - src/api/common/helpers.rs | 3 +-- 4 files changed, 2 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd5a1f9f..e65778cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1300,7 +1300,6 @@ dependencies = [ "http-body-util", "hyper 1.6.0", "hyper-util", - "idna 0.5.0", "md-5", "nom", "opentelemetry", @@ -2170,16 +2169,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "1.0.3" @@ -4252,21 +4241,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "tinyvec" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "tokio" version = "1.44.1" @@ -4587,27 +4561,12 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" -[[package]] -name = "unicode-bidi" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" - [[package]] name = "unicode-ident" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" -[[package]] -name = "unicode-normalization" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-segmentation" version = "1.12.0" @@ -4655,7 +4614,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", - "idna 1.0.3", + "idna", "percent-encoding", ] diff --git a/Cargo.toml b/Cargo.toml index 732f6f05..400c1840 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,6 @@ git-version = "0.3.4" hex = "0.4" hexdump = "0.1" hmac = "0.12" -idna = "0.5" itertools = "0.12" ipnet = "2.9.0" lazy_static = "1.4" diff --git a/src/api/common/Cargo.toml b/src/api/common/Cargo.toml index 6d906423..b1a8b47a 100644 --- a/src/api/common/Cargo.toml +++ b/src/api/common/Cargo.toml @@ -28,7 +28,6 @@ err-derive.workspace = true hex.workspace = true hmac.workspace = true md-5.workspace = true -idna.workspace = true tracing.workspace = true nom.workspace = true pin-project.workspace = true diff --git a/src/api/common/helpers.rs b/src/api/common/helpers.rs index c8586de4..6fc4aa13 100644 --- a/src/api/common/helpers.rs +++ b/src/api/common/helpers.rs @@ -8,7 +8,6 @@ use hyper::{ body::{Body, Bytes}, Request, Response, }; -use idna::domain_to_unicode; use serde::{Deserialize, Serialize}; use garage_model::bucket_table::BucketParams; @@ -97,7 +96,7 @@ pub fn authority_to_host(authority: &str) -> Result { authority ))), }; - authority.map(|h| domain_to_unicode(h).0) + authority.map(|h| h.to_ascii_lowercase()) } /// Extract the bucket name and the key name from an HTTP path and possibly a bucket provided in From bba9202f310b257ed52d1a82052f05532495c62e Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Mon, 19 May 2025 20:36:03 +0200 Subject: [PATCH 14/73] add test for punycode --- src/api/admin/bucket.rs | 4 +- src/api/s3/bucket.rs | 2 +- src/garage/admin/bucket.rs | 2 +- src/garage/tests/common/garage.rs | 2 + src/garage/tests/s3/website.rs | 73 +++++++++++++++++++++++++++++++ src/model/bucket_alias_table.rs | 8 ++-- src/model/helper/locked.rs | 4 +- src/util/config.rs | 4 +- 8 files changed, 87 insertions(+), 12 deletions(-) diff --git a/src/api/admin/bucket.rs b/src/api/admin/bucket.rs index 6cc21938..f8bd1eb5 100644 --- a/src/api/admin/bucket.rs +++ b/src/api/admin/bucket.rs @@ -277,7 +277,7 @@ pub async fn handle_create_bucket( let helper = garage.locked_helper().await; if let Some(ga) = &req.global_alias { - if !is_valid_bucket_name(ga, garage.config.allow_punnycode) { + if !is_valid_bucket_name(ga, garage.config.allow_punycode) { return Err(Error::bad_request(format!( "{}: {}", ga, INVALID_BUCKET_NAME_MESSAGE @@ -292,7 +292,7 @@ pub async fn handle_create_bucket( } if let Some(la) = &req.local_alias { - if !is_valid_bucket_name(&la.alias, garage.config.allow_punnycode) { + if !is_valid_bucket_name(&la.alias, garage.config.allow_punycode) { return Err(Error::bad_request(format!( "{}: {}", la.alias, INVALID_BUCKET_NAME_MESSAGE diff --git a/src/api/s3/bucket.rs b/src/api/s3/bucket.rs index d2a36c18..23cceb84 100644 --- a/src/api/s3/bucket.rs +++ b/src/api/s3/bucket.rs @@ -172,7 +172,7 @@ pub async fn handle_create_bucket( } // Create the bucket! - if !is_valid_bucket_name(&bucket_name, garage.config.allow_punnycode) { + if !is_valid_bucket_name(&bucket_name, garage.config.allow_punycode) { return Err(Error::bad_request(format!( "{}: {}", bucket_name, INVALID_BUCKET_NAME_MESSAGE diff --git a/src/garage/admin/bucket.rs b/src/garage/admin/bucket.rs index 1ed0ebd8..073329c1 100644 --- a/src/garage/admin/bucket.rs +++ b/src/garage/admin/bucket.rs @@ -126,7 +126,7 @@ impl AdminRpcHandler { #[allow(clippy::ptr_arg)] async fn handle_create_bucket(&self, name: &String) -> Result { - if !is_valid_bucket_name(name, self.garage.config.allow_punnycode) { + if !is_valid_bucket_name(name, self.garage.config.allow_punycode) { return Err(Error::BadRequest(format!( "{}: {}", name, INVALID_BUCKET_NAME_MESSAGE diff --git a/src/garage/tests/common/garage.rs b/src/garage/tests/common/garage.rs index 8d71504f..2b0a381c 100644 --- a/src/garage/tests/common/garage.rs +++ b/src/garage/tests/common/garage.rs @@ -63,6 +63,8 @@ rpc_bind_addr = "127.0.0.1:{rpc_port}" rpc_public_addr = "127.0.0.1:{rpc_port}" rpc_secret = "{secret}" +allow_punycode = true + [s3_api] s3_region = "{region}" api_bind_addr = "127.0.0.1:{s3_port}" diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs index 9a9e29f2..6d37eee8 100644 --- a/src/garage/tests/s3/website.rs +++ b/src/garage/tests/s3/website.rs @@ -533,3 +533,76 @@ async fn test_website_check_domain() { }) ); } + +#[tokio::test] +async fn test_website_puny() { + const BCKT_NAME: &str = "xn--pda.eu"; + let ctx = common::context(); + let bucket = ctx.create_bucket(BCKT_NAME); + + let data = ByteStream::from_static(BODY); + + ctx.client + .put_object() + .bucket(&bucket) + .key("index.html") + .body(data) + .send() + .await + .unwrap(); + + let client = Client::builder(TokioExecutor::new()).build_http(); + + let req = |suffix| { + Request::builder() + .method("GET") + .uri(format!("http://127.0.0.1:{}/", ctx.garage.web_port)) + .header("Host", format!("{}{}", BCKT_NAME, suffix)) + .body(Body::new(Bytes::new())) + .unwrap() + }; + + ctx.garage + .command() + .args(["bucket", "website", "--allow", BCKT_NAME]) + .quiet() + .expect_success_status("Could not allow website on bucket"); + + let mut resp = client.request(req("")).await.unwrap(); + assert_eq!(resp.status(), StatusCode::OK); + assert_eq!( + resp.into_body().collect().await.unwrap().to_bytes(), + BODY.as_ref() + ); + + resp = client.request(req(".web.garage")).await.unwrap(); + assert_eq!(resp.status(), StatusCode::OK); + assert_eq!( + resp.into_body().collect().await.unwrap().to_bytes(), + BODY.as_ref() + ); + + for bname in [ + BCKT_NAME.to_string(), + format!("{BCKT_NAME}.web.garage"), + format!("{BCKT_NAME}.s3.garage"), + ] { + let admin_req = || { + Request::builder() + .method("GET") + .uri(format!( + "http://127.0.0.1:{0}/check?domain={1}", + ctx.garage.admin_port, bname + )) + .body(Body::new(Bytes::new())) + .unwrap() + }; + + let admin_resp = client.request(admin_req()).await.unwrap(); + assert_eq!(admin_resp.status(), StatusCode::OK); + assert_eq!( + admin_resp.into_body().collect().await.unwrap().to_bytes(), + format!("Domain '{bname}' is managed by Garage").as_bytes() + ); + } +} diff --git a/src/model/bucket_alias_table.rs b/src/model/bucket_alias_table.rs index 04d808e8..276d0d1c 100644 --- a/src/model/bucket_alias_table.rs +++ b/src/model/bucket_alias_table.rs @@ -76,7 +76,7 @@ impl TableSchema for BucketAliasTable { /// In the case of Garage, bucket names must not be hex-encoded /// 32 byte string, which is excluded thanks to the /// maximum length of 63 bytes given in the spec. -pub fn is_valid_bucket_name(n: &str, punny: bool) -> bool { +pub fn is_valid_bucket_name(n: &str, puny: bool) -> bool { // Bucket names must be between 3 and 63 characters n.len() >= 3 && n.len() <= 63 // Bucket names must be composed of lowercase letters, numbers, @@ -88,9 +88,9 @@ pub fn is_valid_bucket_name(n: &str, punny: bool) -> bool { // Bucket names must not be formatted as an IP address && n.parse::().is_err() // Bucket names must not start with "xn--" - && (!n.starts_with("xn--") || punny) - // We are a bit stricter, to properly restrict punnycode in all labels - && (!n.contains(".xn--") || punny) + && (!n.starts_with("xn--") || puny) + // We are a bit stricter, to properly restrict punycode in all labels + && (!n.contains(".xn--") || puny) // Bucket names must not end with "-s3alias" && !n.ends_with("-s3alias") } diff --git a/src/model/helper/locked.rs b/src/model/helper/locked.rs index 16b0bafc..a5821f77 100644 --- a/src/model/helper/locked.rs +++ b/src/model/helper/locked.rs @@ -57,7 +57,7 @@ impl<'a> LockedHelper<'a> { bucket_id: Uuid, alias_name: &String, ) -> Result<(), Error> { - if !is_valid_bucket_name(alias_name, self.0.config.allow_punnycode) { + if !is_valid_bucket_name(alias_name, self.0.config.allow_punycode) { return Err(Error::InvalidBucketName(alias_name.to_string())); } @@ -217,7 +217,7 @@ impl<'a> LockedHelper<'a> { ) -> Result<(), Error> { let key_helper = KeyHelper(self.0); - if !is_valid_bucket_name(alias_name, self.0.config.allow_punnycode) { + if !is_valid_bucket_name(alias_name, self.0.config.allow_punycode) { return Err(Error::InvalidBucketName(alias_name.to_string())); } diff --git a/src/util/config.rs b/src/util/config.rs index f128177b..c74029e7 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -136,9 +136,9 @@ pub struct Config { #[serde(default = "Default::default")] pub admin: AdminConfig, - /// Allow punnycode in bucket names + /// Allow punycode in bucket names #[serde(default)] - pub allow_punnycode: bool, + pub allow_punycode: bool, } /// Value for data_dir: either a single directory or a list of dirs with attributes From c6bc3f229b5cba9625b240cf60117ba5dc3fba50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arma=C3=ABl=20Gu=C3=A9neau?= Date: Thu, 15 May 2025 23:30:00 +0200 Subject: [PATCH 15/73] Fix behavior of CopyObject wrt x-amz-website-redirect-location --- src/api/s3/copy.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/api/s3/copy.rs b/src/api/s3/copy.rs index a5b2d706..edda7e0f 100644 --- a/src/api/s3/copy.rs +++ b/src/api/s3/copy.rs @@ -29,6 +29,7 @@ use crate::error::*; use crate::get::{full_object_byte_stream, PreconditionHeaders}; use crate::multipart; use crate::put::{extract_metadata_headers, save_stream, ChecksumMode, SaveStreamResult}; +use crate::website::X_AMZ_WEBSITE_REDIRECT_LOCATION; use crate::xml::{self as s3_xml, xmlns_tag}; pub const X_AMZ_COPY_SOURCE_IF_MATCH: HeaderName = @@ -84,7 +85,18 @@ pub async fn handle_copy( Some(v) if v == hyper::header::HeaderValue::from_static("REPLACE") => { extract_metadata_headers(req.headers())? } - _ => source_object_meta_inner.into_owned().headers, + _ => { + // The x-amz-website-redirect-location header is not copied, instead + // it is replaced by the value from the request (or removed if no + // value was specified) + let is_redirect = + |(key, _): &(String, String)| key == X_AMZ_WEBSITE_REDIRECT_LOCATION.as_str(); + let mut headers: Vec<_> = source_object_meta_inner.headers.clone(); + headers.retain(|h| !is_redirect(h)); + let new_headers = extract_metadata_headers(req.headers())?; + headers.extend(new_headers.into_iter().filter(is_redirect)); + headers + } }, checksum: source_checksum, }; From 2dc3a6dbbe88a3498a9fc39c50aeb94124c39781 Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Thu, 22 May 2025 14:08:06 +0200 Subject: [PATCH 16/73] document allow_punycode configuration option --- doc/book/reference-manual/configuration.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/book/reference-manual/configuration.md b/doc/book/reference-manual/configuration.md index e0fc17bc..09ce8d24 100644 --- a/doc/book/reference-manual/configuration.md +++ b/doc/book/reference-manual/configuration.md @@ -46,6 +46,7 @@ bootstrap_peers = [ "212fd62eeaca72c122b45a7f4fa0f55e012aa5e24ac384a72a3016413fa724ff@[fc00:F::1]:3901", ] +allow_punycode = false [consul_discovery] api = "catalog" @@ -115,6 +116,7 @@ Top-level configuration options: [`rpc_public_addr`](#rpc_public_addr), [`rpc_public_addr_subnet`](#rpc_public_addr_subnet) [`rpc_secret`/`rpc_secret_file`](#rpc_secret). +[`allow_punycode`](#allow_punycode). The `[consul_discovery]` section: [`api`](#consul_api), @@ -604,7 +606,7 @@ be obtained by running `garage node id` and then included directly in the key will be returned by `garage node id` and you will have to add the IP yourself. -### `allow_world_readable_secrets` or `GARAGE_ALLOW_WORLD_READABLE_SECRETS` (env) {#allow_world_readable_secrets} +#### `allow_world_readable_secrets` or `GARAGE_ALLOW_WORLD_READABLE_SECRETS` (env) {#allow_world_readable_secrets} Garage checks the permissions of your secret files to make sure they're not world-readable. In some cases, the check might fail and consider your files as @@ -616,6 +618,13 @@ permission verification. Alternatively, you can set the `GARAGE_ALLOW_WORLD_READABLE_SECRETS` environment variable to `true` to bypass the permissions check. +#### `allow_punycode` {#allow_punycode} + +Allow creating buckets with names containing punycode. When used for buckets served +as websites, this allows using almost any unicode character in the domain name. + +Default to `false`. + ### The `[consul_discovery]` section Garage supports discovering other nodes of the cluster using Consul. For this From ae3f7ee76cf3b45348ba97864313c8f6ddde6e7f Mon Sep 17 00:00:00 2001 From: Renjaya Raga Zenta Date: Tue, 20 May 2025 18:47:50 +0700 Subject: [PATCH 17/73] api: lifecycle: 404 if missing lifecycle config --- src/api/s3/lifecycle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/s3/lifecycle.rs b/src/api/s3/lifecycle.rs index c140494e..ccda6cfd 100644 --- a/src/api/s3/lifecycle.rs +++ b/src/api/s3/lifecycle.rs @@ -27,7 +27,7 @@ pub async fn handle_get_lifecycle(ctx: ReqCtx) -> Result, Erro .body(string_body(xml))?) } else { Ok(Response::builder() - .status(StatusCode::NO_CONTENT) + .status(StatusCode::NOT_FOUND) .body(empty_body())?) } } From 0fd1b7342ba5626c97f832726567ba73b72aec0b Mon Sep 17 00:00:00 2001 From: babykart Date: Sat, 22 Mar 2025 21:03:52 +0100 Subject: [PATCH 18/73] Add Kubernetes CRD and the related kustomization Signed-off-by: babykart --- script/k8s/crd/garagenodes.deuxfleurs.fr.yaml | 43 +++++++++++++++++++ script/k8s/crd/kustomization.yaml | 5 +++ 2 files changed, 48 insertions(+) create mode 100644 script/k8s/crd/garagenodes.deuxfleurs.fr.yaml create mode 100644 script/k8s/crd/kustomization.yaml diff --git a/script/k8s/crd/garagenodes.deuxfleurs.fr.yaml b/script/k8s/crd/garagenodes.deuxfleurs.fr.yaml new file mode 100644 index 00000000..cd0fb166 --- /dev/null +++ b/script/k8s/crd/garagenodes.deuxfleurs.fr.yaml @@ -0,0 +1,43 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: garagenodes.deuxfleurs.fr +spec: + conversion: + strategy: None + group: deuxfleurs.fr + names: + kind: GarageNode + listKind: GarageNodeList + plural: garagenodes + singular: garagenode + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + description: Auto-generated derived type for Node via `CustomResource` + properties: + spec: + properties: + address: + format: ip + type: string + hostname: + type: string + port: + format: uint16 + minimum: 0 + type: integer + required: + - address + - hostname + - port + type: object + required: + - spec + title: GarageNode + type: object + served: true + storage: true + subresources: {} \ No newline at end of file diff --git a/script/k8s/crd/kustomization.yaml b/script/k8s/crd/kustomization.yaml new file mode 100644 index 00000000..9f20eccf --- /dev/null +++ b/script/k8s/crd/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- garagenodes.deuxfleurs.fr.yaml \ No newline at end of file From b15e2cbb6ccc044b868cd8c56306c0b3a34610fa Mon Sep 17 00:00:00 2001 From: babykart Date: Sat, 22 Mar 2025 23:44:55 +0100 Subject: [PATCH 19/73] Update Kubernetes cookbook Signed-off-by: babykart --- doc/book/cookbook/kubernetes.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/book/cookbook/kubernetes.md b/doc/book/cookbook/kubernetes.md index af04e94d..1e7674d7 100644 --- a/doc/book/cookbook/kubernetes.md +++ b/doc/book/cookbook/kubernetes.md @@ -26,6 +26,13 @@ Or deploy with custom values: helm install --create-namespace --namespace garage garage ./garage -f values.override.yaml ``` +If you want to manage the CustomRessourceDefinition used by garage for its `kubernetes_discovery` outside of the helm chart, add `garage.kubernetesSkipCrd: true` to your custom values and use the kustomization before deploying the helm chart: + +```bash +kubectl apply -k ../k8s/crd +helm install --create-namespace --namespace garage garage ./garage -f values.override.yaml +``` + After deploying, cluster layout must be configured manually as described in [Creating a cluster layout](@/documentation/quick-start/_index.md#creating-a-cluster-layout). Use the following command to access garage CLI: ```bash From 2ade8c86f62f0e9eafc2b6515b48f1d45722fb5a Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 18 Mar 2025 11:35:55 +0100 Subject: [PATCH 20/73] more resilience to inconsistent alias states --- src/api/admin/bucket.rs | 2 +- src/api/s3/bucket.rs | 4 +- src/model/helper/locked.rs | 118 +++++++++++++++++++++++++------------ 3 files changed, 84 insertions(+), 40 deletions(-) diff --git a/src/api/admin/bucket.rs b/src/api/admin/bucket.rs index f8bd1eb5..207693b6 100644 --- a/src/api/admin/bucket.rs +++ b/src/api/admin/bucket.rs @@ -382,7 +382,7 @@ pub async fn handle_delete_bucket( for ((key_id, alias), _, active) in state.local_aliases.items().iter() { if *active { helper - .unset_local_bucket_alias(bucket.id, key_id, alias) + .purge_local_bucket_alias(bucket.id, key_id, alias) .await?; } } diff --git a/src/api/s3/bucket.rs b/src/api/s3/bucket.rs index 23cceb84..26e2fc49 100644 --- a/src/api/s3/bucket.rs +++ b/src/api/s3/bucket.rs @@ -241,11 +241,11 @@ pub async fn handle_delete_bucket(ctx: ReqCtx) -> Result, Erro // 1. delete bucket alias if is_local_alias { helper - .unset_local_bucket_alias(*bucket_id, &api_key.key_id, bucket_name) + .purge_local_bucket_alias(*bucket_id, &api_key.key_id, bucket_name) .await?; } else { helper - .unset_global_bucket_alias(*bucket_id, bucket_name) + .purge_global_bucket_alias(*bucket_id, bucket_name) .await?; } diff --git a/src/model/helper/locked.rs b/src/model/helper/locked.rs index a5821f77..ecb24854 100644 --- a/src/model/helper/locked.rs +++ b/src/model/helper/locked.rs @@ -47,6 +47,10 @@ impl<'a> LockedHelper<'a> { KeyHelper(self.0) } + // ================================================ + // global bucket aliases + // ================================================ + /// Sets a new alias for a bucket in global namespace. /// This function fails if: /// - alias name is not valid according to S3 spec @@ -179,13 +183,14 @@ impl<'a> LockedHelper<'a> { .ok_or_else(|| Error::NoSuchBucket(alias_name.to_string()))?; // Checks ok, remove alias - let alias_ts = match bucket.state.as_option() { - Some(bucket_state) => increment_logical_clock_2( - alias.state.timestamp(), - bucket_state.aliases.get_timestamp(alias_name), - ), - None => increment_logical_clock(alias.state.timestamp()), - }; + let alias_ts = increment_logical_clock_2( + alias.state.timestamp(), + bucket + .state + .as_option() + .map(|p| p.aliases.get_timestamp(alias_name)) + .unwrap_or(0), + ); // ---- timestamp-ensured causality barrier ---- // writes are now done and all writes use timestamp alias_ts @@ -203,6 +208,10 @@ impl<'a> LockedHelper<'a> { Ok(()) } + // ================================================ + // local bucket aliases + // ================================================ + /// Sets a new alias for a bucket in the local namespace of a key. /// This function fails if: /// - alias name is not valid according to S3 spec @@ -215,14 +224,12 @@ impl<'a> LockedHelper<'a> { key_id: &String, alias_name: &String, ) -> Result<(), Error> { - let key_helper = KeyHelper(self.0); - if !is_valid_bucket_name(alias_name, self.0.config.allow_punycode) { return Err(Error::InvalidBucketName(alias_name.to_string())); } let mut bucket = self.bucket().get_existing_bucket(bucket_id).await?; - let mut key = key_helper.get_existing_key(key_id).await?; + let mut key = self.key().get_existing_key(key_id).await?; let key_param = key.state.as_option_mut().unwrap(); @@ -271,23 +278,13 @@ impl<'a> LockedHelper<'a> { key_id: &String, alias_name: &String, ) -> Result<(), Error> { - let key_helper = KeyHelper(self.0); - let mut bucket = self.bucket().get_existing_bucket(bucket_id).await?; - let mut key = key_helper.get_existing_key(key_id).await?; + let mut key = self.key().get_existing_key(key_id).await?; + let key_p = key.state.as_option().unwrap(); let bucket_p = bucket.state.as_option_mut().unwrap(); - if key - .state - .as_option() - .unwrap() - .local_aliases - .get(alias_name) - .cloned() - .flatten() - != Some(bucket_id) - { + if key_p.local_aliases.get(alias_name).cloned().flatten() != Some(bucket_id) { return Err(GarageError::Message(format!( "Bucket {:?} does not have alias {} in namespace of key {}", bucket_id, alias_name, key_id @@ -304,17 +301,17 @@ impl<'a> LockedHelper<'a> { .local_aliases .items() .iter() - .any(|((k, n), _, active)| *k == key.key_id && n == alias_name && *active); + .any(|((k, n), _, active)| (*k != key.key_id || n != alias_name) && *active); + if !has_other_global_aliases && !has_other_local_aliases { return Err(Error::BadRequest(format!("Bucket {} doesn't have other aliases, please delete it instead of just unaliasing.", alias_name))); } // Checks ok, remove alias - let key_param = key.state.as_option_mut().unwrap(); let bucket_p_local_alias_key = (key.key_id.clone(), alias_name.clone()); let alias_ts = increment_logical_clock_2( - key_param.local_aliases.get_timestamp(alias_name), + key_p.local_aliases.get_timestamp(alias_name), bucket_p .local_aliases .get_timestamp(&bucket_p_local_alias_key), @@ -323,7 +320,8 @@ impl<'a> LockedHelper<'a> { // ---- timestamp-ensured causality barrier ---- // writes are now done and all writes use timestamp alias_ts - key_param.local_aliases = LwwMap::raw_item(alias_name.clone(), alias_ts, None); + key.state.as_option_mut().unwrap().local_aliases = + LwwMap::raw_item(alias_name.clone(), alias_ts, None); self.0.key_table.insert(&key).await?; bucket_p.local_aliases = LwwMap::raw_item(bucket_p_local_alias_key, alias_ts, false); @@ -332,21 +330,68 @@ impl<'a> LockedHelper<'a> { Ok(()) } + /// Ensures a bucket does not have a certain local alias. + /// Contrarily to unset_local_bucket_alias, this does not + /// fail on any condition other than: + /// - bucket cannot be found (its fine if it is in deleted state) + /// - key cannot be found (its fine if alias in key points to nothing + /// or to another bucket) + pub async fn purge_local_bucket_alias( + &self, + bucket_id: Uuid, + key_id: &String, + alias_name: &String, + ) -> Result<(), Error> { + let mut bucket = self.bucket().get_internal_bucket(bucket_id).await?; + let mut key = self.key().get_internal_key(key_id).await?; + + let bucket_p_local_alias_key = (key.key_id.clone(), alias_name.clone()); + + let alias_ts = increment_logical_clock_2( + key.state + .as_option() + .map(|p| p.local_aliases.get_timestamp(alias_name)) + .unwrap_or(0), + bucket + .state + .as_option() + .map(|p| p.local_aliases.get_timestamp(&bucket_p_local_alias_key)) + .unwrap_or(0), + ); + + // ---- timestamp-ensured causality barrier ---- + // writes are now done and all writes use timestamp alias_ts + + if let Some(kp) = key.state.as_option_mut() { + kp.local_aliases = LwwMap::raw_item(alias_name.clone(), alias_ts, None); + self.0.key_table.insert(&key).await?; + } + + if let Some(bp) = bucket.state.as_option_mut() { + bp.local_aliases = LwwMap::raw_item(bucket_p_local_alias_key, alias_ts, false); + self.0.bucket_table.insert(&bucket).await?; + } + + Ok(()) + } + + // ================================================ + // permissions + // ================================================ + /// Sets permissions for a key on a bucket. /// This function fails if: /// - bucket or key cannot be found at all (its ok if they are in deleted state) - /// - bucket or key is in deleted state and we are trying to set permissions other than "deny - /// all" + /// - bucket or key is in deleted state and we are trying to set + /// permissions other than "deny all" pub async fn set_bucket_key_permissions( &self, bucket_id: Uuid, key_id: &String, mut perm: BucketKeyPerm, ) -> Result<(), Error> { - let key_helper = KeyHelper(self.0); - let mut bucket = self.bucket().get_internal_bucket(bucket_id).await?; - let mut key = key_helper.get_internal_key(key_id).await?; + let mut key = self.key().get_internal_key(key_id).await?; if let Some(bstate) = bucket.state.as_option() { if let Some(kp) = bstate.authorized_keys.get(key_id) { @@ -383,21 +428,20 @@ impl<'a> LockedHelper<'a> { Ok(()) } - // ---- + // ================================================ + // keys + // ================================================ /// Deletes an API access key pub async fn delete_key(&self, key: &mut Key) -> Result<(), Error> { let state = key.state.as_option_mut().unwrap(); // --- done checking, now commit --- - // (the step at unset_local_bucket_alias will fail if a bucket - // does not have another alias, the deletion will be - // interrupted in the middle if that happens) // 1. Delete local aliases for (alias, _, to) in state.local_aliases.items().iter() { if let Some(bucket_id) = to { - self.unset_local_bucket_alias(*bucket_id, &key.key_id, alias) + self.purge_local_bucket_alias(*bucket_id, &key.key_id, alias) .await?; } } From 8654eb19bf8a59f8ece8ad70ac8096c799858876 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 19 Mar 2025 12:39:32 +0100 Subject: [PATCH 21/73] implement repair procedure to fix inconsistent bucket aliases --- src/garage/cli/structs.rs | 3 + src/garage/repair/online.rs | 4 + src/model/helper/locked.rs | 193 ++++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) diff --git a/src/garage/cli/structs.rs b/src/garage/cli/structs.rs index 4ec35e68..3652ef6b 100644 --- a/src/garage/cli/structs.rs +++ b/src/garage/cli/structs.rs @@ -478,6 +478,9 @@ pub enum RepairWhat { /// Recalculate block reference counters #[structopt(name = "block-rc", version = garage_version())] BlockRc, + /// Fix inconsistency in bucket aliases (WARNING: EXPERIMENTAL) + #[structopt(name = "aliases", version = garage_version())] + Aliases, /// Verify integrity of all blocks on disc #[structopt(name = "scrub", version = garage_version())] Scrub { diff --git a/src/garage/repair/online.rs b/src/garage/repair/online.rs index 47883f97..950cd5f7 100644 --- a/src/garage/repair/online.rs +++ b/src/garage/repair/online.rs @@ -88,6 +88,10 @@ pub async fn launch_online_repair( garage.block_manager.clone(), )); } + RepairWhat::Aliases => { + info!("Repairing bucket aliases (foreground)"); + garage.locked_helper().await.repair_aliases().await?; + } } Ok(()) } diff --git a/src/model/helper/locked.rs b/src/model/helper/locked.rs index ecb24854..98344b63 100644 --- a/src/model/helper/locked.rs +++ b/src/model/helper/locked.rs @@ -1,3 +1,7 @@ +use std::collections::{HashMap, HashSet}; + +use garage_db as db; + use garage_util::crdt::*; use garage_util::data::*; use garage_util::error::{Error as GarageError, OkOrMessage}; @@ -458,4 +462,193 @@ impl<'a> LockedHelper<'a> { Ok(()) } + + // ================================================ + // repair procedure + // ================================================ + + pub async fn repair_aliases(&self) -> Result<(), GarageError> { + self.0.db.transaction(|tx| { + info!("--- begin repair_aliases transaction ----"); + + // 1. List all non-deleted buckets, so that we can fix bad aliases + let mut all_buckets: HashSet = HashSet::new(); + + for item in tx.range::<&[u8], _>(&self.0.bucket_table.data.store, ..)? { + let bucket = self + .0 + .bucket_table + .data + .decode_entry(&(item?.1)) + .map_err(db::TxError::Abort)?; + if !bucket.is_deleted() { + all_buckets.insert(bucket.id); + } + } + + info!("number of buckets: {}", all_buckets.len()); + + // 2. List all aliases declared in bucket_alias_table and key_table + // Take note of aliases that point to non-existing buckets + let mut global_aliases: HashMap = HashMap::new(); + + { + let mut delete_global = vec![]; + for item in tx.range::<&[u8], _>(&self.0.bucket_alias_table.data.store, ..)? { + let mut alias = self + .0 + .bucket_alias_table + .data + .decode_entry(&(item?.1)) + .map_err(db::TxError::Abort)?; + if let Some(id) = alias.state.get() { + if all_buckets.contains(id) { + // keep aliases + global_aliases.insert(alias.name().to_string(), *id); + } else { + // delete alias + warn!( + "global alias: remove {} -> {:?} (bucket is deleted)", + alias.name(), + id + ); + alias.state.update(None); + delete_global.push(alias); + } + } + } + + info!("number of global aliases: {}", global_aliases.len()); + + info!("global alias table: {} entries fixed", delete_global.len()); + for ga in delete_global { + debug!("Enqueue update to global alias table: {:?}", ga); + self.0.bucket_alias_table.queue_insert(tx, &ga)?; + } + } + + let mut local_aliases: HashMap<(String, String), Uuid> = HashMap::new(); + + { + let mut delete_local = vec![]; + + for item in tx.range::<&[u8], _>(&self.0.key_table.data.store, ..)? { + let mut key = self + .0 + .key_table + .data + .decode_entry(&(item?.1)) + .map_err(db::TxError::Abort)?; + let Some(p) = key.state.as_option_mut() else { + continue; + }; + let mut has_changes = false; + for (name, _, to) in p.local_aliases.items().to_vec() { + if let Some(id) = to { + if all_buckets.contains(&id) { + local_aliases.insert((key.key_id.clone(), name), id); + } else { + warn!( + "local alias: remove ({}, {}) -> {:?} (bucket is deleted)", + key.key_id, name, id + ); + p.local_aliases.update_in_place(name, None); + has_changes = true; + } + } + } + if has_changes { + delete_local.push(key); + } + } + + info!("number of local aliases: {}", local_aliases.len()); + + info!("key table: {} entries fixed", delete_local.len()); + for la in delete_local { + debug!("Enqueue update to key table: {:?}", la); + self.0.key_table.queue_insert(tx, &la)?; + } + } + + // 4. Reverse the alias maps to determine the aliases per-bucket + let mut bucket_global: HashMap> = HashMap::new(); + let mut bucket_local: HashMap> = HashMap::new(); + + for (name, bucket) in global_aliases { + bucket_global.entry(bucket).or_default().push(name); + } + for ((key, name), bucket) in local_aliases { + bucket_local.entry(bucket).or_default().push((key, name)); + } + + // 5. Fix the bucket table to ensure consistency + let mut bucket_updates = vec![]; + + for item in tx.range::<&[u8], _>(&self.0.bucket_table.data.store, ..)? { + let bucket = self + .0 + .bucket_table + .data + .decode_entry(&(item?.1)) + .map_err(db::TxError::Abort)?; + let mut bucket2 = bucket.clone(); + let Some(param) = bucket2.state.as_option_mut() else { + continue; + }; + + // fix global aliases + { + let ga = bucket_global.remove(&bucket.id).unwrap_or_default(); + for (name, _, active) in param.aliases.items().to_vec() { + if active && !ga.contains(&name) { + warn!("bucket {:?}: remove global alias {}", bucket.id, name); + param.aliases.update_in_place(name, false); + } + } + for name in ga { + if param.aliases.get(&name).copied() != Some(true) { + warn!("bucket {:?}: add global alias {}", bucket.id, name); + param.aliases.update_in_place(name, true); + } + } + } + + // fix local aliases + { + let la = bucket_local.remove(&bucket.id).unwrap_or_default(); + for (pair, _, active) in param.local_aliases.items().to_vec() { + if active && !la.contains(&pair) { + warn!("bucket {:?}: remove local alias {:?}", bucket.id, pair); + param.local_aliases.update_in_place(pair, false); + } + } + for pair in la { + if param.local_aliases.get(&pair).copied() != Some(true) { + warn!("bucket {:?}: add local alias {:?}", bucket.id, pair); + param.local_aliases.update_in_place(pair, true); + } + } + } + + if bucket2 != bucket { + bucket_updates.push(bucket2); + } + } + + info!("bucket table: {} entries fixed", bucket_updates.len()); + for b in bucket_updates { + debug!("Enqueue update to bucket table: {:?}", b); + self.0.bucket_table.queue_insert(tx, &b)?; + } + + info!("--- end repair_aliases transaction ----"); + + Ok(()) + })?; + + info!("repair_aliases is done"); + + Ok(()) + } } From 6529ff379ac5737513fe92ba0060d94407ccb58d Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 23 May 2025 17:02:23 +0200 Subject: [PATCH 22/73] documentation updates --- doc/book/reference-manual/configuration.md | 14 +++++++------- doc/book/reference-manual/s3-compatibility.md | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/book/reference-manual/configuration.md b/doc/book/reference-manual/configuration.md index 09ce8d24..091419d9 100644 --- a/doc/book/reference-manual/configuration.md +++ b/doc/book/reference-manual/configuration.md @@ -93,30 +93,30 @@ The following gives details about each available configuration option. [Environment variables](#env_variables). -Top-level configuration options: +Top-level configuration options, in alphabetical order: +[`allow_punycode`](#allow_punycode), [`allow_world_readable_secrets`](#allow_world_readable_secrets), [`block_ram_buffer_max`](#block_ram_buffer_max), [`block_size`](#block_size), [`bootstrap_peers`](#bootstrap_peers), [`compression_level`](#compression_level), +[`consistency_mode`](#consistency_mode), [`data_dir`](#data_dir), [`data_fsync`](#data_fsync), [`db_engine`](#db_engine), [`disable_scrub`](#disable_scrub), -[`use_local_tz`](#use_local_tz), [`lmdb_map_size`](#lmdb_map_size), [`metadata_auto_snapshot_interval`](#metadata_auto_snapshot_interval), [`metadata_dir`](#metadata_dir), [`metadata_fsync`](#metadata_fsync), [`metadata_snapshots_dir`](#metadata_snapshots_dir), [`replication_factor`](#replication_factor), -[`consistency_mode`](#consistency_mode), [`rpc_bind_addr`](#rpc_bind_addr), [`rpc_bind_outgoing`](#rpc_bind_outgoing), [`rpc_public_addr`](#rpc_public_addr), [`rpc_public_addr_subnet`](#rpc_public_addr_subnet) -[`rpc_secret`/`rpc_secret_file`](#rpc_secret). -[`allow_punycode`](#allow_punycode). +[`rpc_secret`/`rpc_secret_file`](#rpc_secret), +[`use_local_tz`](#use_local_tz). The `[consul_discovery]` section: [`api`](#consul_api), @@ -171,7 +171,7 @@ values in the configuration file: ### Top-level configuration options -#### `replication_factor` {#replication_factor} +#### `replication_factor` (since `v1.0.0`) {#replication_factor} The replication factor can be any positive integer smaller or equal the node count in your cluster. The chosen replication factor has a big impact on the cluster's failure tolerancy and performance characteristics. @@ -219,7 +219,7 @@ is in progress. In theory, no data should be lost as rebalancing is a routine operation for Garage, although we cannot guarantee you that everything will go right in such an extreme scenario. -#### `consistency_mode` {#consistency_mode} +#### `consistency_mode` (since `v1.0.0`) {#consistency_mode} The consistency mode setting determines the read and write behaviour of your cluster. diff --git a/doc/book/reference-manual/s3-compatibility.md b/doc/book/reference-manual/s3-compatibility.md index d2c47f3e..edf8de0d 100644 --- a/doc/book/reference-manual/s3-compatibility.md +++ b/doc/book/reference-manual/s3-compatibility.md @@ -23,7 +23,6 @@ Feel free to open a PR to suggest fixes this table. Minio is missing because the - 2022-05-25 - Many Ceph S3 endpoints are not documented but implemented. Following a notification from the Ceph community, we added them. - ## High-level features | Feature | Garage | [Openstack Swift](https://docs.openstack.org/swift/latest/s3_compat.html) | [Ceph Object Gateway](https://docs.ceph.com/en/latest/radosgw/s3/) | [Riak CS](https://docs.riak.com/riak/cs/2.1.1/references/apis/storage/s3/index.html) | [OpenIO](https://docs.openio.io/latest/source/arch-design/s3_compliancy.html) | @@ -34,6 +33,7 @@ Feel free to open a PR to suggest fixes this table. Minio is missing because the | [URL vhost-style](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#virtual-hosted-style-access) URL (eg. `bucket.host.tld/key`) | ✅ Implemented | ❌| ✅| ✅ | ✅ | | [Presigned URLs](https://docs.aws.amazon.com/AmazonS3/latest/userguide/ShareObjectPreSignedURL.html) | ✅ Implemented | ❌| ✅ | ✅ | ✅(❓) | | [SSE-C encryption](https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerSideEncryptionCustomerKeys.html) | ✅ Implemented | ❓ | ✅ | ❌ | ✅ | +| [Bucket versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Versioning.html) | ❌ Missing | ✅ | ✅ | ❌ | ✅ | *Note:* OpenIO does not says if it supports presigned URLs. Because it is part of signature v4 and they claim they support it without additional precisions, From ffbce0f689a05975a5cd68b312bfefbad2dccf2b Mon Sep 17 00:00:00 2001 From: Yureka Date: Mon, 12 May 2025 19:39:20 +0200 Subject: [PATCH 23/73] speed up UploadPartCopy (cherry picked from commit db54bf96c7e35851ffbcf3f93fcefb0b9da72000) --- src/api/s3/copy.rs | 73 +++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/src/api/s3/copy.rs b/src/api/s3/copy.rs index edda7e0f..969541ad 100644 --- a/src/api/s3/copy.rs +++ b/src/api/s3/copy.rs @@ -559,6 +559,7 @@ pub async fn handle_upload_part_copy( let mut current_offset = 0; let mut next_block = defragmenter.next().await?; + let mut blocks_to_dup = dest_version.clone(); // TODO this could be optimized similarly to read_and_put_blocks // low priority because uploadpartcopy is rarely used @@ -588,8 +589,7 @@ pub async fn handle_upload_part_copy( .unwrap()?; checksummer = checksummer_updated; - dest_version.blocks.clear(); - dest_version.blocks.put( + let (version_block_key, version_block) = ( VersionBlockKey { part_number, offset: current_offset, @@ -601,37 +601,56 @@ pub async fn handle_upload_part_copy( ); current_offset += data_len; - let block_ref = BlockRef { - block: final_hash, - version: dest_version_id, - deleted: false.into(), + let next = if let Some(final_data) = data_to_upload { + dest_version.blocks.clear(); + dest_version.blocks.put(version_block_key, version_block); + let block_ref = BlockRef { + block: final_hash, + version: dest_version_id, + deleted: false.into(), + }; + let (_, _, _, next) = futures::try_join!( + // Thing 1: if the block is not exactly a block that existed before, + // we need to insert that data as a new block. + garage.block_manager.rpc_put_block( + final_hash, + final_data, + dest_encryption.is_encrypted(), + None + ), + // Thing 2: we need to insert the block in the version + garage.version_table.insert(&dest_version), + // Thing 3: we need to add a block reference + garage.block_ref_table.insert(&block_ref), + // Thing 4: we need to read the next block + defragmenter.next(), + )?; + next + } else { + blocks_to_dup.blocks.put(version_block_key, version_block); + defragmenter.next().await? }; - - let (_, _, _, next) = futures::try_join!( - // Thing 1: if the block is not exactly a block that existed before, - // we need to insert that data as a new block. - async { - if let Some(final_data) = data_to_upload { - garage - .block_manager - .rpc_put_block(final_hash, final_data, dest_encryption.is_encrypted(), None) - .await - } else { - Ok(()) - } - }, - // Thing 2: we need to insert the block in the version - garage.version_table.insert(&dest_version), - // Thing 3: we need to add a block reference - garage.block_ref_table.insert(&block_ref), - // Thing 4: we need to read the next block - defragmenter.next(), - )?; next_block = next; } assert_eq!(current_offset, source_range.length); + // Put the duplicated blocks into the version & block_refs tables + let block_refs_to_put = blocks_to_dup + .blocks + .items() + .iter() + .map(|b| BlockRef { + block: b.1.hash, + version: dest_version_id, + deleted: false.into(), + }) + .collect::>(); + futures::try_join!( + garage.version_table.insert(&blocks_to_dup), + garage.block_ref_table.insert_many(&block_refs_to_put[..]), + )?; + let checksums = checksummer.finalize(); let etag = dest_encryption.etag_from_md5(&checksums.md5); let checksum = checksums.extract(dest_object_checksum_algorithm); From 1b042e379eda36b3b435edfe2ab16a465a9eccaf Mon Sep 17 00:00:00 2001 From: Renjaya Raga Zenta Date: Mon, 19 May 2025 18:28:00 +0700 Subject: [PATCH 24/73] api: s3: implement get bucket acl --- src/api/s3/api_server.rs | 1 + src/api/s3/bucket.rs | 60 ++++++++++++++++++++++++++++++- src/api/s3/xml.rs | 77 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 1 deletion(-) diff --git a/src/api/s3/api_server.rs b/src/api/s3/api_server.rs index e26c2b65..337ddb23 100644 --- a/src/api/s3/api_server.rs +++ b/src/api/s3/api_server.rs @@ -226,6 +226,7 @@ impl ApiHandler for S3ApiServer { Endpoint::DeleteBucket {} => handle_delete_bucket(ctx).await, Endpoint::GetBucketLocation {} => handle_get_bucket_location(ctx), Endpoint::GetBucketVersioning {} => handle_get_bucket_versioning(), + Endpoint::GetBucketAcl {} => handle_get_bucket_acl(ctx), Endpoint::ListObjects { delimiter, encoding_type, diff --git a/src/api/s3/bucket.rs b/src/api/s3/bucket.rs index 26e2fc49..55caa6c8 100644 --- a/src/api/s3/bucket.rs +++ b/src/api/s3/bucket.rs @@ -5,7 +5,7 @@ use hyper::{Request, Response, StatusCode}; use garage_model::bucket_alias_table::*; use garage_model::bucket_table::Bucket; use garage_model::garage::Garage; -use garage_model::key_table::Key; +use garage_model::key_table::{Key, KeyParams}; use garage_model::permission::BucketKeyPerm; use garage_table::util::*; use garage_util::crdt::*; @@ -44,6 +44,55 @@ pub fn handle_get_bucket_versioning() -> Result, Error> { .body(string_body(xml))?) } +pub fn handle_get_bucket_acl(ctx: ReqCtx) -> Result, Error> { + let ReqCtx { + bucket_id, api_key, .. + } = ctx; + let key_p = api_key.params().ok_or_internal_error( + "Key should not be in deleted state at this point (in handle_get_bucket_acl)", + )?; + + let mut grants: Vec = vec![]; + let kp = api_key.bucket_permissions(&bucket_id); + + if kp.allow_owner { + grants.push(s3_xml::Grant { + grantee: create_grantee(&key_p, &api_key), + permission: s3_xml::Value("FULL_CONTROL".to_string()), + }); + } else { + if kp.allow_read { + grants.push(s3_xml::Grant { + grantee: create_grantee(&key_p, &api_key), + permission: s3_xml::Value("READ".to_string()), + }); + grants.push(s3_xml::Grant { + grantee: create_grantee(&key_p, &api_key), + permission: s3_xml::Value("READ_ACP".to_string()), + }); + } + if kp.allow_write { + grants.push(s3_xml::Grant { + grantee: create_grantee(&key_p, &api_key), + permission: s3_xml::Value("WRITE".to_string()), + }); + } + } + + let access_control_policy = s3_xml::AccessControlPolicy { + xmlns: (), + owner: None, + acl: s3_xml::AccessControlList { entries: grants }, + }; + + let xml = s3_xml::to_xml_with_header(&access_control_policy)?; + trace!("xml: {}", xml); + + Ok(Response::builder() + .header("Content-Type", "application/xml") + .body(string_body(xml))?) +} + pub async fn handle_list_buckets( garage: &Garage, api_key: &Key, @@ -311,6 +360,15 @@ fn parse_create_bucket_xml(xml_bytes: &[u8]) -> Option> { Some(ret) } +fn create_grantee(key_params: &KeyParams, api_key: &Key) -> s3_xml::Grantee { + s3_xml::Grantee { + xmlns_xsi: (), + typ: "CanonicalUser".to_string(), + display_name: Some(s3_xml::Value(key_params.name.get().to_string())), + id: Some(s3_xml::Value(api_key.key_id.to_string())), + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/api/s3/xml.rs b/src/api/s3/xml.rs index e8af3ec0..fdb36318 100644 --- a/src/api/s3/xml.rs +++ b/src/api/s3/xml.rs @@ -13,6 +13,10 @@ pub fn xmlns_tag(_v: &(), s: S) -> Result { s.serialize_str("http://s3.amazonaws.com/doc/2006-03-01/") } +pub fn xmlns_xsi_tag(_v: &(), s: S) -> Result { + s.serialize_str("http://www.w3.org/2001/XMLSchema-instance") +} + #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] pub struct Value(#[serde(rename = "$value")] pub String); @@ -319,6 +323,42 @@ pub struct PostObject { pub etag: Value, } +#[derive(Debug, Serialize, PartialEq, Eq)] +pub struct Grantee { + #[serde(rename = "xmlns:xsi", serialize_with = "xmlns_xsi_tag")] + pub xmlns_xsi: (), + #[serde(rename = "xsi:type")] + pub typ: String, + #[serde(rename = "DisplayName")] + pub display_name: Option, + #[serde(rename = "ID")] + pub id: Option, +} + +#[derive(Debug, Serialize, PartialEq, Eq)] +pub struct Grant { + #[serde(rename = "Grantee")] + pub grantee: Grantee, + #[serde(rename = "Permission")] + pub permission: Value, +} + +#[derive(Debug, Serialize, PartialEq, Eq)] +pub struct AccessControlList { + #[serde(rename = "Grant")] + pub entries: Vec, +} + +#[derive(Debug, Serialize, PartialEq, Eq)] +pub struct AccessControlPolicy { + #[serde(serialize_with = "xmlns_tag")] + pub xmlns: (), + #[serde(rename = "Owner")] + pub owner: Option, + #[serde(rename = "AccessControlList")] + pub acl: AccessControlList, +} + #[cfg(test)] mod tests { use super::*; @@ -427,6 +467,43 @@ mod tests { Ok(()) } + #[test] + fn get_bucket_acl_result() -> Result<(), ApiError> { + let grant = Grant { + grantee: Grantee { + xmlns_xsi: (), + typ: "CanonicalUser".to_string(), + display_name: Some(Value("owner_name".to_string())), + id: Some(Value("qsdfjklm".to_string())), + }, + permission: Value("FULL_CONTROL".to_string()), + }; + + let get_bucket_acl = AccessControlPolicy { + xmlns: (), + owner: None, + acl: AccessControlList { + entries: vec![grant], + }, + }; + assert_eq!( + to_xml_with_header(&get_bucket_acl)?, + "\ +\ + \ + \ + \ + owner_name\ + qsdfjklm\ + \ + FULL_CONTROL\ + \ + \ +" + ); + Ok(()) + } + #[test] fn delete_result() -> Result<(), ApiError> { let delete_result = DeleteResult { From 2a4f729b573f5f174ca31f061b0eed80fe48ff90 Mon Sep 17 00:00:00 2001 From: James O'Claire Date: Wed, 28 May 2025 09:49:50 +0800 Subject: [PATCH 25/73] Minor doc change to clarify why the capacity does not matter and how the zone name is used --- doc/book/quick-start/_index.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/book/quick-start/_index.md b/doc/book/quick-start/_index.md index 2db4211b..ff0c1510 100644 --- a/doc/book/quick-start/_index.md +++ b/doc/book/quick-start/_index.md @@ -182,11 +182,12 @@ ID Hostname Address Tag Zone Capacit ## Creating a cluster layout Creating a cluster layout for a Garage deployment means informing Garage -of the disk space available on each node of the cluster -as well as the zone (e.g. datacenter) each machine is located in. +of the disk space available on each node of the cluster, `-c`, +as well as the name of the zone (e.g. datacenter), `-z`, each machine is located in. -For our test deployment, we are using only one node. The way in which we configure -it does not matter, you can simply write: +For our test deployment, we are have only one node with zone named `dc1` and a +capacity of `1G`, though the capacity is ignored for a single node deployment +and can be changed later when adding new nodes. ```bash garage layout assign -z dc1 -c 1G From fc8fc60f6dae85c70a6350fdcfd560f024656c0e Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Fri, 30 May 2025 16:24:12 +0000 Subject: [PATCH 26/73] emit internal error when we detect race condition (#1053) (fix #1050) i went with a `500`/`InternalError`/`Please try again.` because that is something i've seen AWS S3 report while developing other software, and i'm not convinced all clients would understand a 409 conflict properly (GET don't usually conflict) Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1053 Co-authored-by: trinity-1686a Co-committed-by: trinity-1686a --- src/api/s3/copy.rs | 4 +++- src/api/s3/get.rs | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/api/s3/copy.rs b/src/api/s3/copy.rs index 969541ad..47a63c82 100644 --- a/src/api/s3/copy.rs +++ b/src/api/s3/copy.rs @@ -26,7 +26,7 @@ use garage_api_common::signature::checksum::*; use crate::api_server::{ReqBody, ResBody}; use crate::encryption::EncryptionParams; use crate::error::*; -use crate::get::{full_object_byte_stream, PreconditionHeaders}; +use crate::get::{check_version_not_deleted, full_object_byte_stream, PreconditionHeaders}; use crate::multipart; use crate::put::{extract_metadata_headers, save_stream, ChecksumMode, SaveStreamResult}; use crate::website::X_AMZ_WEBSITE_REDIRECT_LOCATION; @@ -237,6 +237,7 @@ async fn handle_copy_metaonly( .get(&source_version.uuid, &EmptyKey) .await?; let source_version = source_version.ok_or(Error::NoSuchKey)?; + check_version_not_deleted(&source_version)?; // Write an "uploading" marker in Object table // This holds a reference to the object in the Version table @@ -428,6 +429,7 @@ pub async fn handle_upload_part_copy( .get(&source_object_version.uuid, &EmptyKey) .await? .ok_or(Error::NoSuchKey)?; + check_version_not_deleted(&source_version)?; // We want to reuse blocks from the source version as much as possible. // However, we still need to get the data from these blocks diff --git a/src/api/s3/get.rs b/src/api/s3/get.rs index 22076603..888a040a 100644 --- a/src/api/s3/get.rs +++ b/src/api/s3/get.rs @@ -19,12 +19,13 @@ use garage_net::stream::ByteStream; use garage_rpc::rpc_helper::OrderTag; use garage_table::EmptyKey; use garage_util::data::*; -use garage_util::error::OkOrMessage; +use garage_util::error::{Error as UtilError, OkOrMessage}; use garage_model::garage::Garage; use garage_model::s3::object_table::*; use garage_model::s3::version_table::*; +use garage_api_common::common_error::CommonError; use garage_api_common::helpers::*; use garage_api_common::signature::checksum::{add_checksum_response_headers, X_AMZ_CHECKSUM_MODE}; @@ -215,6 +216,7 @@ pub async fn handle_head_without_ctx( .get(&object_version.uuid, &EmptyKey) .await? .ok_or(Error::NoSuchKey)?; + check_version_not_deleted(&version)?; let (part_offset, part_end) = calculate_part_bounds(&version, pn).ok_or(Error::InvalidPart)?; @@ -365,6 +367,21 @@ pub async fn handle_get_without_ctx( } } +pub(crate) fn check_version_not_deleted(version: &Version) -> Result<(), Error> { + if version.deleted.get() { + // the version was deleted between when the object_table was consulted + // and now, this could mean the object was deleted, or overriden. + // Rather than say the key doesn't exist, return a transient error + // to signal the client to try again. + return Err(CommonError::InternalError(UtilError::Message( + "conflict/inconsistency between object and version state, version is deleted" + .to_string(), + )) + .into()); + } + Ok(()) +} + async fn handle_get_full( garage: Arc, version: &ObjectVersion, @@ -431,6 +448,7 @@ pub fn full_object_byte_stream( .ok_or_message("channel closed")?; let version = version_fut.await.unwrap()?.ok_or(Error::NoSuchKey)?; + check_version_not_deleted(&version)?; for (i, (_, vb)) in version.blocks.items().iter().enumerate().skip(1) { let stream_block_i = encryption .get_block(&garage, &vb.hash, Some(order_stream.order(i as u64))) @@ -446,6 +464,14 @@ pub fn full_object_byte_stream( { Ok(()) => (), Err(e) => { + // TODO i think this is a bad idea, we should log + // an error and stop there. If the error happens to + // be exactly the size of what hasn't been streamed + // yet, the client will see the request as a + // success + // instead truncating the output notify the client + // something happened with their download, so that + // they can retry it let _ = tx.send(error_stream_item(e)).await; } } @@ -497,7 +523,7 @@ async fn handle_get_range( .get(&version.uuid, &EmptyKey) .await? .ok_or(Error::NoSuchKey)?; - + check_version_not_deleted(&version)?; let body = body_from_blocks_range(garage, encryption, version.blocks.items(), begin, end); Ok(resp_builder.body(body)?) @@ -548,6 +574,8 @@ async fn handle_get_part( .await? .ok_or(Error::NoSuchKey)?; + check_version_not_deleted(&version)?; + let (begin, end) = calculate_part_bounds(&version, part_number).ok_or(Error::InvalidPart)?; From 8843aa92fa1cc1edbb0cffdeac4b0be644e619d9 Mon Sep 17 00:00:00 2001 From: Renjaya Raga Zenta Date: Mon, 11 Nov 2024 14:58:09 +0700 Subject: [PATCH 27/73] feat: add log to journald feature The systemd-journald is used in most major Linux distros that use systemd. This enables logging using the systemd-journald native protocol, instead of just writing to stderr. --- Cargo.lock | 12 +++++++ Cargo.toml | 1 + doc/book/reference-manual/configuration.md | 4 +++ nix/compile.nix | 1 + src/garage/Cargo.toml | 3 ++ src/garage/main.rs | 37 ++++++++++++++++++++++ 6 files changed, 58 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index e65778cc..8301d8ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1250,6 +1250,7 @@ dependencies = [ "timeago", "tokio", "tracing", + "tracing-journald", "tracing-subscriber", ] @@ -4514,6 +4515,17 @@ dependencies = [ "tracing", ] +[[package]] +name = "tracing-journald" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0b4143302cf1022dac868d521e36e8b27691f72c84b3311750d5188ebba657" +dependencies = [ + "libc", + "tracing-core", + "tracing-subscriber", +] + [[package]] name = "tracing-log" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 400c1840..b57f890c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,6 +83,7 @@ pretty_env_logger = "0.5" structopt = { version = "0.3", default-features = false } syslog-tracing = "0.3" tracing = "0.1" +tracing-journald = "0.3.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } heed = { version = "0.11", default-features = false, features = ["lmdb"] } diff --git a/doc/book/reference-manual/configuration.md b/doc/book/reference-manual/configuration.md index 091419d9..32dc461b 100644 --- a/doc/book/reference-manual/configuration.md +++ b/doc/book/reference-manual/configuration.md @@ -160,6 +160,10 @@ variable, it does not exist in the configuration file: Garage daemon send its logs to `syslog` (using the libc `syslog` function) instead of printing to stderr. +- `GARAGE_LOG_TO_JOURNALD` (since `v2.0.0`): set this to `1` or `true` to make the + Garage daemon send its logs to `journald` (using the native protocol of `systemd-journald`) + instead of printing to stderr. + The following environment variables can be used to override the corresponding values in the configuration file: diff --git a/nix/compile.nix b/nix/compile.nix index 8cd88d01..bbadaa37 100644 --- a/nix/compile.nix +++ b/nix/compile.nix @@ -74,6 +74,7 @@ let "metrics" "telemetry-otlp" "syslog" + "journald" ])); featuresStr = lib.concatStringsSep "," rootFeatures; diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index f03c7331..d2785f06 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -57,6 +57,7 @@ opentelemetry.workspace = true opentelemetry-prometheus = { workspace = true, optional = true } opentelemetry-otlp = { workspace = true, optional = true } syslog-tracing = { workspace = true, optional = true } +tracing-journald = { workspace = true, optional = true } [dev-dependencies] garage_api_common.workspace = true @@ -101,6 +102,8 @@ metrics = [ "garage_api_admin/metrics", "opentelemetry-prometheus" ] telemetry-otlp = [ "opentelemetry-otlp" ] # Logging to syslog syslog = [ "syslog-tracing" ] +# Logging to journald +journald = [ "tracing-journald" ] # NOTE: bundled-libs and system-libs should be treat as mutually exclusive; # exactly one of them should be enabled. diff --git a/src/garage/main.rs b/src/garage/main.rs index ac95e854..2703bedd 100644 --- a/src/garage/main.rs +++ b/src/garage/main.rs @@ -208,6 +208,43 @@ fn init_logging(opt: &Opt) { } } + if std::env::var("GARAGE_LOG_TO_JOURNALD") + .map(|x| x == "1" || x == "true") + .unwrap_or(false) + { + #[cfg(feature = "journald")] + { + use tracing_journald::{Priority, PriorityMappings}; + use tracing_subscriber::layer::SubscriberExt; + use tracing_subscriber::util::SubscriberInitExt; + + let registry = tracing_subscriber::registry() + .with(tracing_subscriber::fmt::layer().with_writer(std::io::sink)) + .with(env_filter); + match tracing_journald::layer() { + Ok(layer) => { + registry + .with(layer.with_priority_mappings(PriorityMappings { + info: Priority::Informational, + debug: Priority::Debug, + ..PriorityMappings::new() + })) + .init(); + } + Err(e) => { + eprintln!("Couldn't connect to journald: {}.", e); + std::process::exit(1); + } + } + return; + } + #[cfg(not(feature = "journald"))] + { + eprintln!("Journald support is not enabled in this build."); + std::process::exit(1); + } + } + tracing_subscriber::fmt() .with_writer(std::io::stderr) .with_env_filter(env_filter) From 47143b88ad648635d085893977d750ef3a211087 Mon Sep 17 00:00:00 2001 From: eddster2309 Date: Tue, 3 Jun 2025 09:15:57 +0000 Subject: [PATCH 28/73] Add eddster2309/ansible-role-garage as deployment option --- doc/book/cookbook/ansible.md | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/doc/book/cookbook/ansible.md b/doc/book/cookbook/ansible.md index 6d624c9c..2d0a4a83 100644 --- a/doc/book/cookbook/ansible.md +++ b/doc/book/cookbook/ansible.md @@ -8,18 +8,18 @@ have published Ansible roles. We list them and compare them below. ## Comparison of Ansible roles -| Feature | [ansible-role-garage](#zorun-ansible-role-garage) | [garage-docker-ansible-deploy](#moan0s-garage-docker-ansible-deploy) | -|------------------------------------|---------------------------------------------|---------------------------------------------------------------| -| **Runtime** | Systemd | Docker | -| **Target OS** | Any Linux | Any Linux | -| **Architecture** | amd64, arm64, i686 | amd64, arm64 | -| **Additional software** | None | Traefik | -| **Automatic node connection** | ❌ | ✅ | -| **Layout management** | ❌ | ✅ | -| **Manage buckets & keys** | ❌ | ✅ (basic) | -| **Allow custom Garage config** | ✅ | ❌ | -| **Facilitate Garage upgrades** | ✅ | ❌ | -| **Multiple instances on one host** | ✅ | ✅ | +| Feature | [ansible-role-garage](#zorun-ansible-role-garage) | [garage-docker-ansible-deploy](#moan0s-garage-docker-ansible-deploy) | [eddster ansible-role-garage](#eddster-ansible-role-garage) | +|------------------------------------|---------------------------------------------|---------------------------------------------------------------|---------------------------------| +| **Runtime** | Systemd | Docker | Systemd | +| **Target OS** | Any Linux | Any Linux | Any Linux | +| **Architecture** | amd64, arm64, i686 | amd64, arm64 | amd64 | +| **Additional software** | None | Traefik | Ngnix and Keepalived (optional) | +| **Automatic node connection** | ❌ | ✅ | ✅ | +| **Layout management** | ❌ | ✅ | ✅ | +| **Manage buckets & keys** | ❌ | ✅ (basic) | ✅ | +| **Allow custom Garage config** | ✅ | ❌ | ❌ | +| **Facilitate Garage upgrades** | ✅ | ❌ | ✅ | +| **Multiple instances on one host** | ✅ | ✅ | ❌ | ## zorun/ansible-role-garage @@ -49,3 +49,15 @@ structured DNS names, etc). As a result, this role makes it easier to start with Garage on Ansible, but is less flexible. + +## eddster2309/ansible-role-garage + +[Source code](https://github.com/eddster2309/ansible-role-garage), [Ansible galaxy](https://galaxy.ansible.com/ui/standalone/roles/eddster2309/garage/) + +This role is a opinionated but customisable role using the official Garage +static binaries and only requires Systemd. As such it should work on any +Linux based host. It includes all the nesscary configuration to +automatically setup a clustered Garage deployment. Most Garage +configuration options are exposed through Ansible variables so while you +can't provide a custom config you can get very close. It can optionally +installed a HA nginx deployment with Keepalived. From adfa44ad70b53614b863de7e94d78f54bb4e10c9 Mon Sep 17 00:00:00 2001 From: eddster2309 Date: Tue, 3 Jun 2025 09:22:43 +0000 Subject: [PATCH 29/73] Add architecture support --- doc/book/cookbook/ansible.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/book/cookbook/ansible.md b/doc/book/cookbook/ansible.md index 2d0a4a83..8b0d2969 100644 --- a/doc/book/cookbook/ansible.md +++ b/doc/book/cookbook/ansible.md @@ -12,7 +12,7 @@ have published Ansible roles. We list them and compare them below. |------------------------------------|---------------------------------------------|---------------------------------------------------------------|---------------------------------| | **Runtime** | Systemd | Docker | Systemd | | **Target OS** | Any Linux | Any Linux | Any Linux | -| **Architecture** | amd64, arm64, i686 | amd64, arm64 | amd64 | +| **Architecture** | amd64, arm64, i686 | amd64, arm64 | arm64, arm, 386, amd64 | | **Additional software** | None | Traefik | Ngnix and Keepalived (optional) | | **Automatic node connection** | ❌ | ✅ | ✅ | | **Layout management** | ❌ | ✅ | ✅ | From 26bc8079050a52be9a12d02fc49fe20645660c78 Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Tue, 10 Jun 2025 20:42:59 +0200 Subject: [PATCH 30/73] put web error in a basic webpage before, it was a plain string, with an xml content type this caused browsers to show very ugly and meaningless pages --- src/garage/tests/s3/website.rs | 42 ++++++++++++++++++++++++++++++++++ src/web/web_server.rs | 24 +++++++++++++++++-- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/src/garage/tests/s3/website.rs b/src/garage/tests/s3/website.rs index 6d37eee8..bbac3de5 100644 --- a/src/garage/tests/s3/website.rs +++ b/src/garage/tests/s3/website.rs @@ -606,3 +606,45 @@ async fn test_website_puny() { ); } } + +#[tokio::test] +async fn test_website_object_not_found() { + const BCKT_NAME: &str = "not-found"; + let ctx = common::context(); + let _bucket = ctx.create_bucket(BCKT_NAME); + + let client = Client::builder(TokioExecutor::new()).build_http(); + + let req = |suffix| { + Request::builder() + .method("GET") + .uri(format!("http://127.0.0.1:{}/", ctx.garage.web_port)) + .header("Host", format!("{}{}", BCKT_NAME, suffix)) + .body(Body::new(Bytes::new())) + .unwrap() + }; + + ctx.garage + .command() + .args(["bucket", "website", "--allow", BCKT_NAME]) + .quiet() + .expect_success_status("Could not allow website on bucket"); + + let resp = client.request(req("")).await.unwrap(); + assert_eq!(resp.status(), StatusCode::NOT_FOUND); + // the error we return by default are *not* xml + assert_eq!( + resp.headers().get(http::header::CONTENT_TYPE).unwrap(), + "text/html; charset=utf-8" + ); + let result = String::from_utf8( + resp.into_body() + .collect() + .await + .unwrap() + .to_bytes() + .to_vec(), + ) + .unwrap(); + assert!(result.contains("not found")); +} diff --git a/src/web/web_server.rs b/src/web/web_server.rs index 242f7801..ea02ab0f 100644 --- a/src/web/web_server.rs +++ b/src/web/web_server.rs @@ -397,10 +397,30 @@ fn error_to_res(e: Error) -> Response> { // was a HEAD request or we couldn't get the error document) // We do NOT enter this code path when returning the bucket's // error document (this is handled in serve_file) - let body = string_body(format!("{}\n", e)); - let mut http_error = Response::new(body); + let mut body_str = format!( + r"{http_code} {code_text} +

{http_code} {code_text}

", + http_code = e.http_status_code().as_u16(), + code_text = e.http_status_code().canonical_reason().unwrap_or("Unknown"), + ); + if let Error::ApiError(ref err) = e { + body_str.push_str(&format!( + r" +
    +
  • Code: {s3_code}
  • +
  • Message: {s3_message}.
  • +
", + s3_code = err.aws_code(), + s3_message = err, + )); + } + let mut http_error = Response::new(string_body(body_str)); *http_error.status_mut() = e.http_status_code(); e.add_headers(http_error.headers_mut()); + http_error.headers_mut().insert( + http::header::CONTENT_TYPE, + "text/html; charset=utf-8".parse().unwrap(), + ); http_error } From 85ee4f5d8c10e676e7c9ed4da3734f449ce1ac7c Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 13 Jun 2025 13:49:35 +0200 Subject: [PATCH 31/73] cli: mark block refs as deleted in garage block purge --- src/garage/admin/block.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/garage/admin/block.rs b/src/garage/admin/block.rs index edeb88c0..5f908ce4 100644 --- a/src/garage/admin/block.rs +++ b/src/garage/admin/block.rs @@ -101,6 +101,7 @@ impl AdminRpcHandler { let mut obj_dels = 0; let mut mpu_dels = 0; let mut ver_dels = 0; + let mut br_dels = 0; for hash in blocks { let hash = hex::decode(hash).ok_or_bad_request("invalid hash")?; @@ -131,12 +132,19 @@ impl AdminRpcHandler { ver_dels += 1; } } + if !br.deleted.get() { + let mut br = br; + br.deleted.set(); + self.garage.block_ref_table.insert(&br).await?; + br_dels += 1; + } } } Ok(AdminRpc::Ok(format!( - "Purged {} blocks, {} versions, {} objects, {} multipart uploads", + "Purged {} blocks: marked {} block refs, {} versions, {} objects and {} multipart uploads as deleted", blocks.len(), + br_dels, ver_dels, obj_dels, mpu_dels, From fbf03e93784b76c2efb82ff8f62e1e7d32869ec9 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 13 Jun 2025 14:21:28 +0200 Subject: [PATCH 32/73] bump version to v1.2.0 --- Cargo.lock | 26 +++++++++++----------- Cargo.toml | 24 ++++++++++---------- doc/book/cookbook/real-world.md | 10 ++++----- doc/book/quick-start/_index.md | 2 +- doc/book/reference-manual/configuration.md | 6 ++--- doc/drafts/admin-api.md | 2 +- script/helm/garage/Chart.yaml | 6 ++--- script/helm/garage/README.md | 2 +- src/api/admin/Cargo.toml | 2 +- src/api/common/Cargo.toml | 2 +- src/api/k2v/Cargo.toml | 2 +- src/api/s3/Cargo.toml | 2 +- src/block/Cargo.toml | 2 +- src/db/Cargo.toml | 2 +- src/garage/Cargo.toml | 2 +- src/model/Cargo.toml | 2 +- src/net/Cargo.toml | 2 +- src/rpc/Cargo.toml | 2 +- src/table/Cargo.toml | 2 +- src/util/Cargo.toml | 2 +- src/web/Cargo.toml | 2 +- 21 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8301d8ee..5180fb29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1200,7 +1200,7 @@ dependencies = [ [[package]] name = "garage" -version = "1.1.0" +version = "1.2.0" dependencies = [ "assert-json-diff", "async-trait", @@ -1256,7 +1256,7 @@ dependencies = [ [[package]] name = "garage_api_admin" -version = "1.1.0" +version = "1.2.0" dependencies = [ "argon2", "async-trait", @@ -1282,7 +1282,7 @@ dependencies = [ [[package]] name = "garage_api_common" -version = "1.1.0" +version = "1.2.0" dependencies = [ "base64 0.21.7", "bytes", @@ -1316,7 +1316,7 @@ dependencies = [ [[package]] name = "garage_api_k2v" -version = "1.1.0" +version = "1.2.0" dependencies = [ "base64 0.21.7", "err-derive", @@ -1339,7 +1339,7 @@ dependencies = [ [[package]] name = "garage_api_s3" -version = "1.1.0" +version = "1.2.0" dependencies = [ "aes-gcm", "async-compression", @@ -1384,7 +1384,7 @@ dependencies = [ [[package]] name = "garage_block" -version = "1.1.0" +version = "1.2.0" dependencies = [ "arc-swap", "async-compression", @@ -1409,7 +1409,7 @@ dependencies = [ [[package]] name = "garage_db" -version = "1.1.0" +version = "1.2.0" dependencies = [ "err-derive", "heed", @@ -1422,7 +1422,7 @@ dependencies = [ [[package]] name = "garage_model" -version = "1.1.0" +version = "1.2.0" dependencies = [ "async-trait", "base64 0.21.7", @@ -1449,7 +1449,7 @@ dependencies = [ [[package]] name = "garage_net" -version = "1.1.0" +version = "1.2.0" dependencies = [ "arc-swap", "bytes", @@ -1474,7 +1474,7 @@ dependencies = [ [[package]] name = "garage_rpc" -version = "1.1.0" +version = "1.2.0" dependencies = [ "arc-swap", "async-trait", @@ -1506,7 +1506,7 @@ dependencies = [ [[package]] name = "garage_table" -version = "1.1.0" +version = "1.2.0" dependencies = [ "arc-swap", "async-trait", @@ -1527,7 +1527,7 @@ dependencies = [ [[package]] name = "garage_util" -version = "1.1.0" +version = "1.2.0" dependencies = [ "arc-swap", "async-trait", @@ -1559,7 +1559,7 @@ dependencies = [ [[package]] name = "garage_web" -version = "1.1.0" +version = "1.2.0" dependencies = [ "err-derive", "garage_api_common", diff --git a/Cargo.toml b/Cargo.toml index b57f890c..789225b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,18 +24,18 @@ default-members = ["src/garage"] # Internal Garage crates format_table = { version = "0.1.1", path = "src/format-table" } -garage_api_common = { version = "1.1.0", path = "src/api/common" } -garage_api_admin = { version = "1.1.0", path = "src/api/admin" } -garage_api_s3 = { version = "1.1.0", path = "src/api/s3" } -garage_api_k2v = { version = "1.1.0", path = "src/api/k2v" } -garage_block = { version = "1.1.0", path = "src/block" } -garage_db = { version = "1.1.0", path = "src/db", default-features = false } -garage_model = { version = "1.1.0", path = "src/model", default-features = false } -garage_net = { version = "1.1.0", path = "src/net" } -garage_rpc = { version = "1.1.0", path = "src/rpc" } -garage_table = { version = "1.1.0", path = "src/table" } -garage_util = { version = "1.1.0", path = "src/util" } -garage_web = { version = "1.1.0", path = "src/web" } +garage_api_common = { version = "1.2.0", path = "src/api/common" } +garage_api_admin = { version = "1.2.0", path = "src/api/admin" } +garage_api_s3 = { version = "1.2.0", path = "src/api/s3" } +garage_api_k2v = { version = "1.2.0", path = "src/api/k2v" } +garage_block = { version = "1.2.0", path = "src/block" } +garage_db = { version = "1.2.0", path = "src/db", default-features = false } +garage_model = { version = "1.2.0", path = "src/model", default-features = false } +garage_net = { version = "1.2.0", path = "src/net" } +garage_rpc = { version = "1.2.0", path = "src/rpc" } +garage_table = { version = "1.2.0", path = "src/table" } +garage_util = { version = "1.2.0", path = "src/util" } +garage_web = { version = "1.2.0", path = "src/web" } k2v-client = { version = "0.0.4", path = "src/k2v-client" } # External crates from crates.io diff --git a/doc/book/cookbook/real-world.md b/doc/book/cookbook/real-world.md index 594f1905..998c02a5 100644 --- a/doc/book/cookbook/real-world.md +++ b/doc/book/cookbook/real-world.md @@ -96,14 +96,14 @@ to store 2 TB of data in total. ## Get a Docker image Our docker image is currently named `dxflrs/garage` and is stored on the [Docker Hub](https://hub.docker.com/r/dxflrs/garage/tags?page=1&ordering=last_updated). -We encourage you to use a fixed tag (eg. `v1.1.0`) and not the `latest` tag. -For this example, we will use the latest published version at the time of the writing which is `v1.1.0` but it's up to you +We encourage you to use a fixed tag (eg. `v1.2.0`) and not the `latest` tag. +For this example, we will use the latest published version at the time of the writing which is `v1.2.0` but it's up to you to check [the most recent versions on the Docker Hub](https://hub.docker.com/r/dxflrs/garage/tags?page=1&ordering=last_updated). For example: ``` -sudo docker pull dxflrs/garage:v1.1.0 +sudo docker pull dxflrs/garage:v1.2.0 ``` ## Deploying and configuring Garage @@ -171,7 +171,7 @@ docker run \ -v /etc/garage.toml:/etc/garage.toml \ -v /var/lib/garage/meta:/var/lib/garage/meta \ -v /var/lib/garage/data:/var/lib/garage/data \ - dxflrs/garage:v1.1.0 + dxflrs/garage:v1.2.0 ``` With this command line, Garage should be started automatically at each boot. @@ -185,7 +185,7 @@ If you want to use `docker-compose`, you may use the following `docker-compose.y version: "3" services: garage: - image: dxflrs/garage:v1.1.0 + image: dxflrs/garage:v1.2.0 network_mode: "host" restart: unless-stopped volumes: diff --git a/doc/book/quick-start/_index.md b/doc/book/quick-start/_index.md index ff0c1510..45a4a43b 100644 --- a/doc/book/quick-start/_index.md +++ b/doc/book/quick-start/_index.md @@ -132,7 +132,7 @@ docker run \ -v /path/to/garage.toml:/etc/garage.toml \ -v /path/to/garage/meta:/var/lib/garage/meta \ -v /path/to/garage/data:/var/lib/garage/data \ - dxflrs/garage:v1.1.0 + dxflrs/garage:v1.2.0 ``` Under Linux, you can substitute `--network host` for `-p 3900:3900 -p 3901:3901 -p 3902:3902 -p 3903:3903` diff --git a/doc/book/reference-manual/configuration.md b/doc/book/reference-manual/configuration.md index 32dc461b..84aaf511 100644 --- a/doc/book/reference-manual/configuration.md +++ b/doc/book/reference-manual/configuration.md @@ -153,14 +153,14 @@ The `[admin]` section: ### Environment variables {#env_variables} -The following configuration parameter must be specified as an environment -variable, it does not exist in the configuration file: +The following configuration parameters must be specified as environment variables, +they do not exist in the configuration file: - `GARAGE_LOG_TO_SYSLOG` (since `v0.9.4`): set this to `1` or `true` to make the Garage daemon send its logs to `syslog` (using the libc `syslog` function) instead of printing to stderr. -- `GARAGE_LOG_TO_JOURNALD` (since `v2.0.0`): set this to `1` or `true` to make the +- `GARAGE_LOG_TO_JOURNALD` (since `v1.2.0`): set this to `1` or `true` to make the Garage daemon send its logs to `journald` (using the native protocol of `systemd-journald`) instead of printing to stderr. diff --git a/doc/drafts/admin-api.md b/doc/drafts/admin-api.md index acceefab..a3d03c41 100644 --- a/doc/drafts/admin-api.md +++ b/doc/drafts/admin-api.md @@ -70,7 +70,7 @@ Example response body: ```json { "node": "b10c110e4e854e5aa3f4637681befac755154b20059ec163254ddbfae86b09df", - "garageVersion": "v1.1.0", + "garageVersion": "v1.2.0", "garageFeatures": [ "k2v", "lmdb", diff --git a/script/helm/garage/Chart.yaml b/script/helm/garage/Chart.yaml index 7a89409e..6806e593 100644 --- a/script/helm/garage/Chart.yaml +++ b/script/helm/garage/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: garage description: S3-compatible object store for small self-hosted geo-distributed deployments type: application -version: 0.7.0 -appVersion: "v1.1.0" +version: 0.7.1 +appVersion: "v1.2.0" home: https://garagehq.deuxfleurs.fr/ icon: https://garagehq.deuxfleurs.fr/images/garage-logo.svg @@ -15,4 +15,4 @@ keywords: sources: - https://git.deuxfleurs.fr/Deuxfleurs/garage.git -maintainers: [] \ No newline at end of file +maintainers: [] diff --git a/script/helm/garage/README.md b/script/helm/garage/README.md index fcf988ca..05d444a3 100644 --- a/script/helm/garage/README.md +++ b/script/helm/garage/README.md @@ -1,6 +1,6 @@ # garage -![Version: 0.7.0](https://img.shields.io/badge/Version-0.7.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.1.0](https://img.shields.io/badge/AppVersion-v1.1.0-informational?style=flat-square) +![Version: 0.7.1](https://img.shields.io/badge/Version-0.7.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.2.0](https://img.shields.io/badge/AppVersion-v1.2.0-informational?style=flat-square) S3-compatible object store for small self-hosted geo-distributed deployments diff --git a/src/api/admin/Cargo.toml b/src/api/admin/Cargo.toml index 7b1d65e1..6b039eeb 100644 --- a/src/api/admin/Cargo.toml +++ b/src/api/admin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_api_admin" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/api/common/Cargo.toml b/src/api/common/Cargo.toml index b1a8b47a..a67e9d9c 100644 --- a/src/api/common/Cargo.toml +++ b/src/api/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_api_common" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/api/k2v/Cargo.toml b/src/api/k2v/Cargo.toml index 385aef3b..845d23f6 100644 --- a/src/api/k2v/Cargo.toml +++ b/src/api/k2v/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_api_k2v" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/api/s3/Cargo.toml b/src/api/s3/Cargo.toml index 7b0cac94..1ba7565d 100644 --- a/src/api/s3/Cargo.toml +++ b/src/api/s3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_api_s3" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/block/Cargo.toml b/src/block/Cargo.toml index 1f5558c5..d5f8e58e 100644 --- a/src/block/Cargo.toml +++ b/src/block/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_block" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/db/Cargo.toml b/src/db/Cargo.toml index bfc9029c..666296ce 100644 --- a/src/db/Cargo.toml +++ b/src/db/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_db" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index d2785f06..ae3b5609 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml index 42ec8537..376eaa9a 100644 --- a/src/model/Cargo.toml +++ b/src/model/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_model" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/net/Cargo.toml b/src/net/Cargo.toml index b48eb153..17a0eb24 100644 --- a/src/net/Cargo.toml +++ b/src/net/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_net" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/rpc/Cargo.toml b/src/rpc/Cargo.toml index e6466001..a314271f 100644 --- a/src/rpc/Cargo.toml +++ b/src/rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_rpc" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/table/Cargo.toml b/src/table/Cargo.toml index ef7b44e4..c76c5b78 100644 --- a/src/table/Cargo.toml +++ b/src/table/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_table" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/util/Cargo.toml b/src/util/Cargo.toml index 123406db..f59e44e2 100644 --- a/src/util/Cargo.toml +++ b/src/util/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_util" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/web/Cargo.toml b/src/web/Cargo.toml index c4fdbc0e..5d208e6e 100644 --- a/src/web/Cargo.toml +++ b/src/web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_web" -version = "1.1.0" +version = "1.2.0" authors = ["Alex Auvolat ", "Quentin Dufour "] edition = "2018" license = "AGPL-3.0" From 3a4afc04a9f157ecf09bac2417f9b043da783b1f Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 13 Jun 2025 17:22:47 +0200 Subject: [PATCH 33/73] cargo: update crossbeam-channel to avoid yanked version --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5180fb29..6acd85ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -867,9 +867,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.14" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" dependencies = [ "crossbeam-utils", ] From 1b42919bf7d63a7f9856e926c2068af5bbbb6d39 Mon Sep 17 00:00:00 2001 From: Arthur Carcano Date: Wed, 9 Jul 2025 12:32:56 +0200 Subject: [PATCH 34/73] Fix some unsoundness in lmdb adapter unsafe --- src/db/lmdb_adapter.rs | 66 +++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs index 259aa566..bd85f1b4 100644 --- a/src/db/lmdb_adapter.rs +++ b/src/db/lmdb_adapter.rs @@ -1,8 +1,8 @@ use core::ops::Bound; -use core::ptr::NonNull; use std::collections::HashMap; use std::convert::TryInto; +use std::marker::PhantomPinned; use std::path::PathBuf; use std::pin::Pin; use std::sync::{Arc, RwLock}; @@ -159,13 +159,15 @@ impl IDb for LmdbDb { fn iter(&self, tree: usize) -> Result> { let tree = self.get_tree(tree)?; let tx = self.db.read_txn()?; - TxAndIterator::make(tx, |tx| Ok(tree.iter(tx)?)) + // Safety: the cloture does not store its argument anywhere, + unsafe { TxAndIterator::make(tx, |tx| Ok(tree.iter(tx)?)) } } fn iter_rev(&self, tree: usize) -> Result> { let tree = self.get_tree(tree)?; let tx = self.db.read_txn()?; - TxAndIterator::make(tx, |tx| Ok(tree.rev_iter(tx)?)) + // Safety: the cloture does not store its argument anywhere, + unsafe { TxAndIterator::make(tx, |tx| Ok(tree.rev_iter(tx)?)) } } fn range<'r>( @@ -176,7 +178,8 @@ impl IDb for LmdbDb { ) -> Result> { let tree = self.get_tree(tree)?; let tx = self.db.read_txn()?; - TxAndIterator::make(tx, |tx| Ok(tree.range(tx, &(low, high))?)) + // Safety: the cloture does not store its argument anywhere, + unsafe { TxAndIterator::make(tx, |tx| Ok(tree.range(tx, &(low, high))?)) } } fn range_rev<'r>( &self, @@ -186,7 +189,8 @@ impl IDb for LmdbDb { ) -> Result> { let tree = self.get_tree(tree)?; let tx = self.db.read_txn()?; - TxAndIterator::make(tx, |tx| Ok(tree.rev_range(tx, &(low, high))?)) + // Safety: the cloture does not store its argument anywhere, + unsafe { TxAndIterator::make(tx, |tx| Ok(tree.rev_range(tx, &(low, high))?)) } } // ---- @@ -316,28 +320,41 @@ where { tx: RoTxn<'a>, iter: Option, + _pin: PhantomPinned, } impl<'a, I> TxAndIterator<'a, I> where I: Iterator> + 'a, { - fn make(tx: RoTxn<'a>, iterfun: F) -> Result> + fn iter(self: Pin<&mut Self>) -> &mut Option { + // Safety: iter is not structural + unsafe { &mut self.get_unchecked_mut().iter } + } + + /// Safety: iterfun must not store its argument anywhere but in its result. + unsafe fn make(tx: RoTxn<'a>, iterfun: F) -> Result> where F: FnOnce(&'a RoTxn<'a>) -> Result, { - let res = TxAndIterator { tx, iter: None }; + let res = TxAndIterator { + tx, + iter: None, + _pin: PhantomPinned, + }; let mut boxed = Box::pin(res); - // This unsafe allows us to bypass lifetime checks - let tx = unsafe { NonNull::from(&boxed.tx).as_ref() }; - let iter = iterfun(tx)?; + let tx_lifetime_overextended: &'a RoTxn<'a> = { + let tx = &boxed.tx; + // Safety: Artificially extending the lifetime because + // this reference will only be stored and accessed from the + // returned ValueIter which guarantees that it is destroyed + // before the tx it is pointing to. + unsafe { &*&raw const *tx } + }; + let iter = iterfun(&tx_lifetime_overextended)?; - let mut_ref = Pin::as_mut(&mut boxed); - // This unsafe allows us to write in a field of the pinned struct - unsafe { - Pin::get_unchecked_mut(mut_ref).iter = Some(iter); - } + *boxed.as_mut().iter() = Some(iter); Ok(Box::new(TxAndIteratorPin(boxed))) } @@ -348,8 +365,10 @@ where I: Iterator> + 'a, { fn drop(&mut self) { - // ensure the iterator is dropped before the RoTxn it references - drop(self.iter.take()); + // Safety: `new_unchecked` is okay because we know this value is never + // used again after being dropped. + let this = unsafe { Pin::new_unchecked(self) }; + drop(this.iter().take()); } } @@ -365,13 +384,12 @@ where fn next(&mut self) -> Option { let mut_ref = Pin::as_mut(&mut self.0); - // This unsafe allows us to mutably access the iterator field - let next = unsafe { Pin::get_unchecked_mut(mut_ref).iter.as_mut()?.next() }; - match next { - None => None, - Some(Err(e)) => Some(Err(e.into())), - Some(Ok((k, v))) => Some(Ok((k.to_vec(), v.to_vec()))), - } + let next = mut_ref.iter().as_mut()?.next()?; + let res = match next { + Err(e) => Err(e.into()), + Ok((k, v)) => Ok((k.to_vec(), v.to_vec())), + }; + Some(res) } } From 70cf6004ae79c26f0d1b17b03fb92b5081b83efb Mon Sep 17 00:00:00 2001 From: Lapineige Date: Fri, 1 Aug 2025 21:32:59 +0000 Subject: [PATCH 35/73] Fix typo in peertube buckets names --- doc/book/connect/apps/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/book/connect/apps/index.md b/doc/book/connect/apps/index.md index baf6ba50..f4ca9865 100644 --- a/doc/book/connect/apps/index.md +++ b/doc/book/connect/apps/index.md @@ -144,10 +144,10 @@ garage key new --name peertube-key Keep the Key ID and the Secret key in a pad, they will be needed later. -We need two buckets, one for normal videos (named peertube-video) and one for webtorrent videos (named peertube-playlist). +We need two buckets, one for normal videos (named peertube-videos) and one for webtorrent videos (named peertube-playlists). ```bash garage bucket create peertube-videos -garage bucket create peertube-playlist +garage bucket create peertube-playlists ``` Now we allow our key to read and write on these buckets: @@ -206,7 +206,7 @@ object_storage: proxify_private_files: false streaming_playlists: - bucket_name: 'peertube-playlist' + bucket_name: 'peertube-playlists' # Keep it empty for our example prefix: '' From cc29a40d51222d9dffb36e0747d4a164d1d0f9b8 Mon Sep 17 00:00:00 2001 From: Lapineige Date: Fri, 1 Aug 2025 21:35:15 +0000 Subject: [PATCH 36/73] Actualiser doc/book/connect/apps/index.md --- doc/book/connect/apps/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/book/connect/apps/index.md b/doc/book/connect/apps/index.md index 242e6fb1..f52d434b 100644 --- a/doc/book/connect/apps/index.md +++ b/doc/book/connect/apps/index.md @@ -12,7 +12,7 @@ In this section, we cover the following web applications: | [Mastodon](#mastodon) | ✅ | Natively supported | | [Matrix](#matrix) | ✅ | Tested with `synapse-s3-storage-provider` | | [ejabberd](#ejabberd) | ✅ | `mod_s3_upload` | -| [Pixelfed](#pixelfed) | ❓ | Not yet tested | +| [Pixelfed](#pixelfed) | ✅ | Natively supported | | [Pleroma](#pleroma) | ❓ | Not yet tested | | [Lemmy](#lemmy) | ✅ | Supported with pict-rs | | [Funkwhale](#funkwhale) | ❓ | Not yet tested | From f930c6f64302d2de1cff6fab6ed95468d2d99969 Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Sat, 2 Aug 2025 13:09:33 +0200 Subject: [PATCH 37/73] don't die on SIGHUP --- src/garage/server.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/garage/server.rs b/src/garage/server.rs index 1dc86fd3..b81ae334 100644 --- a/src/garage/server.rs +++ b/src/garage/server.rs @@ -183,10 +183,21 @@ fn watch_shutdown_signal() -> watch::Receiver { let mut sigterm = signal(SignalKind::terminate()).expect("Failed to install SIGTERM handler"); let mut sighup = signal(SignalKind::hangup()).expect("Failed to install SIGHUP handler"); - tokio::select! { - _ = sigint.recv() => info!("Received SIGINT, shutting down."), - _ = sigterm.recv() => info!("Received SIGTERM, shutting down."), - _ = sighup.recv() => info!("Received SIGHUP, shutting down."), + loop { + tokio::select! { + _ = sigint.recv() => { + info!("Received SIGINT, shutting down."); + break + } + _ = sigterm.recv() => { + info!("Received SIGTERM, shutting down."); + break + } + _ = sighup.recv() => { + info!("Received SIGHUP, reload not supported."); + continue + } + } } send_cancel.send(true).unwrap(); }); From 5469c9587718b24eb4b58ed9a5cbe39dfe39777b Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Sat, 2 Aug 2025 12:51:37 +0200 Subject: [PATCH 38/73] handle ECONNABORTED --- src/api/common/generic_server.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/common/generic_server.rs b/src/api/common/generic_server.rs index 6ddc2ff2..8f9bcdfb 100644 --- a/src/api/common/generic_server.rs +++ b/src/api/common/generic_server.rs @@ -343,7 +343,11 @@ where while !*must_exit.borrow() { let (stream, client_addr) = tokio::select! { - acc = listener.accept() => acc?, + acc = listener.accept() => match acc { + Ok(r) => r, + Err(e) if e.kind() == std::io::ErrorKind::ConnectionAborted => continue, + Err(e) => return Err(e.into()), + }, _ = must_exit.changed() => continue, }; From b340599e6865ecd488c7a88487c48b410e45d9f8 Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Sat, 2 Aug 2025 13:43:38 +0200 Subject: [PATCH 39/73] log access keys --- src/api/common/generic_server.rs | 28 ++++++++++++++++++---------- src/api/common/signature/payload.rs | 4 ++-- src/api/k2v/api_server.rs | 6 ++++++ src/api/s3/api_server.rs | 6 ++++++ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/api/common/generic_server.rs b/src/api/common/generic_server.rs index 6ddc2ff2..8453dc07 100644 --- a/src/api/common/generic_server.rs +++ b/src/api/common/generic_server.rs @@ -33,6 +33,7 @@ use garage_util::metrics::{gen_trace_id, RecordDuration}; use garage_util::socket_address::UnixOrTCPSocketAddress; use crate::helpers::{BoxBody, ErrorBody}; +use crate::signature::payload::Authorization; pub trait ApiEndpoint: Send + Sync + 'static { fn name(&self) -> &'static str; @@ -58,6 +59,12 @@ pub trait ApiHandler: Send + Sync + 'static { req: Request, endpoint: Self::Endpoint, ) -> impl Future>, Self::Error>> + Send; + + /// Returns the key id used to authenticate this request. The ID returned must be safe to + /// log. + fn key_id_from_request(&self, req: &Request) -> Option { + None + } } pub struct ApiServer { @@ -142,19 +149,20 @@ impl ApiServer { ) -> Result>, http::Error> { let uri = req.uri().clone(); - if let Ok(forwarded_for_ip_addr) = + let source = if let Ok(forwarded_for_ip_addr) = forwarded_headers::handle_forwarded_for_headers(req.headers()) { - info!( - "{} (via {}) {} {}", - forwarded_for_ip_addr, - addr, - req.method(), - uri - ); + format!("{forwarded_for_ip_addr} (via {addr})") } else { - info!("{} {} {}", addr, req.method(), uri); - } + format!("{addr}") + }; + // we only do this to log the access key, so we can discard any error + let key = self + .api_handler + .key_id_from_request(&req) + .map(|k| format!("(key {k}) ")) + .unwrap_or_default(); + info!("{source} {key}{} {uri}", req.method()); debug!("{:?}", req); let tracer = opentelemetry::global::tracer("garage"); diff --git a/src/api/common/signature/payload.rs b/src/api/common/signature/payload.rs index 2d5f8603..c3a7f231 100644 --- a/src/api/common/signature/payload.rs +++ b/src/api/common/signature/payload.rs @@ -417,7 +417,7 @@ pub async fn verify_v4( // ============ Authorization header, or X-Amz-* query params ========= pub struct Authorization { - key_id: String, + pub key_id: String, scope: String, signed_headers: String, signature: String, @@ -426,7 +426,7 @@ pub struct Authorization { } impl Authorization { - fn parse_header(headers: &HeaderMap) -> Result { + pub fn parse_header(headers: &HeaderMap) -> Result { let authorization = headers .get(AUTHORIZATION) .ok_or_bad_request("Missing authorization header")? diff --git a/src/api/k2v/api_server.rs b/src/api/k2v/api_server.rs index de5775da..8e10d9a6 100644 --- a/src/api/k2v/api_server.rs +++ b/src/api/k2v/api_server.rs @@ -176,6 +176,12 @@ impl ApiHandler for K2VApiServer { Ok(resp_ok) } + + fn key_id_from_request(&self, req: &Request) -> Option { + garage_api_common::signature::payload::Authorization::parse_header(req.headers()) + .map(|auth| auth.key_id) + .ok() + } } impl ApiEndpoint for K2VApiEndpoint { diff --git a/src/api/s3/api_server.rs b/src/api/s3/api_server.rs index 337ddb23..acb0cf56 100644 --- a/src/api/s3/api_server.rs +++ b/src/api/s3/api_server.rs @@ -343,6 +343,12 @@ impl ApiHandler for S3ApiServer { Ok(resp_ok) } + + fn key_id_from_request(&self, req: &Request) -> Option { + garage_api_common::signature::payload::Authorization::parse_header(req.headers()) + .map(|auth| auth.key_id) + .ok() + } } impl ApiEndpoint for S3ApiEndpoint { From 96d7713915861da178c101700c37d0ac580dd1dc Mon Sep 17 00:00:00 2001 From: Julien Kritter Date: Fri, 13 Sep 2024 10:40:46 +0200 Subject: [PATCH 40/73] Add support for an LSM-tree-based backend with Fjall --- Cargo.lock | 197 ++++++++++++++++++++- Cargo.toml | 1 + src/db/Cargo.toml | 2 + src/db/fjall_adapter.rs | 366 ++++++++++++++++++++++++++++++++++++++++ src/db/lib.rs | 2 + src/db/open.rs | 23 +++ src/garage/Cargo.toml | 1 + src/model/Cargo.toml | 1 + src/model/garage.rs | 7 + src/util/config.rs | 4 + 10 files changed, 603 insertions(+), 1 deletion(-) create mode 100644 src/db/fjall_adapter.rs diff --git a/Cargo.lock b/Cargo.lock index 6acd85ff..cd44160c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -687,6 +687,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d2c12f985c78475a6b8d629afd0c360260ef34cfef52efccdcfd31972f81c2e" +[[package]] +name = "byteview" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6236364b88b9b6d0bc181ba374cf1ab55ba3ef97a1cb6f8cddad48a273767fb5" + [[package]] name = "cc" version = "1.2.16" @@ -798,6 +804,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +[[package]] +name = "compare" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0095f6103c2a8b44acd6fd15960c801dafebf02e21940360833e0673f48ba7" + [[package]] name = "core-foundation" version = "0.9.4" @@ -874,6 +886,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-queue" version = "0.3.12" @@ -883,6 +904,16 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-skiplist" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df29de440c58ca2cc6e587ec3d22347551a32435fbde9d2bff64e78a9ffa151b" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.21" @@ -954,6 +985,20 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core 0.9.10", +] + [[package]] name = "deranged" version = "0.4.0" @@ -996,6 +1041,12 @@ dependencies = [ "syn 2.0.100", ] +[[package]] +name = "double-ended-peekable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0d05e1c0dbad51b52c38bda7adceef61b9efc2baf04acfe8726a8c4630a6f57" + [[package]] name = "dyn-clone" version = "1.0.19" @@ -1017,6 +1068,18 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum_dispatch" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" +dependencies = [ + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "env_logger" version = "0.10.2" @@ -1084,6 +1147,23 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "fjall" +version = "2.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b25ad44cd4360a0448a9b5a0a6f1c7a621101cca4578706d43c9a821418aebc" +dependencies = [ + "byteorder", + "byteview", + "dashmap 6.1.0", + "log", + "lsm-tree", + "path-absolutize", + "std-semaphore", + "tempfile", + "xxhash-rust", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1412,6 +1492,7 @@ name = "garage_db" version = "1.2.0" dependencies = [ "err-derive", + "fjall", "heed", "mktemp", "r2d2", @@ -1655,6 +1736,12 @@ dependencies = [ "syn 2.0.100", ] +[[package]] +name = "guardian" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17e2ac29387b1aa07a1e448f7bb4f35b500787971e965b02842b900afa5c8f6f" + [[package]] name = "h2" version = "0.3.26" @@ -2229,6 +2316,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "interval-heap" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11274e5e8e89b8607cfedc2910b6626e998779b48a019151c7604d0adcb86ac6" +dependencies = [ + "compare", +] + [[package]] name = "ipnet" version = "2.11.0" @@ -2585,6 +2681,36 @@ dependencies = [ "hashbrown 0.15.2", ] +[[package]] +name = "lsm-tree" +version = "2.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab73c02eadb3dc12c0024e5b61d6284e6d59064e67e74fbad77856caa56f62c7" +dependencies = [ + "byteorder", + "crossbeam-skiplist", + "double-ended-peekable", + "enum_dispatch", + "guardian", + "interval-heap", + "log", + "lz4_flex", + "path-absolutize", + "quick_cache", + "rustc-hash", + "self_cell", + "tempfile", + "value-log", + "varint-rs", + "xxhash-rust", +] + +[[package]] +name = "lz4_flex" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" + [[package]] name = "matchers" version = "0.1.0" @@ -2839,7 +2965,7 @@ checksum = "6105e89802af13fdf48c49d7646d3b533a70e536d818aae7e78ba0433d01acb8" dependencies = [ "async-trait", "crossbeam-channel", - "dashmap", + "dashmap 4.0.2", "fnv", "futures-channel", "futures-executor", @@ -3000,6 +3126,24 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "path-absolutize" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5" +dependencies = [ + "path-dedot", +] + +[[package]] +name = "path-dedot" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397" +dependencies = [ + "once_cell", +] + [[package]] name = "pem" version = "3.0.5" @@ -3295,6 +3439,16 @@ dependencies = [ "serde", ] +[[package]] +name = "quick_cache" +version = "0.6.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ad6644cb07b7f3488b9f3d2fde3b4c0a7fa367cafefb39dff93a659f76eb786" +dependencies = [ + "equivalent", + "hashbrown 0.15.2", +] + [[package]] name = "quote" version = "1.0.40" @@ -3532,6 +3686,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + [[package]] name = "rustc_version" version = "0.4.1" @@ -3774,6 +3934,12 @@ dependencies = [ "libc", ] +[[package]] +name = "self_cell" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749" + [[package]] name = "semver" version = "1.0.26" @@ -3987,6 +4153,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "std-semaphore" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ae9eec00137a8eed469fb4148acd9fc6ac8c3f9b110f52cd34698c8b5bfa0e" + [[package]] name = "strsim" version = "0.11.1" @@ -4664,6 +4836,29 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "value-log" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62fc7c4ce161f049607ecea654dca3f2d727da5371ae85e2e4f14ce2b98ed67c" +dependencies = [ + "byteorder", + "byteview", + "interval-heap", + "log", + "path-absolutize", + "rustc-hash", + "tempfile", + "varint-rs", + "xxhash-rust", +] + +[[package]] +name = "varint-rs" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f54a172d0620933a27a4360d3db3e2ae0dd6cceae9730751a036bbf182c4b23" + [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index 789225b8..9876db60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,6 +90,7 @@ heed = { version = "0.11", default-features = false, features = ["lmdb"] } rusqlite = "0.31.0" r2d2 = "0.8" r2d2_sqlite = "0.24" +fjall = "2.4" async-compression = { version = "0.4", features = ["tokio", "zstd"] } zstd = { version = "0.13", default-features = false } diff --git a/src/db/Cargo.toml b/src/db/Cargo.toml index 666296ce..06b2fabc 100644 --- a/src/db/Cargo.toml +++ b/src/db/Cargo.toml @@ -19,6 +19,7 @@ heed = { workspace = true, optional = true } rusqlite = { workspace = true, optional = true, features = ["backup"] } r2d2 = { workspace = true, optional = true } r2d2_sqlite = { workspace = true, optional = true } +fjall = { workspace = true, optional = true } [dev-dependencies] mktemp.workspace = true @@ -27,4 +28,5 @@ mktemp.workspace = true default = [ "lmdb", "sqlite" ] bundled-libs = [ "rusqlite?/bundled" ] lmdb = [ "heed" ] +fjall = [ "dep:fjall" ] sqlite = [ "rusqlite", "r2d2", "r2d2_sqlite" ] diff --git a/src/db/fjall_adapter.rs b/src/db/fjall_adapter.rs new file mode 100644 index 00000000..57b540c1 --- /dev/null +++ b/src/db/fjall_adapter.rs @@ -0,0 +1,366 @@ +use core::ops::Bound; + +use std::collections::HashMap; +use std::path::PathBuf; +use std::sync::{Arc, RwLock}; + +use fjall::{ + PartitionCreateOptions, PersistMode, TransactionalKeyspace, TransactionalPartitionHandle, + WriteTransaction, +}; + +use crate::{ + Db, Error, IDb, ITx, ITxFn, OnCommit, Result, TxError, TxFnResult, TxOpError, TxOpResult, + TxResult, TxValueIter, Value, ValueIter, +}; + +pub use fjall; + +// -- err + +impl From for Error { + fn from(e: fjall::Error) -> Error { + Error(format!("fjall: {}", e).into()) + } +} + +impl From for Error { + fn from(e: fjall::LsmError) -> Error { + Error(format!("fjall lsm_tree: {}", e).into()) + } +} + +impl From for TxOpError { + fn from(e: fjall::Error) -> TxOpError { + TxOpError(e.into()) + } +} + +// -- db + +pub struct FjallDb { + path: PathBuf, + keyspace: TransactionalKeyspace, + trees: RwLock<(Vec, HashMap)>, +} + +type ByteRefRangeBound<'r> = (Bound<&'r [u8]>, Bound<&'r [u8]>); + +impl FjallDb { + pub fn init(path: &PathBuf, keyspace: TransactionalKeyspace) -> Db { + let s = Self { + path: path.clone(), + keyspace, + trees: RwLock::new((Vec::new(), HashMap::new())), + }; + Db(Arc::new(s)) + } + + fn get_tree(&self, i: usize) -> Result { + self.trees + .read() + .unwrap() + .0 + .get(i) + .cloned() + .ok_or_else(|| Error("invalid tree id".into())) + } + + fn canonicalize(name: &str) -> String { + name.chars() + .map(|c| { + if c.is_alphanumeric() || c == '-' || c == '_' { + c + } else { + '_' + } + }) + .collect::() + } +} + +impl IDb for FjallDb { + fn engine(&self) -> String { + "LSM trees (using Fjall crate)".into() + } + + fn open_tree(&self, name: &str) -> Result { + let mut trees = self.trees.write().unwrap(); + let canonical_name = FjallDb::canonicalize(name); + if let Some(i) = trees.1.get(&canonical_name) { + Ok(*i) + } else { + let tree = self + .keyspace + .open_partition(&canonical_name, PartitionCreateOptions::default())?; + let i = trees.0.len(); + trees.0.push(tree); + trees.1.insert(canonical_name, i); + Ok(i) + } + } + + fn list_trees(&self) -> Result> { + Ok(self + .keyspace + .list_partitions() + .iter() + .map(|n| n.to_string()) + .collect()) + } + + fn snapshot(&self, to: &PathBuf) -> Result<()> { + std::fs::create_dir_all(to)?; + let mut path = to.clone(); + path.push("data.fjall"); + + let source_keyspace = fjall::Config::new(&self.path).open()?; + let copy_keyspace = fjall::Config::new(path).open()?; + + for partition_name in source_keyspace.list_partitions() { + let source_partition = source_keyspace + .open_partition(&partition_name, PartitionCreateOptions::default())?; + let snapshot = source_partition.snapshot(); + let copy_partition = + copy_keyspace.open_partition(&partition_name, PartitionCreateOptions::default())?; + + for entry in snapshot.iter() { + let (key, value) = entry?; + copy_partition.insert(key, value)?; + } + } + + copy_keyspace.persist(PersistMode::SyncAll)?; + Ok(()) + } + + // ---- + + fn get(&self, tree_idx: usize, key: &[u8]) -> Result> { + let tree = self.get_tree(tree_idx)?; + let tx = self.keyspace.read_tx(); + let val = tx.get(&tree, key)?; + match val { + None => Ok(None), + Some(v) => Ok(Some(v.to_vec())), + } + } + + fn len(&self, tree_idx: usize) -> Result { + let tree = self.get_tree(tree_idx)?; + let tx = self.keyspace.read_tx(); + Ok(tx.len(&tree)?) + } + + fn insert(&self, tree_idx: usize, key: &[u8], value: &[u8]) -> Result<()> { + let tree = self.get_tree(tree_idx)?; + let mut tx = self.keyspace.write_tx(); + tx.insert(&tree, key, value); + tx.commit()?; + Ok(()) + } + + fn remove(&self, tree_idx: usize, key: &[u8]) -> Result<()> { + let tree = self.get_tree(tree_idx)?; + let mut tx = self.keyspace.write_tx(); + tx.remove(&tree, key); + tx.commit()?; + Ok(()) + } + + fn clear(&self, tree_idx: usize) -> Result<()> { + let tree = self.get_tree(tree_idx)?; + let tree_name = tree.inner().name.clone(); + self.keyspace.delete_partition(tree)?; + let tree = self + .keyspace + .open_partition(&tree_name, PartitionCreateOptions::default())?; + let mut trees = self.trees.write().unwrap(); + trees.0[tree_idx] = tree; + Ok(()) + } + + fn iter(&self, tree_idx: usize) -> Result> { + let tree = self.get_tree(tree_idx)?; + let tx = self.keyspace.read_tx(); + Ok(Box::new(tx.iter(&tree).map(iterator_remap))) + } + + fn iter_rev(&self, tree_idx: usize) -> Result> { + let tree = self.get_tree(tree_idx)?; + let tx = self.keyspace.read_tx(); + Ok(Box::new(tx.iter(&tree).rev().map(iterator_remap))) + } + + fn range<'r>( + &self, + tree_idx: usize, + low: Bound<&'r [u8]>, + high: Bound<&'r [u8]>, + ) -> Result> { + let tree = self.get_tree(tree_idx)?; + let tx = self.keyspace.read_tx(); + Ok(Box::new( + tx.range::<&'r [u8], ByteRefRangeBound>(&tree, (low, high)) + .map(iterator_remap), + )) + } + fn range_rev<'r>( + &self, + tree_idx: usize, + low: Bound<&'r [u8]>, + high: Bound<&'r [u8]>, + ) -> Result> { + let tree = self.get_tree(tree_idx)?; + let tx = self.keyspace.read_tx(); + Ok(Box::new( + tx.range::<&'r [u8], ByteRefRangeBound>(&tree, (low, high)) + .rev() + .map(iterator_remap), + )) + } + + // ---- + + fn transaction(&self, f: &dyn ITxFn) -> TxResult { + let trees = self.trees.read().unwrap(); + let mut tx = FjallTx { + trees: &trees.0[..], + tx: self.keyspace.write_tx(), + }; + + let res = f.try_on(&mut tx); + match res { + TxFnResult::Ok(on_commit) => { + tx.tx.commit().map_err(Error::from).map_err(TxError::Db)?; + Ok(on_commit) + } + TxFnResult::Abort => { + tx.tx.rollback(); + Err(TxError::Abort(())) + } + TxFnResult::DbErr => { + tx.tx.rollback(); + Err(TxError::Db(Error( + "(this message will be discarded)".into(), + ))) + } + } + } +} + +// ---- + +struct FjallTx<'a> { + trees: &'a [TransactionalPartitionHandle], + tx: WriteTransaction<'a>, +} + +impl<'a> FjallTx<'a> { + fn get_tree(&self, i: usize) -> TxOpResult<&TransactionalPartitionHandle> { + self.trees.get(i).ok_or_else(|| { + TxOpError(Error( + "invalid tree id (it might have been openned after the transaction started)".into(), + )) + }) + } +} + +impl<'a> ITx for FjallTx<'a> { + fn get(&self, tree_idx: usize, key: &[u8]) -> TxOpResult> { + let tree = self.get_tree(tree_idx)?; + match self.tx.get(tree, key)? { + Some(v) => Ok(Some(v.to_vec())), + None => Ok(None), + } + } + fn len(&self, tree_idx: usize) -> TxOpResult { + let tree = self.get_tree(tree_idx)?; + Ok(self.tx.len(tree)? as usize) + } + + fn insert(&mut self, tree_idx: usize, key: &[u8], value: &[u8]) -> TxOpResult<()> { + let tree = self.get_tree(tree_idx)?.clone(); + self.tx.insert(&tree, key, value); + Ok(()) + } + fn remove(&mut self, tree_idx: usize, key: &[u8]) -> TxOpResult<()> { + let tree = self.get_tree(tree_idx)?.clone(); + self.tx.remove(&tree, key); + Ok(()) + } + fn clear(&mut self, _tree_idx: usize) -> TxOpResult<()> { + unimplemented!("LSM tree clearing in cross-partition transaction is not supported") + } + + fn iter(&self, tree_idx: usize) -> TxOpResult> { + let tree = self.get_tree(tree_idx)?.clone(); + Ok(Box::new(self.tx.iter(&tree).map(iterator_remap_tx))) + } + fn iter_rev(&self, tree_idx: usize) -> TxOpResult> { + let tree = self.get_tree(tree_idx)?.clone(); + Ok(Box::new(self.tx.iter(&tree).rev().map(iterator_remap_tx))) + } + + fn range<'r>( + &self, + tree_idx: usize, + low: Bound<&'r [u8]>, + high: Bound<&'r [u8]>, + ) -> TxOpResult> { + let tree = self.get_tree(tree_idx)?; + let low = clone_bound(low); + let high = clone_bound(high); + Ok(Box::new( + self.tx + .range::, ByteVecRangeBounds>(&tree, (low, high)) + .map(iterator_remap_tx), + )) + } + fn range_rev<'r>( + &self, + tree_idx: usize, + low: Bound<&'r [u8]>, + high: Bound<&'r [u8]>, + ) -> TxOpResult> { + let tree = self.get_tree(tree_idx)?; + let low = clone_bound(low); + let high = clone_bound(high); + Ok(Box::new( + self.tx + .range::, ByteVecRangeBounds>(&tree, (low, high)) + .rev() + .map(iterator_remap_tx), + )) + } +} + +// -- maps fjall's (k, v) to ours + +fn iterator_remap(r: fjall::Result<(fjall::Slice, fjall::Slice)>) -> Result<(Value, Value)> { + r.map(|(k, v)| (k.to_vec(), v.to_vec())) + .map_err(|e| e.into()) +} + +fn iterator_remap_tx(r: fjall::Result<(fjall::Slice, fjall::Slice)>) -> TxOpResult<(Value, Value)> { + r.map(|(k, v)| (k.to_vec(), v.to_vec())) + .map_err(|e| e.into()) +} + +// -- utils to deal with Garage's tightness on Bound lifetimes + +type ByteVecBound = Bound>; +type ByteVecRangeBounds = (ByteVecBound, ByteVecBound); + +fn clone_bound(bound: Bound<&[u8]>) -> ByteVecBound { + let value = match bound { + Bound::Excluded(v) | Bound::Included(v) => v.to_vec(), + Bound::Unbounded => vec![], + }; + + match bound { + Bound::Included(_) => Bound::Included(value), + Bound::Excluded(_) => Bound::Excluded(value), + Bound::Unbounded => Bound::Unbounded, + } +} diff --git a/src/db/lib.rs b/src/db/lib.rs index c55c8643..3454c759 100644 --- a/src/db/lib.rs +++ b/src/db/lib.rs @@ -1,6 +1,8 @@ #[macro_use] extern crate tracing; +#[cfg(feature = "fjall")] +pub mod fjall_adapter; #[cfg(feature = "lmdb")] pub mod lmdb_adapter; #[cfg(feature = "sqlite")] diff --git a/src/db/open.rs b/src/db/open.rs index ff3bc830..83ae1f93 100644 --- a/src/db/open.rs +++ b/src/db/open.rs @@ -1,4 +1,6 @@ +use std::convert::TryInto; use std::path::PathBuf; +use std::sync::Arc; use crate::{Db, Error, Result}; @@ -11,6 +13,7 @@ use crate::{Db, Error, Result}; pub enum Engine { Lmdb, Sqlite, + Fjall, } impl Engine { @@ -19,6 +22,7 @@ impl Engine { match self { Self::Lmdb => "lmdb", Self::Sqlite => "sqlite", + Self::Fjall => "fjall", } } } @@ -36,6 +40,7 @@ impl std::str::FromStr for Engine { match text { "lmdb" | "heed" => Ok(Self::Lmdb), "sqlite" | "sqlite3" | "rusqlite" => Ok(Self::Sqlite), + "fjall" => Ok(Self::Fjall), "sled" => Err(Error("Sled is no longer supported as a database engine. Converting your old metadata db can be done using an older Garage binary (e.g. v0.9.4).".into())), kind => Err(Error( format!( @@ -51,6 +56,7 @@ impl std::str::FromStr for Engine { pub struct OpenOpt { pub fsync: bool, pub lmdb_map_size: Option, + pub fjall_block_cache_size: Option, } impl Default for OpenOpt { @@ -58,6 +64,7 @@ impl Default for OpenOpt { Self { fsync: false, lmdb_map_size: None, + fjall_block_cache_size: None, } } } @@ -114,6 +121,22 @@ pub fn open_db(path: &PathBuf, engine: Engine, opt: &OpenOpt) -> Result { } } + // ---- Fjall DB ---- + #[cfg(feature = "fjall")] + Engine::Fjall => { + info!("Opening Fjall database at: {}", path.display()); + let fsync_ms = opt.fsync.then(|| 1000 as u16); + let mut config = fjall::Config::new(path).fsync_ms(fsync_ms); + if let Some(block_cache_size) = opt.fjall_block_cache_size { + let block_cache = Arc::new(fjall::BlockCache::with_capacity_bytes( + block_cache_size.try_into().unwrap(), + )); + config = config.block_cache(block_cache); + } + let keyspace = config.open_transactional()?; + Ok(crate::fjall_adapter::FjallDb::init(path, keyspace)) + } + // Pattern is unreachable when all supported DB engines are compiled into binary. The allow // attribute is added so that we won't have to change this match in case stop building // support for one or more engines by default. diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index ae3b5609..7d60313e 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -91,6 +91,7 @@ k2v = [ "garage_util/k2v", "garage_api_k2v" ] # Database engines lmdb = [ "garage_model/lmdb" ] sqlite = [ "garage_model/sqlite" ] +fjall = [ "garage_model/fjall" ] # Automatic registration and discovery via Consul API consul-discovery = [ "garage_rpc/consul-discovery" ] diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml index 376eaa9a..14f92253 100644 --- a/src/model/Cargo.toml +++ b/src/model/Cargo.toml @@ -44,3 +44,4 @@ default = [ "lmdb", "sqlite" ] k2v = [ "garage_util/k2v" ] lmdb = [ "garage_db/lmdb" ] sqlite = [ "garage_db/sqlite" ] +fjall = [ "garage_db/fjall" ] \ No newline at end of file diff --git a/src/model/garage.rs b/src/model/garage.rs index 11c0d90f..7420e740 100644 --- a/src/model/garage.rs +++ b/src/model/garage.rs @@ -124,6 +124,9 @@ impl Garage { db::Engine::Lmdb => { db_path.push("db.lmdb"); } + db::Engine::Fjall => { + db_path.push("db.fjall"); + } } let db_opt = db::OpenOpt { fsync: config.metadata_fsync, @@ -131,6 +134,10 @@ impl Garage { v if v == usize::default() => None, v => Some(v), }, + fjall_block_cache_size: match config.fjall_block_cache_size { + v if v == usize::default() => None, + v => Some(v), + }, }; let db = db::open_db(&db_path, db_engine, &db_opt) .ok_or_message("Unable to open metadata db")?; diff --git a/src/util/config.rs b/src/util/config.rs index c74029e7..19c3e821 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -122,6 +122,10 @@ pub struct Config { #[serde(deserialize_with = "deserialize_capacity", default)] pub lmdb_map_size: usize, + /// Fjall block cache size + #[serde(deserialize_with = "deserialize_capacity", default)] + pub fjall_block_cache_size: usize, + // -- APIs /// Configuration for S3 api pub s3_api: S3ApiConfig, From a6c6c44310973aba4625abba3819eaf1099362b5 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 4 Jan 2025 17:56:09 +0100 Subject: [PATCH 41/73] nix: build and test fjall feature --- .woodpecker/debug.yaml | 5 +++++ flake.nix | 3 +++ nix/compile.nix | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.woodpecker/debug.yaml b/.woodpecker/debug.yaml index 65dab9ab..62266aa4 100644 --- a/.woodpecker/debug.yaml +++ b/.woodpecker/debug.yaml @@ -28,6 +28,11 @@ steps: commands: - nix-build -j4 --attr flakePackages.tests-sqlite + - name: unit + func tests (fjall) + image: nixpkgs/nix:nixos-22.05 + commands: + - nix-build -j4 --attr flakePackages.tests-fjall + - name: integration tests image: nixpkgs/nix:nixos-22.05 commands: diff --git a/flake.nix b/flake.nix index fc599e0b..2fb8c48e 100644 --- a/flake.nix +++ b/flake.nix @@ -53,6 +53,9 @@ tests-sqlite = testWith { GARAGE_TEST_INTEGRATION_DB_ENGINE = "sqlite"; }; + tests-fjall = testWith { + GARAGE_TEST_INTEGRATION_DB_ENGINE = "fjall"; + }; }; # ---- developpment shell, for making native builds only ---- diff --git a/nix/compile.nix b/nix/compile.nix index bbadaa37..7e9f79ab 100644 --- a/nix/compile.nix +++ b/nix/compile.nix @@ -68,7 +68,7 @@ let rootFeatures = if features != null then features else - ([ "bundled-libs" "lmdb" "sqlite" "k2v" ] ++ (lib.optionals release [ + ([ "bundled-libs" "lmdb" "sqlite" "fjall" "k2v" ] ++ (lib.optionals release [ "consul-discovery" "kubernetes-discovery" "metrics" From aa69c06f2b1b76630ae5b0f9d14c4223dbee6641 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 27 Aug 2025 19:41:06 +0200 Subject: [PATCH 42/73] fix potential race condition and naming bug in fjall adapter --- Cargo.lock | 1 + Cargo.toml | 1 + src/db/Cargo.toml | 5 +- src/db/fjall_adapter.rs | 170 ++++++++++++++++++++++++++++------------ src/db/open.rs | 8 +- src/db/test.rs | 14 +++- 6 files changed, 139 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cd44160c..997d6a92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1495,6 +1495,7 @@ dependencies = [ "fjall", "heed", "mktemp", + "parking_lot 0.12.3", "r2d2", "r2d2_sqlite", "rusqlite", diff --git a/Cargo.toml b/Cargo.toml index 9876db60..fdec5010 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,7 @@ md-5 = "0.10" mktemp = "0.5" nix = { version = "0.29", default-features = false, features = ["fs"] } nom = "7.1" +parking_lot = "0.12" parse_duration = "2.1" pin-project = "1.0.12" pnet_datalink = "0.34" diff --git a/src/db/Cargo.toml b/src/db/Cargo.toml index 06b2fabc..e9ed15c9 100644 --- a/src/db/Cargo.toml +++ b/src/db/Cargo.toml @@ -16,10 +16,13 @@ err-derive.workspace = true tracing.workspace = true heed = { workspace = true, optional = true } + rusqlite = { workspace = true, optional = true, features = ["backup"] } r2d2 = { workspace = true, optional = true } r2d2_sqlite = { workspace = true, optional = true } + fjall = { workspace = true, optional = true } +parking_lot = { workspace = true, optional = true } [dev-dependencies] mktemp.workspace = true @@ -28,5 +31,5 @@ mktemp.workspace = true default = [ "lmdb", "sqlite" ] bundled-libs = [ "rusqlite?/bundled" ] lmdb = [ "heed" ] -fjall = [ "dep:fjall" ] +fjall = [ "dep:fjall", "dep:parking_lot" ] sqlite = [ "rusqlite", "r2d2", "r2d2_sqlite" ] diff --git a/src/db/fjall_adapter.rs b/src/db/fjall_adapter.rs index 57b540c1..d91ef12f 100644 --- a/src/db/fjall_adapter.rs +++ b/src/db/fjall_adapter.rs @@ -1,8 +1,9 @@ use core::ops::Bound; -use std::collections::HashMap; use std::path::PathBuf; -use std::sync::{Arc, RwLock}; +use std::sync::Arc; + +use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard}; use fjall::{ PartitionCreateOptions, PersistMode, TransactionalKeyspace, TransactionalPartitionHandle, @@ -39,63 +40,48 @@ impl From for TxOpError { // -- db pub struct FjallDb { - path: PathBuf, keyspace: TransactionalKeyspace, - trees: RwLock<(Vec, HashMap)>, + trees: RwLock>, } type ByteRefRangeBound<'r> = (Bound<&'r [u8]>, Bound<&'r [u8]>); impl FjallDb { - pub fn init(path: &PathBuf, keyspace: TransactionalKeyspace) -> Db { + pub fn init(keyspace: TransactionalKeyspace) -> Db { let s = Self { - path: path.clone(), keyspace, - trees: RwLock::new((Vec::new(), HashMap::new())), + trees: RwLock::new(Vec::new()), }; Db(Arc::new(s)) } - fn get_tree(&self, i: usize) -> Result { - self.trees - .read() - .unwrap() - .0 - .get(i) - .cloned() - .ok_or_else(|| Error("invalid tree id".into())) - } - - fn canonicalize(name: &str) -> String { - name.chars() - .map(|c| { - if c.is_alphanumeric() || c == '-' || c == '_' { - c - } else { - '_' - } - }) - .collect::() + fn get_tree( + &self, + i: usize, + ) -> Result> { + RwLockReadGuard::try_map(self.trees.read(), |trees: &Vec<_>| { + trees.get(i).map(|tup| &tup.1) + }) + .map_err(|_| Error("invalid tree id".into())) } } impl IDb for FjallDb { fn engine(&self) -> String { - "LSM trees (using Fjall crate)".into() + "Fjall (EXPERIMENTAL!)".into() } fn open_tree(&self, name: &str) -> Result { - let mut trees = self.trees.write().unwrap(); - let canonical_name = FjallDb::canonicalize(name); - if let Some(i) = trees.1.get(&canonical_name) { - Ok(*i) + let mut trees = self.trees.write(); + let safe_name = encode_name(name)?; + if let Some(i) = trees.iter().position(|(name, _)| *name == safe_name) { + Ok(i) } else { let tree = self .keyspace - .open_partition(&canonical_name, PartitionCreateOptions::default())?; - let i = trees.0.len(); - trees.0.push(tree); - trees.1.insert(canonical_name, i); + .open_partition(&safe_name, PartitionCreateOptions::default())?; + let i = trees.len(); + trees.push((safe_name, tree)); Ok(i) } } @@ -105,8 +91,8 @@ impl IDb for FjallDb { .keyspace .list_partitions() .iter() - .map(|n| n.to_string()) - .collect()) + .map(|n| decode_name(&n)) + .collect::>>()?) } fn snapshot(&self, to: &PathBuf) -> Result<()> { @@ -114,17 +100,17 @@ impl IDb for FjallDb { let mut path = to.clone(); path.push("data.fjall"); - let source_keyspace = fjall::Config::new(&self.path).open()?; + let source_state = self.keyspace.read_tx(); let copy_keyspace = fjall::Config::new(path).open()?; - for partition_name in source_keyspace.list_partitions() { - let source_partition = source_keyspace + for partition_name in self.keyspace.list_partitions() { + let source_partition = self + .keyspace .open_partition(&partition_name, PartitionCreateOptions::default())?; - let snapshot = source_partition.snapshot(); let copy_partition = copy_keyspace.open_partition(&partition_name, PartitionCreateOptions::default())?; - for entry in snapshot.iter() { + for entry in source_state.iter(&source_partition) { let (key, value) = entry?; copy_partition.insert(key, value)?; } @@ -169,14 +155,19 @@ impl IDb for FjallDb { } fn clear(&self, tree_idx: usize) -> Result<()> { - let tree = self.get_tree(tree_idx)?; - let tree_name = tree.inner().name.clone(); + let mut trees = self.trees.write(); + + if tree_idx >= trees.len() { + return Err(Error("invalid tree id".into())); + } + let (name, tree) = trees.remove(tree_idx); + self.keyspace.delete_partition(tree)?; let tree = self .keyspace - .open_partition(&tree_name, PartitionCreateOptions::default())?; - let mut trees = self.trees.write().unwrap(); - trees.0[tree_idx] = tree; + .open_partition(&name, PartitionCreateOptions::default())?; + trees.insert(tree_idx, (name, tree)); + Ok(()) } @@ -223,9 +214,9 @@ impl IDb for FjallDb { // ---- fn transaction(&self, f: &dyn ITxFn) -> TxResult { - let trees = self.trees.read().unwrap(); + let trees = self.trees.read(); let mut tx = FjallTx { - trees: &trees.0[..], + trees: &trees[..], tx: self.keyspace.write_tx(), }; @@ -252,13 +243,13 @@ impl IDb for FjallDb { // ---- struct FjallTx<'a> { - trees: &'a [TransactionalPartitionHandle], + trees: &'a [(String, TransactionalPartitionHandle)], tx: WriteTransaction<'a>, } impl<'a> FjallTx<'a> { fn get_tree(&self, i: usize) -> TxOpResult<&TransactionalPartitionHandle> { - self.trees.get(i).ok_or_else(|| { + self.trees.get(i).map(|tup| &tup.1).ok_or_else(|| { TxOpError(Error( "invalid tree id (it might have been openned after the transaction started)".into(), )) @@ -364,3 +355,78 @@ fn clone_bound(bound: Bound<&[u8]>) -> ByteVecBound { Bound::Unbounded => Bound::Unbounded, } } + +// -- utils to encode table names -- + +fn encode_name(s: &str) -> Result { + let base = 'A' as u32; + + let mut ret = String::with_capacity(s.len() + 10); + for c in s.chars() { + if c.is_alphanumeric() || c == '_' || c == '-' || c == '#' { + ret.push(c); + } else if c <= u8::MAX as char { + ret.push('$'); + let c_hi = c as u32 / 16; + let c_lo = c as u32 % 16; + ret.push(char::from_u32(base + c_hi).unwrap()); + ret.push(char::from_u32(base + c_lo).unwrap()); + } else { + return Err(Error( + format!("table name {} could not be safely encoded", s).into(), + )); + } + } + Ok(ret) +} + +fn decode_name(s: &str) -> Result { + use std::convert::TryFrom; + + let errfn = || Error(format!("encoded table name {} is invalid", s).into()); + let c_map = |c: char| { + let c = c as u32; + let base = 'A' as u32; + if (base..base + 16).contains(&c) { + Some(c - base) + } else { + None + } + }; + + let mut ret = String::with_capacity(s.len()); + let mut it = s.chars(); + while let Some(c) = it.next() { + if c == '$' { + let c_hi = it.next().and_then(c_map).ok_or_else(errfn)?; + let c_lo = it.next().and_then(c_map).ok_or_else(errfn)?; + let c_dec = char::try_from(c_hi * 16 + c_lo).map_err(|_| errfn())?; + ret.push(c_dec); + } else { + ret.push(c); + } + } + Ok(ret) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_encdec_name() { + for name in [ + "testname", + "test_name", + "test name", + "test$name", + "test:name@help.me$get/this**right", + ] { + let encname = encode_name(name).unwrap(); + assert!(!encname.contains(' ')); + assert!(!encname.contains('.')); + assert!(!encname.contains('*')); + assert_eq!(*name, decode_name(&encname).unwrap()); + } + } +} diff --git a/src/db/open.rs b/src/db/open.rs index 83ae1f93..fbd8d74a 100644 --- a/src/db/open.rs +++ b/src/db/open.rs @@ -1,6 +1,5 @@ use std::convert::TryInto; use std::path::PathBuf; -use std::sync::Arc; use crate::{Db, Error, Result}; @@ -128,13 +127,10 @@ pub fn open_db(path: &PathBuf, engine: Engine, opt: &OpenOpt) -> Result { let fsync_ms = opt.fsync.then(|| 1000 as u16); let mut config = fjall::Config::new(path).fsync_ms(fsync_ms); if let Some(block_cache_size) = opt.fjall_block_cache_size { - let block_cache = Arc::new(fjall::BlockCache::with_capacity_bytes( - block_cache_size.try_into().unwrap(), - )); - config = config.block_cache(block_cache); + config = config.cache_size(block_cache_size.try_into().unwrap()); } let keyspace = config.open_transactional()?; - Ok(crate::fjall_adapter::FjallDb::init(path, keyspace)) + Ok(crate::fjall_adapter::FjallDb::init(keyspace)) } // Pattern is unreachable when all supported DB engines are compiled into binary. The allow diff --git a/src/db/test.rs b/src/db/test.rs index 26b816b8..08ce1dda 100644 --- a/src/db/test.rs +++ b/src/db/test.rs @@ -1,7 +1,7 @@ use crate::*; fn test_suite(db: Db) { - let tree = db.open_tree("tree").unwrap(); + let tree = db.open_tree("tree:this_is_a_tree").unwrap(); let ka: &[u8] = &b"test"[..]; let kb: &[u8] = &b"zwello"[..]; @@ -148,3 +148,15 @@ fn test_sqlite_db() { let db = SqliteDb::new(manager, false).unwrap(); test_suite(db); } + +#[test] +#[cfg(feature = "fjall")] +fn test_fjall_db() { + use crate::fjall_adapter::{fjall, FjallDb}; + + let path = mktemp::Temp::new_dir().unwrap(); + let config = fjall::Config::new(path); + let keyspace = config.open_transactional().unwrap(); + let db = FjallDb::init(keyspace); + test_suite(db); +} From 6ea86db8cd7687a766679526f10cf1cb42ae00b2 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 27 Aug 2025 19:51:38 +0200 Subject: [PATCH 43/73] document fjall db engine, remove flakey metadata_fsync implementation --- doc/book/reference-manual/configuration.md | 10 ++++++++++ src/db/open.rs | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/book/reference-manual/configuration.md b/doc/book/reference-manual/configuration.md index 84aaf511..e134a83f 100644 --- a/doc/book/reference-manual/configuration.md +++ b/doc/book/reference-manual/configuration.md @@ -333,6 +333,7 @@ Since `v0.8.0`, Garage can use alternative storage backends as follows: | --------- | ----------------- | ------------- | | [LMDB](https://www.symas.com/lmdb) (since `v0.8.0`, default since `v0.9.0`) | `"lmdb"` | `/db.lmdb/` | | [Sqlite](https://sqlite.org) (since `v0.8.0`) | `"sqlite"` | `/db.sqlite` | +| [Fjall](https://github.com/fjall-rs/fjall) (**experimental support** since `v1.3.0`) | `"fjall"` | `/db.fjall/` | | [Sled](https://sled.rs) (old default, removed since `v1.0`) | `"sled"` | `/db/` | Sled was supported until Garage v0.9.x, and was removed in Garage v1.0. @@ -369,6 +370,14 @@ LMDB works very well, but is known to have the following limitations: so it is not the best choice for high-performance storage clusters, but it should work fine in many cases. +- Fjall: a storage engine based on LSM trees, which theoretically allow for + higher write throughput than other storage engines that are based on B-trees. + Using Fjall could potentially improve Garage's performance significantly in + write-heavy workloads. **Support for Fjall is experimental at this point**, + we have added it to Garage for evaluation purposes only. **Do not use it for + production-critical workloads.** + + It is possible to convert Garage's metadata directory from one format to another using the `garage convert-db` command, which should be used as follows: @@ -406,6 +415,7 @@ Here is how this option impacts the different database engines: |----------|------------------------------------|-------------------------------| | Sqlite | `PRAGMA synchronous = OFF` | `PRAGMA synchronous = NORMAL` | | LMDB | `MDB_NOMETASYNC` + `MDB_NOSYNC` | `MDB_NOMETASYNC` | +| Fjall | default options | not supported | Note that the Sqlite database is always ran in `WAL` mode (`PRAGMA journal_mode = WAL`). diff --git a/src/db/open.rs b/src/db/open.rs index fbd8d74a..d5469b58 100644 --- a/src/db/open.rs +++ b/src/db/open.rs @@ -124,8 +124,12 @@ pub fn open_db(path: &PathBuf, engine: Engine, opt: &OpenOpt) -> Result { #[cfg(feature = "fjall")] Engine::Fjall => { info!("Opening Fjall database at: {}", path.display()); - let fsync_ms = opt.fsync.then(|| 1000 as u16); - let mut config = fjall::Config::new(path).fsync_ms(fsync_ms); + if opt.fsync { + return Err(Error( + "metadata_fsync is not supported with the Fjall database engine".into(), + )); + } + let mut config = fjall::Config::new(path); if let Some(block_cache_size) = opt.fjall_block_cache_size { config = config.cache_size(block_cache_size.try_into().unwrap()); } From 90bba5889aeeadfcd895ce4a245c3010bdcad01c Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 27 Aug 2025 21:17:32 +0200 Subject: [PATCH 44/73] garage_db: rename len to approximate_len as it is used for stats only --- src/block/manager.rs | 6 +++--- src/block/metrics.rs | 6 +++--- src/block/resync.rs | 14 ++++++++------ src/db/fjall_adapter.rs | 8 ++++++-- src/db/lib.rs | 13 +++++++++---- src/db/lmdb_adapter.rs | 7 ++++++- src/db/sqlite_adapter.rs | 6 +++++- src/db/test.rs | 2 +- src/garage/admin/mod.rs | 19 ++++++++++++------- src/model/s3/lifecycle_worker.rs | 6 +++--- src/table/data.rs | 4 ++-- src/table/gc.rs | 2 +- src/table/merkle.rs | 10 +++++----- src/table/metrics.rs | 8 ++++---- src/table/queue.rs | 2 +- 15 files changed, 69 insertions(+), 44 deletions(-) diff --git a/src/block/manager.rs b/src/block/manager.rs index 41b2f02a..d1bf90d8 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -408,8 +408,8 @@ impl BlockManager { } /// Get number of items in the refcount table - pub fn rc_len(&self) -> Result { - Ok(self.rc.rc_table.len()?) + pub fn rc_approximate_len(&self) -> Result { + Ok(self.rc.rc_table.approximate_len()?) } /// Send command to start/stop/manager scrub worker @@ -427,7 +427,7 @@ impl BlockManager { /// List all resync errors pub fn list_resync_errors(&self) -> Result, Error> { - let mut blocks = Vec::with_capacity(self.resync.errors.len()?); + let mut blocks = Vec::with_capacity(self.resync.errors.approximate_len()?); for ent in self.resync.errors.iter()? { let (hash, cnt) = ent?; let cnt = ErrorCounter::decode(&cnt); diff --git a/src/block/metrics.rs b/src/block/metrics.rs index 2d41e365..c2ebb76b 100644 --- a/src/block/metrics.rs +++ b/src/block/metrics.rs @@ -50,7 +50,7 @@ impl BlockManagerMetrics { .init(), _rc_size: meter .u64_value_observer("block.rc_size", move |observer| { - if let Ok(value) = rc_tree.len() { + if let Ok(value) = rc_tree.approximate_len() { observer.observe(value as u64, &[]) } }) @@ -58,7 +58,7 @@ impl BlockManagerMetrics { .init(), _resync_queue_len: meter .u64_value_observer("block.resync_queue_length", move |observer| { - if let Ok(value) = resync_queue.len() { + if let Ok(value) = resync_queue.approximate_len() { observer.observe(value as u64, &[]); } }) @@ -68,7 +68,7 @@ impl BlockManagerMetrics { .init(), _resync_errored_blocks: meter .u64_value_observer("block.resync_errored_blocks", move |observer| { - if let Ok(value) = resync_errors.len() { + if let Ok(value) = resync_errors.approximate_len() { observer.observe(value as u64, &[]); } }) diff --git a/src/block/resync.rs b/src/block/resync.rs index b476a0b8..004f6b48 100644 --- a/src/block/resync.rs +++ b/src/block/resync.rs @@ -106,13 +106,13 @@ impl BlockResyncManager { } /// Get length of resync queue - pub fn queue_len(&self) -> Result { - Ok(self.queue.len()?) + pub fn queue_approximate_len(&self) -> Result { + Ok(self.queue.approximate_len()?) } /// Get number of blocks that have an error - pub fn errors_len(&self) -> Result { - Ok(self.errors.len()?) + pub fn errors_approximate_len(&self) -> Result { + Ok(self.errors.approximate_len()?) } /// Clear the error counter for a block and put it in queue immediately @@ -548,9 +548,11 @@ impl Worker for ResyncWorker { } WorkerStatus { - queue_length: Some(self.manager.resync.queue_len().unwrap_or(0) as u64), + queue_length: Some(self.manager.resync.queue_approximate_len().unwrap_or(0) as u64), tranquility: Some(tranquility), - persistent_errors: Some(self.manager.resync.errors_len().unwrap_or(0) as u64), + persistent_errors: Some( + self.manager.resync.errors_approximate_len().unwrap_or(0) as u64 + ), ..Default::default() } } diff --git a/src/db/fjall_adapter.rs b/src/db/fjall_adapter.rs index d91ef12f..d6a41e9e 100644 --- a/src/db/fjall_adapter.rs +++ b/src/db/fjall_adapter.rs @@ -132,10 +132,14 @@ impl IDb for FjallDb { } } - fn len(&self, tree_idx: usize) -> Result { + fn approximate_len(&self, tree_idx: usize) -> Result { + let tree = self.get_tree(tree_idx)?; + Ok(tree.approximate_len()) + } + fn is_empty(&self, tree_idx: usize) -> Result { let tree = self.get_tree(tree_idx)?; let tx = self.keyspace.read_tx(); - Ok(tx.len(&tree)?) + Ok(tx.is_empty(&tree)?) } fn insert(&self, tree_idx: usize, key: &[u8], value: &[u8]) -> Result<()> { diff --git a/src/db/lib.rs b/src/db/lib.rs index 3454c759..5ac16da8 100644 --- a/src/db/lib.rs +++ b/src/db/lib.rs @@ -154,7 +154,7 @@ impl Db { let tree_names = other.list_trees()?; for name in tree_names { let tree = self.open_tree(&name)?; - if tree.len()? > 0 { + if !tree.is_empty()? { return Err(Error(format!("tree {} already contains data", name).into())); } @@ -196,8 +196,12 @@ impl Tree { self.0.get(self.1, key.as_ref()) } #[inline] - pub fn len(&self) -> Result { - self.0.len(self.1) + pub fn approximate_len(&self) -> Result { + self.0.approximate_len(self.1) + } + #[inline] + pub fn is_empty(&self) -> Result { + self.0.is_empty(self.1) } #[inline] @@ -335,7 +339,8 @@ pub(crate) trait IDb: Send + Sync { fn snapshot(&self, path: &PathBuf) -> Result<()>; fn get(&self, tree: usize, key: &[u8]) -> Result>; - fn len(&self, tree: usize) -> Result; + fn approximate_len(&self, tree: usize) -> Result; + fn is_empty(&self, tree: usize) -> Result; fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<()>; fn remove(&self, tree: usize, key: &[u8]) -> Result<()>; diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs index bd85f1b4..cbbce2f8 100644 --- a/src/db/lmdb_adapter.rs +++ b/src/db/lmdb_adapter.rs @@ -126,11 +126,16 @@ impl IDb for LmdbDb { } } - fn len(&self, tree: usize) -> Result { + fn approximate_len(&self, tree: usize) -> Result { let tree = self.get_tree(tree)?; let tx = self.db.read_txn()?; Ok(tree.len(&tx)?.try_into().unwrap()) } + fn is_empty(&self, tree: usize) -> Result { + let tree = self.get_tree(tree)?; + let tx = self.db.read_txn()?; + Ok(tree.is_empty(&tx)?) + } fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> { let tree = self.get_tree(tree)?; diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index ce6412b6..eee8b15d 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -160,7 +160,7 @@ impl IDb for SqliteDb { self.internal_get(&self.db.get()?, &tree, key) } - fn len(&self, tree: usize) -> Result { + fn approximate_len(&self, tree: usize) -> Result { let tree = self.get_tree(tree)?; let db = self.db.get()?; @@ -172,6 +172,10 @@ impl IDb for SqliteDb { } } + fn is_empty(&self, tree: usize) -> Result { + Ok(self.approximate_len(tree)? == 0) + } + fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> { let tree = self.get_tree(tree)?; let db = self.db.get()?; diff --git a/src/db/test.rs b/src/db/test.rs index 08ce1dda..1e649719 100644 --- a/src/db/test.rs +++ b/src/db/test.rs @@ -14,7 +14,7 @@ fn test_suite(db: Db) { assert!(tree.insert(ka, va).is_ok()); assert_eq!(tree.get(ka).unwrap().unwrap(), va); - assert_eq!(tree.len().unwrap(), 1); + assert_eq!(tree.iter().unwrap().count(), 1); // ---- test transaction logic ---- diff --git a/src/garage/admin/mod.rs b/src/garage/admin/mod.rs index 3bbc2b86..6ae8fa88 100644 --- a/src/garage/admin/mod.rs +++ b/src/garage/admin/mod.rs @@ -219,7 +219,7 @@ impl AdminRpcHandler { // Gather block manager statistics writeln!(&mut ret, "\nBlock manager stats:").unwrap(); - let rc_len = self.garage.block_manager.rc_len()?.to_string(); + let rc_len = self.garage.block_manager.rc_approximate_len()?.to_string(); writeln!( &mut ret, @@ -230,13 +230,13 @@ impl AdminRpcHandler { writeln!( &mut ret, " resync queue length: {}", - self.garage.block_manager.resync.queue_len()? + self.garage.block_manager.resync.queue_approximate_len()? ) .unwrap(); writeln!( &mut ret, " blocks with resync errors: {}", - self.garage.block_manager.resync.errors_len()? + self.garage.block_manager.resync.errors_approximate_len()? ) .unwrap(); @@ -346,16 +346,21 @@ impl AdminRpcHandler { F: TableSchema + 'static, R: TableReplication + 'static, { - let data_len = t.data.store.len().map_err(GarageError::from)?.to_string(); - let mkl_len = t.merkle_updater.merkle_tree_len()?.to_string(); + let data_len = t + .data + .store + .approximate_len() + .map_err(GarageError::from)? + .to_string(); + let mkl_len = t.merkle_updater.merkle_tree_approximate_len()?.to_string(); Ok(format!( " {}\t{}\t{}\t{}\t{}", F::TABLE_NAME, data_len, mkl_len, - t.merkle_updater.todo_len()?, - t.data.gc_todo_len()? + t.merkle_updater.todo_approximate_len()?, + t.data.gc_todo_approximate_len()? )) } diff --git a/src/model/s3/lifecycle_worker.rs b/src/model/s3/lifecycle_worker.rs index bb10ba48..af00437e 100644 --- a/src/model/s3/lifecycle_worker.rs +++ b/src/model/s3/lifecycle_worker.rs @@ -121,13 +121,13 @@ impl Worker for LifecycleWorker { mpu_aborted, .. } => { - let n_objects = self.garage.object_table.data.store.len().ok(); + let n_objects = self.garage.object_table.data.store.approximate_len().ok(); let progress = match n_objects { - None => "...".to_string(), - Some(total) => format!( + Some(total) if total > 0 => format!( "~{:.2}%", 100. * std::cmp::min(*counter, total) as f32 / total as f32 ), + _ => "...".to_string(), }; WorkerStatus { progress: Some(progress), diff --git a/src/table/data.rs b/src/table/data.rs index 09f4e008..1d0308ce 100644 --- a/src/table/data.rs +++ b/src/table/data.rs @@ -367,7 +367,7 @@ impl TableData { } } - pub fn gc_todo_len(&self) -> Result { - Ok(self.gc_todo.len()?) + pub fn gc_todo_approximate_len(&self) -> Result { + Ok(self.gc_todo.approximate_len()?) } } diff --git a/src/table/gc.rs b/src/table/gc.rs index 28ea119d..1f30bd76 100644 --- a/src/table/gc.rs +++ b/src/table/gc.rs @@ -313,7 +313,7 @@ impl Worker for GcWorker { fn status(&self) -> WorkerStatus { WorkerStatus { - queue_length: Some(self.gc.data.gc_todo_len().unwrap_or(0) as u64), + queue_length: Some(self.gc.data.gc_todo_approximate_len().unwrap_or(0) as u64), ..Default::default() } } diff --git a/src/table/merkle.rs b/src/table/merkle.rs index 596d5805..7ba1f007 100644 --- a/src/table/merkle.rs +++ b/src/table/merkle.rs @@ -287,12 +287,12 @@ impl MerkleUpdater { MerkleNode::decode_opt(&ent) } - pub fn merkle_tree_len(&self) -> Result { - Ok(self.data.merkle_tree.len()?) + pub fn merkle_tree_approximate_len(&self) -> Result { + Ok(self.data.merkle_tree.approximate_len()?) } - pub fn todo_len(&self) -> Result { - Ok(self.data.merkle_todo.len()?) + pub fn todo_approximate_len(&self) -> Result { + Ok(self.data.merkle_todo.approximate_len()?) } } @@ -306,7 +306,7 @@ impl Worker for MerkleWorker { fn status(&self) -> WorkerStatus { WorkerStatus { - queue_length: Some(self.0.todo_len().unwrap_or(0) as u64), + queue_length: Some(self.0.todo_approximate_len().unwrap_or(0) as u64), ..Default::default() } } diff --git a/src/table/metrics.rs b/src/table/metrics.rs index 7bb0959a..78593202 100644 --- a/src/table/metrics.rs +++ b/src/table/metrics.rs @@ -34,7 +34,7 @@ impl TableMetrics { .u64_value_observer( "table.size", move |observer| { - if let Ok(value) = store.len() { + if let Ok(value) = store.approximate_len() { observer.observe( value as u64, &[KeyValue::new("table_name", table_name)], @@ -48,7 +48,7 @@ impl TableMetrics { .u64_value_observer( "table.merkle_tree_size", move |observer| { - if let Ok(value) = merkle_tree.len() { + if let Ok(value) = merkle_tree.approximate_len() { observer.observe( value as u64, &[KeyValue::new("table_name", table_name)], @@ -62,7 +62,7 @@ impl TableMetrics { .u64_value_observer( "table.merkle_updater_todo_queue_length", move |observer| { - if let Ok(v) = merkle_todo.len() { + if let Ok(v) = merkle_todo.approximate_len() { observer.observe( v as u64, &[KeyValue::new("table_name", table_name)], @@ -76,7 +76,7 @@ impl TableMetrics { .u64_value_observer( "table.gc_todo_queue_length", move |observer| { - if let Ok(value) = gc_todo.len() { + if let Ok(value) = gc_todo.approximate_len() { observer.observe( value as u64, &[KeyValue::new("table_name", table_name)], diff --git a/src/table/queue.rs b/src/table/queue.rs index ffe0a4a7..7ef1f16e 100644 --- a/src/table/queue.rs +++ b/src/table/queue.rs @@ -27,7 +27,7 @@ impl Worker for InsertQueueWorker { fn status(&self) -> WorkerStatus { WorkerStatus { - queue_length: Some(self.0.data.insert_queue.len().unwrap_or(0) as u64), + queue_length: Some(self.0.data.insert_queue.approximate_len().unwrap_or(0) as u64), ..Default::default() } } From 54b9bf02a34612e227920693730cf45d2bb7fa14 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 27 Aug 2025 23:03:09 +0200 Subject: [PATCH 45/73] garage_db: refactor open function --- src/db/fjall_adapter.rs | 25 +++++++++++-- src/db/lmdb_adapter.rs | 50 +++++++++++++++++++++++-- src/db/open.rs | 81 +++++++++++----------------------------- src/db/sqlite_adapter.rs | 21 +++++++++-- src/db/test.rs | 2 +- src/model/garage.rs | 13 +------ 6 files changed, 107 insertions(+), 85 deletions(-) diff --git a/src/db/fjall_adapter.rs b/src/db/fjall_adapter.rs index d6a41e9e..25913a1f 100644 --- a/src/db/fjall_adapter.rs +++ b/src/db/fjall_adapter.rs @@ -11,12 +11,30 @@ use fjall::{ }; use crate::{ + open::{Engine, OpenOpt}, Db, Error, IDb, ITx, ITxFn, OnCommit, Result, TxError, TxFnResult, TxOpError, TxOpResult, TxResult, TxValueIter, Value, ValueIter, }; pub use fjall; +// -- + +pub(crate) fn open_db(path: &PathBuf, opt: &OpenOpt) -> Result { + info!("Opening Fjall database at: {}", path.display()); + if opt.fsync { + return Err(Error( + "metadata_fsync is not supported with the Fjall database engine".into(), + )); + } + let mut config = fjall::Config::new(path); + if let Some(block_cache_size) = opt.fjall_block_cache_size { + config = config.cache_size(block_cache_size as u64); + } + let keyspace = config.open_transactional()?; + Ok(FjallDb::init(keyspace)) +} + // -- err impl From for Error { @@ -95,10 +113,9 @@ impl IDb for FjallDb { .collect::>>()?) } - fn snapshot(&self, to: &PathBuf) -> Result<()> { - std::fs::create_dir_all(to)?; - let mut path = to.clone(); - path.push("data.fjall"); + fn snapshot(&self, base_path: &PathBuf) -> Result<()> { + std::fs::create_dir_all(base_path)?; + let path = Engine::Fjall.db_path(base_path); let source_state = self.keyspace.read_tx(); let copy_keyspace = fjall::Config::new(path).open()?; diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs index cbbce2f8..ac185ae9 100644 --- a/src/db/lmdb_adapter.rs +++ b/src/db/lmdb_adapter.rs @@ -11,12 +11,55 @@ use heed::types::ByteSlice; use heed::{BytesDecode, Env, RoTxn, RwTxn, UntypedDatabase as Database}; use crate::{ + open::{Engine, OpenOpt}, Db, Error, IDb, ITx, ITxFn, OnCommit, Result, TxError, TxFnResult, TxOpError, TxOpResult, TxResult, TxValueIter, Value, ValueIter, }; pub use heed; +// ---- top-level open function + +pub(crate) fn open_db(path: &PathBuf, opt: &OpenOpt) -> Result { + info!("Opening LMDB database at: {}", path.display()); + if let Err(e) = std::fs::create_dir_all(&path) { + return Err(Error( + format!("Unable to create LMDB data directory: {}", e).into(), + )); + } + + let map_size = match opt.lmdb_map_size { + None => recommended_map_size(), + Some(v) => v - (v % 4096), + }; + + let mut env_builder = heed::EnvOpenOptions::new(); + env_builder.max_dbs(100); + env_builder.map_size(map_size); + env_builder.max_readers(2048); + unsafe { + env_builder.flag(heed::flags::Flags::MdbNoRdAhead); + env_builder.flag(heed::flags::Flags::MdbNoMetaSync); + if !opt.fsync { + env_builder.flag(heed::flags::Flags::MdbNoSync); + } + } + match env_builder.open(&path) { + Err(heed::Error::Io(e)) if e.kind() == std::io::ErrorKind::OutOfMemory => { + return Err(Error( + "OutOfMemory error while trying to open LMDB database. This can happen \ + if your operating system is not allowing you to use sufficient virtual \ + memory address space. Please check that no limit is set (ulimit -v). \ + You may also try to set a smaller `lmdb_map_size` configuration parameter. \ + On 32-bit machines, you should probably switch to another database engine." + .into(), + )) + } + Err(e) => Err(Error(format!("Cannot open LMDB database: {}", e).into())), + Ok(db) => Ok(LmdbDb::init(db)), + } +} + // -- err impl From for Error { @@ -104,10 +147,9 @@ impl IDb for LmdbDb { Ok(ret2) } - fn snapshot(&self, to: &PathBuf) -> Result<()> { - std::fs::create_dir_all(to)?; - let mut path = to.clone(); - path.push("data.mdb"); + fn snapshot(&self, base_path: &PathBuf) -> Result<()> { + std::fs::create_dir_all(base_path)?; + let path = Engine::Lmdb.db_path(base_path); self.db .copy_to_path(path, heed::CompactionOption::Enabled)?; Ok(()) diff --git a/src/db/open.rs b/src/db/open.rs index d5469b58..23391c61 100644 --- a/src/db/open.rs +++ b/src/db/open.rs @@ -1,4 +1,3 @@ -use std::convert::TryInto; use std::path::PathBuf; use crate::{Db, Error, Result}; @@ -24,6 +23,23 @@ impl Engine { Self::Fjall => "fjall", } } + + /// Return engine-specific DB path from base path + pub fn db_path(&self, base_path: &PathBuf) -> PathBuf { + let mut ret = base_path.clone(); + match self { + Self::Lmdb => { + ret.push("db.lmdb"); + } + Self::Sqlite => { + ret.push("db.sqlite"); + } + Self::Fjall => { + ret.push("db.fjall"); + } + } + ret + } } impl std::fmt::Display for Engine { @@ -43,7 +59,7 @@ impl std::str::FromStr for Engine { "sled" => Err(Error("Sled is no longer supported as a database engine. Converting your old metadata db can be done using an older Garage binary (e.g. v0.9.4).".into())), kind => Err(Error( format!( - "Invalid DB engine: {} (options are: lmdb, sqlite)", + "Invalid DB engine: {} (options are: lmdb, sqlite, fjall)", kind ) .into(), @@ -72,70 +88,15 @@ pub fn open_db(path: &PathBuf, engine: Engine, opt: &OpenOpt) -> Result { match engine { // ---- Sqlite DB ---- #[cfg(feature = "sqlite")] - Engine::Sqlite => { - info!("Opening Sqlite database at: {}", path.display()); - let manager = r2d2_sqlite::SqliteConnectionManager::file(path); - Ok(crate::sqlite_adapter::SqliteDb::new(manager, opt.fsync)?) - } + Engine::Sqlite => crate::sqlite_adapter::open_db(path, opt), // ---- LMDB DB ---- #[cfg(feature = "lmdb")] - Engine::Lmdb => { - info!("Opening LMDB database at: {}", path.display()); - if let Err(e) = std::fs::create_dir_all(&path) { - return Err(Error( - format!("Unable to create LMDB data directory: {}", e).into(), - )); - } - - let map_size = match opt.lmdb_map_size { - None => crate::lmdb_adapter::recommended_map_size(), - Some(v) => v - (v % 4096), - }; - - let mut env_builder = heed::EnvOpenOptions::new(); - env_builder.max_dbs(100); - env_builder.map_size(map_size); - env_builder.max_readers(2048); - unsafe { - env_builder.flag(crate::lmdb_adapter::heed::flags::Flags::MdbNoRdAhead); - env_builder.flag(crate::lmdb_adapter::heed::flags::Flags::MdbNoMetaSync); - if !opt.fsync { - env_builder.flag(heed::flags::Flags::MdbNoSync); - } - } - match env_builder.open(&path) { - Err(heed::Error::Io(e)) if e.kind() == std::io::ErrorKind::OutOfMemory => { - return Err(Error( - "OutOfMemory error while trying to open LMDB database. This can happen \ - if your operating system is not allowing you to use sufficient virtual \ - memory address space. Please check that no limit is set (ulimit -v). \ - You may also try to set a smaller `lmdb_map_size` configuration parameter. \ - On 32-bit machines, you should probably switch to another database engine." - .into(), - )) - } - Err(e) => Err(Error(format!("Cannot open LMDB database: {}", e).into())), - Ok(db) => Ok(crate::lmdb_adapter::LmdbDb::init(db)), - } - } + Engine::Lmdb => crate::lmdb_adapter::open_db(path, opt), // ---- Fjall DB ---- #[cfg(feature = "fjall")] - Engine::Fjall => { - info!("Opening Fjall database at: {}", path.display()); - if opt.fsync { - return Err(Error( - "metadata_fsync is not supported with the Fjall database engine".into(), - )); - } - let mut config = fjall::Config::new(path); - if let Some(block_cache_size) = opt.fjall_block_cache_size { - config = config.cache_size(block_cache_size.try_into().unwrap()); - } - let keyspace = config.open_transactional()?; - Ok(crate::fjall_adapter::FjallDb::init(keyspace)) - } + Engine::Fjall => crate::fjall_adapter::open_db(path, opt), // Pattern is unreachable when all supported DB engines are compiled into binary. The allow // attribute is added so that we won't have to change this match in case stop building diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index eee8b15d..5d86f178 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -11,12 +11,23 @@ use r2d2_sqlite::SqliteConnectionManager; use rusqlite::{params, Rows, Statement, Transaction}; use crate::{ + open::{Engine, OpenOpt}, Db, Error, IDb, ITx, ITxFn, OnCommit, Result, TxError, TxFnResult, TxOpError, TxOpResult, TxResult, TxValueIter, Value, ValueIter, }; pub use rusqlite; +// ---- top-level open function + +pub(crate) fn open_db(path: &PathBuf, opt: &OpenOpt) -> Result { + info!("Opening Sqlite database at: {}", path.display()); + let manager = r2d2_sqlite::SqliteConnectionManager::file(path); + Ok(SqliteDb::new(manager, opt.fsync)?) +} + +// ---- + type Connection = r2d2::PooledConnection; // --- err @@ -139,17 +150,19 @@ impl IDb for SqliteDb { Ok(trees) } - fn snapshot(&self, to: &PathBuf) -> Result<()> { + fn snapshot(&self, base_path: &PathBuf) -> Result<()> { fn progress(p: rusqlite::backup::Progress) { let percent = (p.pagecount - p.remaining) * 100 / p.pagecount; info!("Sqlite snapshot progress: {}%", percent); } - std::fs::create_dir_all(to)?; - let mut path = to.clone(); - path.push("db.sqlite"); + + std::fs::create_dir_all(base_path)?; + let path = Engine::Sqlite.db_path(&base_path); + self.db .get()? .backup(rusqlite::DatabaseName::Main, path, Some(progress))?; + Ok(()) } diff --git a/src/db/test.rs b/src/db/test.rs index 1e649719..977dc965 100644 --- a/src/db/test.rs +++ b/src/db/test.rs @@ -155,7 +155,7 @@ fn test_fjall_db() { use crate::fjall_adapter::{fjall, FjallDb}; let path = mktemp::Temp::new_dir().unwrap(); - let config = fjall::Config::new(path); + let config = fjall::Config::new(path).temporary(true); let keyspace = config.open_transactional().unwrap(); let db = FjallDb::init(keyspace); test_suite(db); diff --git a/src/model/garage.rs b/src/model/garage.rs index 7420e740..38f8f1f7 100644 --- a/src/model/garage.rs +++ b/src/model/garage.rs @@ -116,18 +116,7 @@ impl Garage { info!("Opening database..."); let db_engine = db::Engine::from_str(&config.db_engine) .ok_or_message("Invalid `db_engine` value in configuration file")?; - let mut db_path = config.metadata_dir.clone(); - match db_engine { - db::Engine::Sqlite => { - db_path.push("db.sqlite"); - } - db::Engine::Lmdb => { - db_path.push("db.lmdb"); - } - db::Engine::Fjall => { - db_path.push("db.fjall"); - } - } + let db_path = db_engine.db_path(&config.metadata_dir); let db_opt = db::OpenOpt { fsync: config.metadata_fsync, lmdb_map_size: match config.lmdb_map_size { From c8c20d6f471a4263c187b778582e6df2bd7a08b3 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 28 Aug 2025 00:07:35 +0200 Subject: [PATCH 46/73] garage_db: reduce frequency of sqlite snapshot progress log (fix #1129) --- src/db/sqlite_adapter.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index 5d86f178..d645c64e 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -152,8 +152,21 @@ impl IDb for SqliteDb { fn snapshot(&self, base_path: &PathBuf) -> Result<()> { fn progress(p: rusqlite::backup::Progress) { - let percent = (p.pagecount - p.remaining) * 100 / p.pagecount; - info!("Sqlite snapshot progress: {}%", percent); + use std::sync::atomic::{AtomicU64, Ordering}; + use std::time::{SystemTime, UNIX_EPOCH}; + + static LAST_LOG_TIME: AtomicU64 = AtomicU64::new(0); + + let now = SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("Fix your clock :o") + .as_millis() as u64; + if now >= LAST_LOG_TIME.load(Ordering::Relaxed) + 10 * 1000 { + let percent = (p.pagecount - p.remaining) * 100 / p.pagecount; + info!("Sqlite snapshot progress: {}%", percent); + + LAST_LOG_TIME.fetch_max(now, Ordering::Relaxed); + } } std::fs::create_dir_all(base_path)?; From c8599a86360e72a40e0d8ada3e7b5802e943fe9e Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 4 Sep 2025 11:06:46 +0200 Subject: [PATCH 47/73] woodpecker: require the nix=enabled label --- .woodpecker/debug.yaml | 3 +++ .woodpecker/publish.yaml | 3 +++ .woodpecker/release.yaml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.woodpecker/debug.yaml b/.woodpecker/debug.yaml index 62266aa4..4c729672 100644 --- a/.woodpecker/debug.yaml +++ b/.woodpecker/debug.yaml @@ -1,3 +1,6 @@ +labels: + nix: "enabled" + when: event: - push diff --git a/.woodpecker/publish.yaml b/.woodpecker/publish.yaml index 7522d58d..24a84463 100644 --- a/.woodpecker/publish.yaml +++ b/.woodpecker/publish.yaml @@ -1,3 +1,6 @@ +labels: + nix: "enabled" + when: event: - deployment diff --git a/.woodpecker/release.yaml b/.woodpecker/release.yaml index 0678a45b..bf2bd8ba 100644 --- a/.woodpecker/release.yaml +++ b/.woodpecker/release.yaml @@ -1,3 +1,6 @@ +labels: + nix: "enabled" + when: event: - deployment From 5cf354acb44872e782ff51b9da59df2838aa12f6 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 13 Sep 2025 17:38:06 +0200 Subject: [PATCH 48/73] block: maximum number of simultaneous reads --- doc/book/reference-manual/configuration.md | 25 ++++++++++++++++++++++ src/block/manager.rs | 16 ++++++++++++++ src/block/metrics.rs | 6 ++++++ src/util/config.rs | 7 ++++++ 4 files changed, 54 insertions(+) diff --git a/doc/book/reference-manual/configuration.md b/doc/book/reference-manual/configuration.md index e134a83f..c6dce089 100644 --- a/doc/book/reference-manual/configuration.md +++ b/doc/book/reference-manual/configuration.md @@ -24,6 +24,7 @@ db_engine = "lmdb" block_size = "1M" block_ram_buffer_max = "256MiB" +block_max_concurrent_reads = 16 lmdb_map_size = "1T" @@ -96,6 +97,7 @@ The following gives details about each available configuration option. Top-level configuration options, in alphabetical order: [`allow_punycode`](#allow_punycode), [`allow_world_readable_secrets`](#allow_world_readable_secrets), +[`block_max_concurrent_reads`](`block_max_concurrent_reads), [`block_ram_buffer_max`](#block_ram_buffer_max), [`block_size`](#block_size), [`bootstrap_peers`](#bootstrap_peers), @@ -522,6 +524,29 @@ node. The default value is 256MiB. +#### `block_max_concurrent_reads` (since `v1.3.0` / `v2.1.0`) {#block_max_concurrent_reads} + +The maximum number of blocks (individual files in the data directory) open +simultaneously for reading. + +Reducing this number does not limit the number of data blocks that can be +transferred through the network simultaneously. This mechanism was just added +as a backpressure mechanism for HDD read speed: it helps avoid a situation +where too many requests are coming in and Garage is reading too many block +files simultaneously, thus not making timely progress on any of the reads. + +When a request to read a data block comes in through the network, the requests +awaits for one of the `block_max_concurrent_reads` slots to be available +(internally implemented using a Semaphore object). Once it acquired a read +slot, it reads the entire block file to RAM and frees the slot as soon as the +block file is finished reading. Only after the slot is released will the +block's data start being transferred over the network. If the request fails to +acquire a reading slot wihtin 15 seconds, it fails with a timeout error. +Timeout events can be monitored through the `block_read_semaphore_timeouts` +metric in Prometheus: a non-zero number of such events indicates an I/O +bottleneck on HDD read speed. + + #### `lmdb_map_size` {#lmdb_map_size} This parameters can be used to set the map size used by LMDB, diff --git a/src/block/manager.rs b/src/block/manager.rs index d1bf90d8..5ff9a138 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -50,6 +50,8 @@ pub const INLINE_THRESHOLD: usize = 3072; // to delete the block locally. pub(crate) const BLOCK_GC_DELAY: Duration = Duration::from_secs(600); +const BLOCK_READ_SEMAPHORE_TIMEOUT: Duration = Duration::from_secs(15); + /// RPC messages used to share blocks of data between nodes #[derive(Debug, Serialize, Deserialize)] pub enum BlockRpc { @@ -87,6 +89,7 @@ pub struct BlockManager { disable_scrub: bool, mutation_lock: Vec>, + read_semaphore: Semaphore, pub rc: BlockRc, pub resync: BlockResyncManager, @@ -176,6 +179,8 @@ impl BlockManager { .iter() .map(|_| Mutex::new(BlockManagerLocked())) .collect::>(), + + read_semaphore: Semaphore::new(config.block_max_concurrent_reads), rc, resync, system, @@ -581,6 +586,15 @@ impl BlockManager { ) -> Result { let (header, path) = block_path.as_parts_ref(); + let permit = tokio::select! { + sem = self.read_semaphore.acquire() => sem.ok_or_message("acquire read semaphore")?, + _ = tokio::time::sleep(BLOCK_READ_SEMAPHORE_TIMEOUT) => { + self.metrics.block_read_semaphore_timeouts.add(1); + debug!("read block {:?}: read_semaphore acquire timeout", hash); + return Err(Error::Message("read block: read_semaphore acquire timeout".into())); + } + }; + let mut f = fs::File::open(&path).await?; let mut data = vec![]; f.read_to_end(&mut data).await?; @@ -605,6 +619,8 @@ impl BlockManager { return Err(Error::CorruptData(*hash)); } + drop(permit); + Ok(data) } diff --git a/src/block/metrics.rs b/src/block/metrics.rs index c2ebb76b..81021fe1 100644 --- a/src/block/metrics.rs +++ b/src/block/metrics.rs @@ -22,6 +22,7 @@ pub struct BlockManagerMetrics { pub(crate) bytes_read: BoundCounter, pub(crate) block_read_duration: BoundValueRecorder, + pub(crate) block_read_semaphore_timeouts: BoundCounter, pub(crate) bytes_written: BoundCounter, pub(crate) block_write_duration: BoundValueRecorder, pub(crate) delete_counter: BoundCounter, @@ -119,6 +120,11 @@ impl BlockManagerMetrics { .with_description("Duration of block read operations") .init() .bind(&[]), + block_read_semaphore_timeouts: meter + .u64_counter("block.read_semaphore_timeouts") + .with_description("Number of block reads that failed due to semaphore acquire timeout") + .init() + .bind(&[]), bytes_written: meter .u64_counter("block.bytes_written") .with_description("Number of bytes written to disk") diff --git a/src/util/config.rs b/src/util/config.rs index 19c3e821..e351185f 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -75,6 +75,10 @@ pub struct Config { )] pub block_ram_buffer_max: usize, + /// Maximum number of concurrent reads of block files on disk + #[serde(default = "default_block_max_concurrent_reads")] + pub block_max_concurrent_reads: usize, + /// Skip the permission check of secret files. Useful when /// POSIX ACLs (or more complex chmods) are used. #[serde(default)] @@ -280,6 +284,9 @@ fn default_block_size() -> usize { fn default_block_ram_buffer_max() -> usize { 256 * 1024 * 1024 } +fn default_block_max_concurrent_reads() -> usize { + 16 +} fn default_consistency_mode() -> String { "consistent".into() From d5a57e3e130841f83fafeb973f4d13777b3f40d3 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 13 Sep 2025 17:38:23 +0200 Subject: [PATCH 49/73] block: read_block: don't add not found blocks to resync queue --- src/block/manager.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/block/manager.rs b/src/block/manager.rs index 5ff9a138..06cf9cbe 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -562,9 +562,6 @@ impl BlockManager { match self.find_block(hash).await { Some(p) => self.read_block_from(hash, &p).await, None => { - // Not found but maybe we should have had it ?? - self.resync - .put_to_resync(hash, 2 * self.system.rpc_helper().rpc_timeout())?; return Err(Error::Message(format!( "block {:?} not found on node", hash From 6cf6db5c6141e062560396086e7c6c80633f934c Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 13 Sep 2025 17:49:25 +0200 Subject: [PATCH 50/73] fix panic when cluster_layout cannot be saved (fix #1150) --- src/rpc/layout/manager.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/rpc/layout/manager.rs b/src/rpc/layout/manager.rs index 21907ec7..bb8000bd 100644 --- a/src/rpc/layout/manager.rs +++ b/src/rpc/layout/manager.rs @@ -229,13 +229,11 @@ impl LayoutManager { } /// Save cluster layout data to disk - async fn save_cluster_layout(&self) -> Result<(), Error> { + async fn save_cluster_layout(&self) { let layout = self.layout.read().unwrap().inner().clone(); - self.persist_cluster_layout - .save_async(&layout) - .await - .expect("Cannot save current cluster layout"); - Ok(()) + if let Err(e) = self.persist_cluster_layout.save_async(&layout).await { + error!("Failed to save cluster_layout: {}", e); + } } fn broadcast_update(self: &Arc, rpc: SystemRpc) { @@ -313,7 +311,7 @@ impl LayoutManager { self.change_notify.notify_waiters(); self.broadcast_update(SystemRpc::AdvertiseClusterLayout(new_layout)); - self.save_cluster_layout().await?; + self.save_cluster_layout().await; } Ok(SystemRpc::Ok) @@ -328,7 +326,7 @@ impl LayoutManager { if let Some(new_trackers) = self.merge_layout_trackers(trackers) { self.change_notify.notify_waiters(); self.broadcast_update(SystemRpc::AdvertiseClusterLayoutTrackers(new_trackers)); - self.save_cluster_layout().await?; + self.save_cluster_layout().await; } Ok(SystemRpc::Ok) From 4c895a71862717ac0eed992d90a5cbd49508c430 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 14 Sep 2025 18:03:23 +0200 Subject: [PATCH 51/73] garage_db: fix error handling logic (fix #1138) --- src/db/lib.rs | 62 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/src/db/lib.rs b/src/db/lib.rs index 5ac16da8..71826255 100644 --- a/src/db/lib.rs +++ b/src/db/lib.rs @@ -106,32 +106,44 @@ impl Db { result: Cell::new(None), }; let tx_res = self.0.transaction(&f); - let ret = f - .result - .into_inner() - .expect("Transaction did not store result"); + let fn_res = f.result.into_inner(); - match tx_res { - Ok(on_commit) => match ret { - Ok(value) => { - on_commit.into_iter().for_each(|f| f()); - Ok(value) - } - _ => unreachable!(), - }, - Err(TxError::Abort(())) => match ret { - Err(TxError::Abort(e)) => Err(TxError::Abort(e)), - _ => unreachable!(), - }, - Err(TxError::Db(e2)) => match ret { - // Ok was stored -> the error occurred when finalizing - // transaction - Ok(_) => Err(TxError::Db(e2)), - // An error was already stored: that's the one we want to - // return - Err(TxError::Db(e)) => Err(TxError::Db(e)), - _ => unreachable!(), - }, + match (tx_res, fn_res) { + (Ok(on_commit), Some(Ok(value))) => { + // Transaction succeeded + // TxFn stored the value to return to the user in fn_res + // tx_res contains the on_commit list of callbacks, run them now + on_commit.into_iter().for_each(|f| f()); + Ok(value) + } + (Err(TxError::Abort(())), Some(Err(TxError::Abort(e)))) => { + // Transaction was aborted by user code + // The abort error value is stored in fn_res + Err(TxError::Abort(e)) + } + (Err(TxError::Db(_tx_e)), Some(Err(TxError::Db(fn_e)))) => { + // Transaction encountered a DB error in user code + // The error value encountered is the one in fn_res, + // tx_res contains only a dummy error message + Err(TxError::Db(fn_e)) + } + (Err(TxError::Db(tx_e)), None) => { + // Transaction encounterred a DB error when initializing the transaction, + // before user code was called + Err(TxError::Db(tx_e)) + } + (Err(TxError::Db(tx_e)), Some(Ok(_))) => { + // Transaction encounterred a DB error when commiting the transaction, + // after user code was called + Err(TxError::Db(tx_e)) + } + (tx_res, fn_res) => { + panic!( + "unexpected error case: tx_res={:?}, fn_res={:?}", + tx_res.map(|_| "..."), + fn_res.map(|x| x.map(|_| "...").map_err(|_| "...")) + ); + } } } From 60b1d78b562f5eb3fa6a81faee943d2207f9f4ef Mon Sep 17 00:00:00 2001 From: Lapineige Date: Fri, 1 Aug 2025 21:55:00 +0000 Subject: [PATCH 52/73] Add Plakar documentation --- doc/book/connect/backup.md | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/doc/book/connect/backup.md b/doc/book/connect/backup.md index f39cc3b6..7e97d777 100644 --- a/doc/book/connect/backup.md +++ b/doc/book/connect/backup.md @@ -161,3 +161,49 @@ kopia repository validate-provider You can then run all the standard kopia commands: `kopia snapshot create`, `kopia mount`... Everything should work out-of-the-box. + +## Plakar + +Create your key and bucket on Garage server: + +```bash +garage key create my-plakar-key +garage bucket create plakar-backups +garage bucket allow plakar-backups --read --write --key my-plakar-key +… +``` + +On Plakar server, add your Garage as a storage location: +```bash +plakar store add garageS3 s3://my-garage.tld/plakar-backups \ +region=garage # Or as you've specified in garage.toml \ +access_key= \ +secret_access_key= +``` + +Then create the repository. +```bash +plakar at @garageS3 create -plaintext # Unencrypted +# or +plakar at @garageS3 create #encrypted +``` + +If you encrypt your backups (Plakar default), you will need to define a strong passphrase. Do not forget to save your password safely. It will be needed to decrypt your backups. + + +After the repository has been created, check that everything works as expected (that might give an empty result as no file has been added yet, but no error message): +```bash +plakar at @garageS3 check +``` + +Now that everything is configure, you can use Garage as your backups storage. For instance sync it with a local backup storage: +```bash +$ plakar at ~/backups sync to @garageS3 +``` + +Or list the S3 storage content: +```bash +$ plakar at @garageS3 ls +``` + +More information in Plakar documentation: https://www.plakar.io/docs/main/quickstart/ From 5687fc0375375a85a6b939845f270135ca289959 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 14 Sep 2025 19:22:36 +0200 Subject: [PATCH 53/73] update rusqlite and snapshot using VACUUM INTO --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 4 ++-- src/db/sqlite_adapter.rs | 30 ++++++++---------------------- 3 files changed, 19 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 997d6a92..5824294e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1810,11 +1810,11 @@ dependencies = [ [[package]] name = "hashlink" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" dependencies = [ - "hashbrown 0.14.5", + "hashbrown 0.15.2", ] [[package]] @@ -2619,9 +2619,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.28.0" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c10584274047cb335c23d3e61bcef8e323adae7c5c8c760540f73610177fc3f" +checksum = "133c182a6a2c87864fe97778797e46c7e999672690dc9fa3ee8e241aa4a9c13f" dependencies = [ "cc", "pkg-config", @@ -3478,9 +3478,9 @@ dependencies = [ [[package]] name = "r2d2_sqlite" -version = "0.24.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a982edf65c129796dba72f8775b292ef482b40d035e827a9825b3bc07ccc5f2" +checksum = "63417e83dc891797eea3ad379f52a5986da4bca0d6ef28baf4d14034dd111b0c" dependencies = [ "r2d2", "rusqlite", @@ -3669,9 +3669,9 @@ checksum = "3cd14fd5e3b777a7422cca79358c57a8f6e3a703d9ac187448d0daf220c2407f" [[package]] name = "rusqlite" -version = "0.31.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" +checksum = "165ca6e57b20e1351573e3729b958bc62f0e48025386970b6e4d29e7a7e71f3f" dependencies = [ "bitflags 2.9.0", "fallible-iterator", diff --git a/Cargo.toml b/Cargo.toml index fdec5010..75d5bcfb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -88,9 +88,9 @@ tracing-journald = "0.3.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } heed = { version = "0.11", default-features = false, features = ["lmdb"] } -rusqlite = "0.31.0" +rusqlite = "0.37" r2d2 = "0.8" -r2d2_sqlite = "0.24" +r2d2_sqlite = "0.31" fjall = "2.4" async-compression = { version = "0.4", features = ["tokio", "zstd"] } diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index d645c64e..a03ee8ef 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -151,30 +151,16 @@ impl IDb for SqliteDb { } fn snapshot(&self, base_path: &PathBuf) -> Result<()> { - fn progress(p: rusqlite::backup::Progress) { - use std::sync::atomic::{AtomicU64, Ordering}; - use std::time::{SystemTime, UNIX_EPOCH}; - - static LAST_LOG_TIME: AtomicU64 = AtomicU64::new(0); - - let now = SystemTime::now() - .duration_since(UNIX_EPOCH) - .expect("Fix your clock :o") - .as_millis() as u64; - if now >= LAST_LOG_TIME.load(Ordering::Relaxed) + 10 * 1000 { - let percent = (p.pagecount - p.remaining) * 100 / p.pagecount; - info!("Sqlite snapshot progress: {}%", percent); - - LAST_LOG_TIME.fetch_max(now, Ordering::Relaxed); - } - } - std::fs::create_dir_all(base_path)?; - let path = Engine::Sqlite.db_path(&base_path); + let path = Engine::Sqlite + .db_path(&base_path) + .into_os_string() + .into_string() + .map_err(|_| Error("invalid sqlite path string".into()))?; - self.db - .get()? - .backup(rusqlite::DatabaseName::Main, path, Some(progress))?; + info!("Start sqlite VACUUM INTO `{}`", path); + self.db.get()?.execute("VACUUM INTO ?1", params![path])?; + info!("Finished sqlite VACUUM INTO `{}`", path); Ok(()) } From d726cf02997417f6f03ce2fe6e7d7886204cb633 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 14 Sep 2025 19:34:44 +0200 Subject: [PATCH 54/73] add `garage repair clear-resync-queue` (fix #1151) --- src/block/resync.rs | 8 ++++++++ src/garage/cli/structs.rs | 4 ++++ src/garage/repair/online.rs | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/src/block/resync.rs b/src/block/resync.rs index 004f6b48..7056a828 100644 --- a/src/block/resync.rs +++ b/src/block/resync.rs @@ -133,6 +133,14 @@ impl BlockResyncManager { ))) } + /// Clear the entire resync queue and list of errored blocks + /// Corresponds to `garage repair clear-resync-queue` + pub fn clear_resync_queue(&self) -> Result<(), Error> { + self.queue.clear()?; + self.errors.clear()?; + Ok(()) + } + pub fn register_bg_vars(&self, vars: &mut vars::BgVars) { let notify = self.notify.clone(); vars.register_rw( diff --git a/src/garage/cli/structs.rs b/src/garage/cli/structs.rs index 3652ef6b..386a213b 100644 --- a/src/garage/cli/structs.rs +++ b/src/garage/cli/structs.rs @@ -466,6 +466,10 @@ pub enum RepairWhat { /// Repair (resync/rebalance) the set of stored blocks in the cluster #[structopt(name = "blocks", version = garage_version())] Blocks, + /// Clear the block resync queue. The list of blocks in errored state + /// is cleared as well. You MUST run `garage repair blocks` after invoking this. + #[structopt(name = "clear-resync-queue", version = garage_version())] + ClearResyncQueue, /// Repropagate object deletions to the version table #[structopt(name = "versions", version = garage_version())] Versions, diff --git a/src/garage/repair/online.rs b/src/garage/repair/online.rs index 950cd5f7..6a7dafcf 100644 --- a/src/garage/repair/online.rs +++ b/src/garage/repair/online.rs @@ -92,6 +92,11 @@ pub async fn launch_online_repair( info!("Repairing bucket aliases (foreground)"); garage.locked_helper().await.repair_aliases().await?; } + RepairWhat::ClearResyncQueue => { + let garage = garage.clone(); + tokio::task::spawn_blocking(move || garage.block_manager.resync.clear_resync_queue()) + .await?? + } } Ok(()) } From 0f1b488be051f08e49ae0fcc03cc34cb608fc2bf Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 14 Sep 2025 21:25:37 +0200 Subject: [PATCH 55/73] fix rust warnings --- src/api/common/generic_server.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/api/common/generic_server.rs b/src/api/common/generic_server.rs index 5783c276..3f14c07d 100644 --- a/src/api/common/generic_server.rs +++ b/src/api/common/generic_server.rs @@ -33,7 +33,6 @@ use garage_util::metrics::{gen_trace_id, RecordDuration}; use garage_util::socket_address::UnixOrTCPSocketAddress; use crate::helpers::{BoxBody, ErrorBody}; -use crate::signature::payload::Authorization; pub trait ApiEndpoint: Send + Sync + 'static { fn name(&self) -> &'static str; @@ -62,7 +61,7 @@ pub trait ApiHandler: Send + Sync + 'static { /// Returns the key id used to authenticate this request. The ID returned must be safe to /// log. - fn key_id_from_request(&self, req: &Request) -> Option { + fn key_id_from_request(&self, _req: &Request) -> Option { None } } From 4b1fdbef55ee6a6bd68e904aa91863e7c3289555 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 14 Sep 2025 21:36:33 +0200 Subject: [PATCH 56/73] bump version to v1.3.0 --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 24 ++++++++++++------------ doc/book/cookbook/real-world.md | 10 +++++----- doc/book/quick-start/_index.md | 2 +- doc/drafts/admin-api.md | 2 +- script/helm/garage/Chart.yaml | 4 ++-- script/helm/garage/README.md | 2 +- src/api/admin/Cargo.toml | 2 +- src/api/common/Cargo.toml | 2 +- src/api/k2v/Cargo.toml | 2 +- src/api/s3/Cargo.toml | 2 +- src/block/Cargo.toml | 2 +- src/db/Cargo.toml | 2 +- src/garage/Cargo.toml | 2 +- src/model/Cargo.toml | 4 ++-- src/net/Cargo.toml | 2 +- src/rpc/Cargo.toml | 2 +- src/table/Cargo.toml | 2 +- src/util/Cargo.toml | 2 +- src/web/Cargo.toml | 2 +- 20 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5824294e..c516bfbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1280,7 +1280,7 @@ dependencies = [ [[package]] name = "garage" -version = "1.2.0" +version = "1.3.0" dependencies = [ "assert-json-diff", "async-trait", @@ -1336,7 +1336,7 @@ dependencies = [ [[package]] name = "garage_api_admin" -version = "1.2.0" +version = "1.3.0" dependencies = [ "argon2", "async-trait", @@ -1362,7 +1362,7 @@ dependencies = [ [[package]] name = "garage_api_common" -version = "1.2.0" +version = "1.3.0" dependencies = [ "base64 0.21.7", "bytes", @@ -1396,7 +1396,7 @@ dependencies = [ [[package]] name = "garage_api_k2v" -version = "1.2.0" +version = "1.3.0" dependencies = [ "base64 0.21.7", "err-derive", @@ -1419,7 +1419,7 @@ dependencies = [ [[package]] name = "garage_api_s3" -version = "1.2.0" +version = "1.3.0" dependencies = [ "aes-gcm", "async-compression", @@ -1464,7 +1464,7 @@ dependencies = [ [[package]] name = "garage_block" -version = "1.2.0" +version = "1.3.0" dependencies = [ "arc-swap", "async-compression", @@ -1489,7 +1489,7 @@ dependencies = [ [[package]] name = "garage_db" -version = "1.2.0" +version = "1.3.0" dependencies = [ "err-derive", "fjall", @@ -1504,7 +1504,7 @@ dependencies = [ [[package]] name = "garage_model" -version = "1.2.0" +version = "1.3.0" dependencies = [ "async-trait", "base64 0.21.7", @@ -1531,7 +1531,7 @@ dependencies = [ [[package]] name = "garage_net" -version = "1.2.0" +version = "1.3.0" dependencies = [ "arc-swap", "bytes", @@ -1556,7 +1556,7 @@ dependencies = [ [[package]] name = "garage_rpc" -version = "1.2.0" +version = "1.3.0" dependencies = [ "arc-swap", "async-trait", @@ -1588,7 +1588,7 @@ dependencies = [ [[package]] name = "garage_table" -version = "1.2.0" +version = "1.3.0" dependencies = [ "arc-swap", "async-trait", @@ -1609,7 +1609,7 @@ dependencies = [ [[package]] name = "garage_util" -version = "1.2.0" +version = "1.3.0" dependencies = [ "arc-swap", "async-trait", @@ -1641,7 +1641,7 @@ dependencies = [ [[package]] name = "garage_web" -version = "1.2.0" +version = "1.3.0" dependencies = [ "err-derive", "garage_api_common", diff --git a/Cargo.toml b/Cargo.toml index 75d5bcfb..5bc76e3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,18 +24,18 @@ default-members = ["src/garage"] # Internal Garage crates format_table = { version = "0.1.1", path = "src/format-table" } -garage_api_common = { version = "1.2.0", path = "src/api/common" } -garage_api_admin = { version = "1.2.0", path = "src/api/admin" } -garage_api_s3 = { version = "1.2.0", path = "src/api/s3" } -garage_api_k2v = { version = "1.2.0", path = "src/api/k2v" } -garage_block = { version = "1.2.0", path = "src/block" } -garage_db = { version = "1.2.0", path = "src/db", default-features = false } -garage_model = { version = "1.2.0", path = "src/model", default-features = false } -garage_net = { version = "1.2.0", path = "src/net" } -garage_rpc = { version = "1.2.0", path = "src/rpc" } -garage_table = { version = "1.2.0", path = "src/table" } -garage_util = { version = "1.2.0", path = "src/util" } -garage_web = { version = "1.2.0", path = "src/web" } +garage_api_common = { version = "1.3.0", path = "src/api/common" } +garage_api_admin = { version = "1.3.0", path = "src/api/admin" } +garage_api_s3 = { version = "1.3.0", path = "src/api/s3" } +garage_api_k2v = { version = "1.3.0", path = "src/api/k2v" } +garage_block = { version = "1.3.0", path = "src/block" } +garage_db = { version = "1.3.0", path = "src/db", default-features = false } +garage_model = { version = "1.3.0", path = "src/model", default-features = false } +garage_net = { version = "1.3.0", path = "src/net" } +garage_rpc = { version = "1.3.0", path = "src/rpc" } +garage_table = { version = "1.3.0", path = "src/table" } +garage_util = { version = "1.3.0", path = "src/util" } +garage_web = { version = "1.3.0", path = "src/web" } k2v-client = { version = "0.0.4", path = "src/k2v-client" } # External crates from crates.io diff --git a/doc/book/cookbook/real-world.md b/doc/book/cookbook/real-world.md index 998c02a5..b9927c06 100644 --- a/doc/book/cookbook/real-world.md +++ b/doc/book/cookbook/real-world.md @@ -96,14 +96,14 @@ to store 2 TB of data in total. ## Get a Docker image Our docker image is currently named `dxflrs/garage` and is stored on the [Docker Hub](https://hub.docker.com/r/dxflrs/garage/tags?page=1&ordering=last_updated). -We encourage you to use a fixed tag (eg. `v1.2.0`) and not the `latest` tag. -For this example, we will use the latest published version at the time of the writing which is `v1.2.0` but it's up to you +We encourage you to use a fixed tag (eg. `v1.3.0`) and not the `latest` tag. +For this example, we will use the latest published version at the time of the writing which is `v1.3.0` but it's up to you to check [the most recent versions on the Docker Hub](https://hub.docker.com/r/dxflrs/garage/tags?page=1&ordering=last_updated). For example: ``` -sudo docker pull dxflrs/garage:v1.2.0 +sudo docker pull dxflrs/garage:v1.3.0 ``` ## Deploying and configuring Garage @@ -171,7 +171,7 @@ docker run \ -v /etc/garage.toml:/etc/garage.toml \ -v /var/lib/garage/meta:/var/lib/garage/meta \ -v /var/lib/garage/data:/var/lib/garage/data \ - dxflrs/garage:v1.2.0 + dxflrs/garage:v1.3.0 ``` With this command line, Garage should be started automatically at each boot. @@ -185,7 +185,7 @@ If you want to use `docker-compose`, you may use the following `docker-compose.y version: "3" services: garage: - image: dxflrs/garage:v1.2.0 + image: dxflrs/garage:v1.3.0 network_mode: "host" restart: unless-stopped volumes: diff --git a/doc/book/quick-start/_index.md b/doc/book/quick-start/_index.md index 45a4a43b..633b785a 100644 --- a/doc/book/quick-start/_index.md +++ b/doc/book/quick-start/_index.md @@ -132,7 +132,7 @@ docker run \ -v /path/to/garage.toml:/etc/garage.toml \ -v /path/to/garage/meta:/var/lib/garage/meta \ -v /path/to/garage/data:/var/lib/garage/data \ - dxflrs/garage:v1.2.0 + dxflrs/garage:v1.3.0 ``` Under Linux, you can substitute `--network host` for `-p 3900:3900 -p 3901:3901 -p 3902:3902 -p 3903:3903` diff --git a/doc/drafts/admin-api.md b/doc/drafts/admin-api.md index a3d03c41..3ee948cb 100644 --- a/doc/drafts/admin-api.md +++ b/doc/drafts/admin-api.md @@ -70,7 +70,7 @@ Example response body: ```json { "node": "b10c110e4e854e5aa3f4637681befac755154b20059ec163254ddbfae86b09df", - "garageVersion": "v1.2.0", + "garageVersion": "v1.3.0", "garageFeatures": [ "k2v", "lmdb", diff --git a/script/helm/garage/Chart.yaml b/script/helm/garage/Chart.yaml index 6806e593..51f98bbb 100644 --- a/script/helm/garage/Chart.yaml +++ b/script/helm/garage/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: garage description: S3-compatible object store for small self-hosted geo-distributed deployments type: application -version: 0.7.1 -appVersion: "v1.2.0" +version: 0.7.2 +appVersion: "v1.3.0" home: https://garagehq.deuxfleurs.fr/ icon: https://garagehq.deuxfleurs.fr/images/garage-logo.svg diff --git a/script/helm/garage/README.md b/script/helm/garage/README.md index 05d444a3..25e548ec 100644 --- a/script/helm/garage/README.md +++ b/script/helm/garage/README.md @@ -1,6 +1,6 @@ # garage -![Version: 0.7.1](https://img.shields.io/badge/Version-0.7.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.2.0](https://img.shields.io/badge/AppVersion-v1.2.0-informational?style=flat-square) +![Version: 0.7.2](https://img.shields.io/badge/Version-0.7.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.3.0](https://img.shields.io/badge/AppVersion-v1.3.0-informational?style=flat-square) S3-compatible object store for small self-hosted geo-distributed deployments diff --git a/src/api/admin/Cargo.toml b/src/api/admin/Cargo.toml index 6b039eeb..d7184068 100644 --- a/src/api/admin/Cargo.toml +++ b/src/api/admin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_api_admin" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/api/common/Cargo.toml b/src/api/common/Cargo.toml index a67e9d9c..fd159c96 100644 --- a/src/api/common/Cargo.toml +++ b/src/api/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_api_common" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/api/k2v/Cargo.toml b/src/api/k2v/Cargo.toml index 845d23f6..628d2db1 100644 --- a/src/api/k2v/Cargo.toml +++ b/src/api/k2v/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_api_k2v" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/api/s3/Cargo.toml b/src/api/s3/Cargo.toml index 1ba7565d..15f6858c 100644 --- a/src/api/s3/Cargo.toml +++ b/src/api/s3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_api_s3" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/block/Cargo.toml b/src/block/Cargo.toml index d5f8e58e..effa8dba 100644 --- a/src/block/Cargo.toml +++ b/src/block/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_block" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/db/Cargo.toml b/src/db/Cargo.toml index e9ed15c9..6dee2fa6 100644 --- a/src/db/Cargo.toml +++ b/src/db/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_db" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml index 7d60313e..ad2b917b 100644 --- a/src/garage/Cargo.toml +++ b/src/garage/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml index 14f92253..e59765d7 100644 --- a/src/model/Cargo.toml +++ b/src/model/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_model" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" @@ -44,4 +44,4 @@ default = [ "lmdb", "sqlite" ] k2v = [ "garage_util/k2v" ] lmdb = [ "garage_db/lmdb" ] sqlite = [ "garage_db/sqlite" ] -fjall = [ "garage_db/fjall" ] \ No newline at end of file +fjall = [ "garage_db/fjall" ] diff --git a/src/net/Cargo.toml b/src/net/Cargo.toml index 17a0eb24..83b3b15b 100644 --- a/src/net/Cargo.toml +++ b/src/net/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_net" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/rpc/Cargo.toml b/src/rpc/Cargo.toml index a314271f..1e764c77 100644 --- a/src/rpc/Cargo.toml +++ b/src/rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_rpc" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/table/Cargo.toml b/src/table/Cargo.toml index c76c5b78..91ab110c 100644 --- a/src/table/Cargo.toml +++ b/src/table/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_table" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/util/Cargo.toml b/src/util/Cargo.toml index f59e44e2..0d693a97 100644 --- a/src/util/Cargo.toml +++ b/src/util/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_util" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat "] edition = "2018" license = "AGPL-3.0" diff --git a/src/web/Cargo.toml b/src/web/Cargo.toml index 5d208e6e..c1056509 100644 --- a/src/web/Cargo.toml +++ b/src/web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "garage_web" -version = "1.2.0" +version = "1.3.0" authors = ["Alex Auvolat ", "Quentin Dufour "] edition = "2018" license = "AGPL-3.0" From 42fd8583bd81c9855d25c5ac0171e9eb9d265ab7 Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Wed, 8 Oct 2025 17:54:15 +0200 Subject: [PATCH 57/73] properly handle precondition time equal to object time --- src/api/s3/get.rs | 4 +++- src/garage/tests/s3/objects.rs | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/api/s3/get.rs b/src/api/s3/get.rs index 888a040a..a1e4ce10 100644 --- a/src/api/s3/get.rs +++ b/src/api/s3/get.rs @@ -845,7 +845,9 @@ impl PreconditionHeaders { } fn check(&self, v: &ObjectVersion, etag: &str) -> Result, Error> { - let v_date = UNIX_EPOCH + Duration::from_millis(v.timestamp); + // we store date with ms precision, but headers are precise to the second: truncate + // the timestamp to handle the same-second edge case + let v_date = UNIX_EPOCH + Duration::from_secs(v.timestamp / 1000); // Implemented from https://datatracker.ietf.org/doc/html/rfc7232#section-6 diff --git a/src/garage/tests/s3/objects.rs b/src/garage/tests/s3/objects.rs index d63ac000..53e8231d 100644 --- a/src/garage/tests/s3/objects.rs +++ b/src/garage/tests/s3/objects.rs @@ -198,6 +198,7 @@ async fn test_precondition() { ); } let older_date = DateTime::from_secs_f64(last_modified.as_secs_f64() - 10.0); + let same_date = DateTime::from_secs_f64(last_modified.as_secs_f64()); let newer_date = DateTime::from_secs_f64(last_modified.as_secs_f64() + 10.0); { let err = ctx @@ -212,6 +213,18 @@ async fn test_precondition() { matches!(err, Err(SdkError::ServiceError(se)) if se.raw().status().as_u16() == 304) ); + let err = ctx + .client + .get_object() + .bucket(&bucket) + .key(STD_KEY) + .if_modified_since(same_date) + .send() + .await; + assert!( + matches!(err, Err(SdkError::ServiceError(se)) if se.raw().status().as_u16() == 304) + ); + let o = ctx .client .get_object() @@ -236,6 +249,17 @@ async fn test_precondition() { matches!(err, Err(SdkError::ServiceError(se)) if se.raw().status().as_u16() == 412) ); + let o = ctx + .client + .get_object() + .bucket(&bucket) + .key(STD_KEY) + .if_unmodified_since(same_date) + .send() + .await + .unwrap(); + assert_eq!(o.e_tag.as_ref().unwrap().as_str(), etag); + let o = ctx .client .get_object() From 1c29d04cc5c05aae1b0b7928e573c8f1ac6d65e4 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 14 Oct 2025 11:16:35 +0200 Subject: [PATCH 58/73] sigv4: don't enforce x-amz-content-sha256 to be in signed headers list (fix #770) From the following page: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html > In both cases, because the x-amz-content-sha256 header value is already > part of your HashedPayload, you are not required to include the > x-amz-content-sha256 header as a canonical header. --- src/api/common/signature/payload.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/api/common/signature/payload.rs b/src/api/common/signature/payload.rs index c3a7f231..3939da19 100644 --- a/src/api/common/signature/payload.rs +++ b/src/api/common/signature/payload.rs @@ -104,7 +104,7 @@ async fn check_standard_signature( // Verify that all necessary request headers are included in signed_headers // The following must be included for all signatures: // - the Host header (mandatory) - // - all x-amz-* headers used in the request + // - all x-amz-* headers used in the request (except x-amz-content-sha256) // AWS also indicates that the Content-Type header should be signed if // it is used, but Minio client doesn't sign it so we don't check it for compatibility. let signed_headers = split_signed_headers(&authorization)?; @@ -151,7 +151,7 @@ async fn check_presigned_signature( // Verify that all necessary request headers are included in signed_headers // For AWSv4 pre-signed URLs, the following must be included: // - the Host header (mandatory) - // - all x-amz-* headers used in the request + // - all x-amz-* headers used in the request (except x-amz-content-sha256) let signed_headers = split_signed_headers(&authorization)?; verify_signed_headers(request.headers(), &signed_headers)?; @@ -268,7 +268,9 @@ fn verify_signed_headers(headers: &HeaderMap, signed_headers: &[HeaderName]) -> return Err(Error::bad_request("Header `Host` should be signed")); } for (name, _) in headers.iter() { - if name.as_str().starts_with("x-amz-") { + // Enforce signature of all x-amz-* headers, except x-amz-content-sh256 + // because it is included in the canonical request in all cases + if name.as_str().starts_with("x-amz-") && name != X_AMZ_CONTENT_SHA256 { if !signed_headers.contains(name) { return Err(Error::bad_request(format!( "Header `{}` should be signed", @@ -468,8 +470,7 @@ impl Authorization { let date = headers .get(X_AMZ_DATE) - .ok_or_bad_request("Missing X-Amz-Date field") - .map_err(Error::from)? + .ok_or_bad_request("Missing X-Amz-Date field")? .to_str()?; let date = parse_date(date)?; From b43c58cbe553deb970fe403316d621ec57f0fac0 Mon Sep 17 00:00:00 2001 From: fgberry Date: Fri, 24 Oct 2025 11:22:32 +0200 Subject: [PATCH 59/73] fix: default config path changed for alpine binary --- doc/book/cookbook/binary-packages.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/book/cookbook/binary-packages.md b/doc/book/cookbook/binary-packages.md index 0a6ad8fc..8c30b360 100644 --- a/doc/book/cookbook/binary-packages.md +++ b/doc/book/cookbook/binary-packages.md @@ -15,8 +15,10 @@ Alpine Linux repositories (available since v3.17): apk add garage ``` -The default configuration file is installed to `/etc/garage.toml`. You can run -Garage using: `rc-service garage start`. If you don't specify `rpc_secret`, it +The default configuration file is installed to `/etc/garage/garage.toml`. You can run +Garage using: `rc-service garage start`. + +If you don't specify `rpc_secret`, it will be automatically replaced with a random string on the first start. Please note that this package is built without Consul discovery, Kubernetes From 1aac7b4875b1acde44e98b6a98b343cb659572f5 Mon Sep 17 00:00:00 2001 From: fgberry Date: Fri, 24 Oct 2025 11:25:33 +0200 Subject: [PATCH 60/73] chore: spacing --- doc/book/cookbook/binary-packages.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/book/cookbook/binary-packages.md b/doc/book/cookbook/binary-packages.md index 8c30b360..6476ff51 100644 --- a/doc/book/cookbook/binary-packages.md +++ b/doc/book/cookbook/binary-packages.md @@ -18,8 +18,7 @@ apk add garage The default configuration file is installed to `/etc/garage/garage.toml`. You can run Garage using: `rc-service garage start`. -If you don't specify `rpc_secret`, it -will be automatically replaced with a random string on the first start. +If you don't specify `rpc_secret`, it will be automatically replaced with a random string on the first start. Please note that this package is built without Consul discovery, Kubernetes discovery, OpenTelemetry exporter, and K2V features (K2V will be enabled once From 174f4f01a8d2daff681152d62a1a23c5fe7bcc9e Mon Sep 17 00:00:00 2001 From: teo-tsirpanis Date: Sun, 26 Oct 2025 15:54:08 +0000 Subject: [PATCH 61/73] Update link to signature v2. --- doc/book/reference-manual/s3-compatibility.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/book/reference-manual/s3-compatibility.md b/doc/book/reference-manual/s3-compatibility.md index edf8de0d..b869b6f4 100644 --- a/doc/book/reference-manual/s3-compatibility.md +++ b/doc/book/reference-manual/s3-compatibility.md @@ -27,7 +27,7 @@ Feel free to open a PR to suggest fixes this table. Minio is missing because the | Feature | Garage | [Openstack Swift](https://docs.openstack.org/swift/latest/s3_compat.html) | [Ceph Object Gateway](https://docs.ceph.com/en/latest/radosgw/s3/) | [Riak CS](https://docs.riak.com/riak/cs/2.1.1/references/apis/storage/s3/index.html) | [OpenIO](https://docs.openio.io/latest/source/arch-design/s3_compliancy.html) | |------------------------------|----------------------------------|-----------------|---------------|---------|-----| -| [signature v2](https://docs.aws.amazon.com/general/latest/gr/signature-version-2.html) (deprecated) | ❌ Missing | ✅ | ✅ | ✅ | ✅ | +| [signature v2](https://docs.aws.amazon.com/AmazonS3/latest/API/Appendix-Sigv2.html) (deprecated) | ❌ Missing | ✅ | ✅ | ✅ | ✅ | | [signature v4](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html) | ✅ Implemented | ✅ | ✅ | ❌ | ✅ | | [URL path-style](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access) (eg. `host.tld/bucket/key`) | ✅ Implemented | ✅ | ✅ | ❓| ✅ | | [URL vhost-style](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#virtual-hosted-style-access) URL (eg. `bucket.host.tld/key`) | ✅ Implemented | ❌| ✅| ✅ | ✅ | From 82297371bff85476ad10d05d98ad8ebe316060a4 Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Sat, 1 Nov 2025 17:20:39 +0100 Subject: [PATCH 62/73] migrate to this error it doesn't generate a bazillion warning at compile time --- Cargo.lock | 58 ++++++------------------ Cargo.toml | 3 +- src/api/admin/Cargo.toml | 2 +- src/api/admin/error.rs | 13 +++--- src/api/common/Cargo.toml | 2 +- src/api/common/common_error.rs | 30 ++++++------- src/api/common/signature/error.rs | 12 ++--- src/api/k2v/Cargo.toml | 2 +- src/api/k2v/error.rs | 24 +++++----- src/api/s3/Cargo.toml | 2 +- src/api/s3/error.rs | 46 ++++++++++--------- src/db/Cargo.toml | 2 +- src/db/lib.rs | 6 +-- src/model/Cargo.toml | 2 +- src/model/garage.rs | 6 +-- src/model/helper/error.rs | 14 +++--- src/net/Cargo.toml | 2 +- src/net/endpoint.rs | 4 +- src/net/error.rs | 44 +++++++++--------- src/rpc/Cargo.toml | 4 +- src/rpc/consul.rs | 16 +++---- src/util/Cargo.toml | 2 +- src/util/error.rs | 75 ++++++++++++++----------------- src/web/Cargo.toml | 2 +- src/web/error.rs | 8 ++-- 25 files changed, 172 insertions(+), 209 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c516bfbf..69bad7a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1099,20 +1099,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" -[[package]] -name = "err-derive" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c34a887c8df3ed90498c1c437ce21f211c8e27672921a8ffa293cb8d6d4caa9e" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "rustversion", - "syn 1.0.109", - "synstructure 0.12.6", -] - [[package]] name = "errno" version = "0.3.10" @@ -1340,7 +1326,6 @@ version = "1.3.0" dependencies = [ "argon2", "async-trait", - "err-derive", "futures", "garage_api_common", "garage_model", @@ -1355,6 +1340,7 @@ dependencies = [ "prometheus", "serde", "serde_json", + "thiserror 2.0.12", "tokio", "tracing", "url", @@ -1370,7 +1356,6 @@ dependencies = [ "crc32c", "crc32fast", "crypto-common", - "err-derive", "futures", "garage_model", "garage_table", @@ -1389,6 +1374,7 @@ dependencies = [ "serde_json", "sha1", "sha2", + "thiserror 2.0.12", "tokio", "tracing", "url", @@ -1399,7 +1385,6 @@ name = "garage_api_k2v" version = "1.3.0" dependencies = [ "base64 0.21.7", - "err-derive", "futures", "garage_api_common", "garage_model", @@ -1412,6 +1397,7 @@ dependencies = [ "percent-encoding", "serde", "serde_json", + "thiserror 2.0.12", "tokio", "tracing", "url", @@ -1428,7 +1414,6 @@ dependencies = [ "chrono", "crc32c", "crc32fast", - "err-derive", "form_urlencoded", "futures", "garage_api_common", @@ -1455,6 +1440,7 @@ dependencies = [ "serde_json", "sha1", "sha2", + "thiserror 2.0.12", "tokio", "tokio-stream", "tokio-util 0.7.14", @@ -1491,7 +1477,6 @@ dependencies = [ name = "garage_db" version = "1.3.0" dependencies = [ - "err-derive", "fjall", "heed", "mktemp", @@ -1499,6 +1484,7 @@ dependencies = [ "r2d2", "r2d2_sqlite", "rusqlite", + "thiserror 2.0.12", "tracing", ] @@ -1510,7 +1496,6 @@ dependencies = [ "base64 0.21.7", "blake2", "chrono", - "err-derive", "futures", "garage_block", "garage_db", @@ -1524,6 +1509,7 @@ dependencies = [ "rand", "serde", "serde_bytes", + "thiserror 2.0.12", "tokio", "tracing", "zstd", @@ -1536,7 +1522,6 @@ dependencies = [ "arc-swap", "bytes", "cfg-if", - "err-derive", "futures", "hex", "kuska-handshake", @@ -1549,6 +1534,7 @@ dependencies = [ "rand", "rmp-serde", "serde", + "thiserror 2.0.12", "tokio", "tokio-stream", "tokio-util 0.7.14", @@ -1561,7 +1547,6 @@ dependencies = [ "arc-swap", "async-trait", "bytesize", - "err-derive", "format_table", "futures", "garage_net", @@ -1582,6 +1567,7 @@ dependencies = [ "serde", "serde_bytes", "serde_json", + "thiserror 2.0.12", "tokio", "tracing", ] @@ -1616,7 +1602,6 @@ dependencies = [ "blake2", "bytesize", "chrono", - "err-derive", "futures", "garage_db", "garage_net", @@ -1633,6 +1618,7 @@ dependencies = [ "serde", "serde_json", "sha2", + "thiserror 2.0.12", "tokio", "toml", "tracing", @@ -1643,7 +1629,6 @@ dependencies = [ name = "garage_web" version = "1.3.0" dependencies = [ - "err-derive", "garage_api_common", "garage_api_s3", "garage_model", @@ -1654,6 +1639,7 @@ dependencies = [ "hyper 1.6.0", "opentelemetry", "percent-encoding", + "thiserror 2.0.12", "tokio", "tracing", ] @@ -2445,7 +2431,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "thiserror 1.0.69", + "thiserror 2.0.12", "tokio", "tracing-subscriber", ] @@ -4233,18 +4219,6 @@ dependencies = [ "crossbeam-queue", ] -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "synstructure" version = "0.13.1" @@ -4764,12 +4738,6 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "universal-hash" version = "0.5.1" @@ -5272,7 +5240,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.100", - "synstructure 0.13.1", + "synstructure", ] [[package]] @@ -5333,7 +5301,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.100", - "synstructure 0.13.1", + "synstructure", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5bc76e3c..a21ac072 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,6 @@ chrono = "0.4" crc32fast = "1.4" crc32c = "0.6" crypto-common = "0.1" -err-derive = "0.3" gethostname = "0.4" git-version = "0.3.4" hex = "0.4" @@ -137,7 +136,7 @@ prometheus = "0.13" aws-sigv4 = { version = "1.1", default-features = false } hyper-rustls = { version = "0.26", default-features = false, features = ["http1", "http2", "ring", "rustls-native-certs"] } log = "0.4" -thiserror = "1.0" +thiserror = "2.0" # ---- used only as build / dev dependencies ---- assert-json-diff = "2.0" diff --git a/src/api/admin/Cargo.toml b/src/api/admin/Cargo.toml index d7184068..81735a85 100644 --- a/src/api/admin/Cargo.toml +++ b/src/api/admin/Cargo.toml @@ -22,7 +22,7 @@ garage_api_common.workspace = true argon2.workspace = true async-trait.workspace = true -err-derive.workspace = true +thiserror.workspace = true hex.workspace = true tracing.workspace = true diff --git a/src/api/admin/error.rs b/src/api/admin/error.rs index 201f9b40..97f02156 100644 --- a/src/api/admin/error.rs +++ b/src/api/admin/error.rs @@ -1,6 +1,6 @@ use std::convert::TryFrom; -use err_derive::Error; +use thiserror::Error; use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; @@ -16,20 +16,17 @@ use garage_api_common::helpers::*; /// Errors of this crate #[derive(Debug, Error)] pub enum Error { - #[error(display = "{}", _0)] + #[error("{0}")] /// Error from common error - Common(#[error(source)] CommonError), + Common(#[from] CommonError), // Category: cannot process /// The API access key does not exist - #[error(display = "Access key not found: {}", _0)] + #[error("Access key not found: {0}")] NoSuchAccessKey(String), /// In Import key, the key already exists - #[error( - display = "Key {} already exists in data store. Even if it is deleted, we can't let you create a new key with the same ID. Sorry.", - _0 - )] + #[error("Key {0} already exists in data store. Even if it is deleted, we can't let you create a new key with the same ID. Sorry.")] KeyAlreadyExists(String), } diff --git a/src/api/common/Cargo.toml b/src/api/common/Cargo.toml index fd159c96..b337cd69 100644 --- a/src/api/common/Cargo.toml +++ b/src/api/common/Cargo.toml @@ -24,7 +24,7 @@ chrono.workspace = true crc32fast.workspace = true crc32c.workspace = true crypto-common.workspace = true -err-derive.workspace = true +thiserror.workspace = true hex.workspace = true hmac.workspace = true md-5.workspace = true diff --git a/src/api/common/common_error.rs b/src/api/common/common_error.rs index 597a3511..1335fece 100644 --- a/src/api/common/common_error.rs +++ b/src/api/common/common_error.rs @@ -1,6 +1,6 @@ use std::convert::TryFrom; -use err_derive::Error; +use thiserror::Error; use hyper::StatusCode; use garage_util::error::Error as GarageError; @@ -12,48 +12,48 @@ use garage_model::helper::error::Error as HelperError; pub enum CommonError { // ---- INTERNAL ERRORS ---- /// Error related to deeper parts of Garage - #[error(display = "Internal error: {}", _0)] - InternalError(#[error(source)] GarageError), + #[error("Internal error: {0}")] + InternalError(#[from] GarageError), /// Error related to Hyper - #[error(display = "Internal error (Hyper error): {}", _0)] - Hyper(#[error(source)] hyper::Error), + #[error("Internal error (Hyper error): {0}")] + Hyper(#[from] hyper::Error), /// Error related to HTTP - #[error(display = "Internal error (HTTP error): {}", _0)] - Http(#[error(source)] http::Error), + #[error("Internal error (HTTP error): {0}")] + Http(#[from] http::Error), // ---- GENERIC CLIENT ERRORS ---- /// Proper authentication was not provided - #[error(display = "Forbidden: {}", _0)] + #[error("Forbidden: {0}")] Forbidden(String), /// Generic bad request response with custom message - #[error(display = "Bad request: {}", _0)] + #[error("Bad request: {0}")] BadRequest(String), /// The client sent a header with invalid value - #[error(display = "Invalid header value: {}", _0)] - InvalidHeader(#[error(source)] hyper::header::ToStrError), + #[error("Invalid header value: {0}")] + InvalidHeader(#[from] hyper::header::ToStrError), // ---- SPECIFIC ERROR CONDITIONS ---- // These have to be error codes referenced in the S3 spec here: // https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList /// The bucket requested don't exists - #[error(display = "Bucket not found: {}", _0)] + #[error("Bucket not found: {0}")] NoSuchBucket(String), /// Tried to create a bucket that already exist - #[error(display = "Bucket already exists")] + #[error("Bucket already exists")] BucketAlreadyExists, /// Tried to delete a non-empty bucket - #[error(display = "Tried to delete a non-empty bucket")] + #[error("Tried to delete a non-empty bucket")] BucketNotEmpty, // Category: bad request /// Bucket name is not valid according to AWS S3 specs - #[error(display = "Invalid bucket name: {}", _0)] + #[error("Invalid bucket name: {0}")] InvalidBucketName(String), } diff --git a/src/api/common/signature/error.rs b/src/api/common/signature/error.rs index b2f396b5..a1b353e1 100644 --- a/src/api/common/signature/error.rs +++ b/src/api/common/signature/error.rs @@ -1,4 +1,4 @@ -use err_derive::Error; +use thiserror::Error; use crate::common_error::CommonError; pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInternalError}; @@ -6,21 +6,21 @@ pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInterna /// Errors of this crate #[derive(Debug, Error)] pub enum Error { - #[error(display = "{}", _0)] + #[error("{0}")] /// Error from common error Common(CommonError), /// Authorization Header Malformed - #[error(display = "Authorization header malformed, unexpected scope: {}", _0)] + #[error("Authorization header malformed, unexpected scope: {0}")] AuthorizationHeaderMalformed(String), // Category: bad request /// The request contained an invalid UTF-8 sequence in its path or in other parameters - #[error(display = "Invalid UTF-8: {}", _0)] - InvalidUtf8Str(#[error(source)] std::str::Utf8Error), + #[error("Invalid UTF-8: {0}")] + InvalidUtf8Str(#[from] std::str::Utf8Error), /// The provided digest (checksum) value was invalid - #[error(display = "Invalid digest: {}", _0)] + #[error("Invalid digest: {0}")] InvalidDigest(String), } diff --git a/src/api/k2v/Cargo.toml b/src/api/k2v/Cargo.toml index 628d2db1..2b77f676 100644 --- a/src/api/k2v/Cargo.toml +++ b/src/api/k2v/Cargo.toml @@ -20,7 +20,7 @@ garage_util = { workspace = true, features = [ "k2v" ] } garage_api_common.workspace = true base64.workspace = true -err-derive.workspace = true +thiserror.workspace = true tracing.workspace = true futures.workspace = true diff --git a/src/api/k2v/error.rs b/src/api/k2v/error.rs index 257ff893..c860ab98 100644 --- a/src/api/k2v/error.rs +++ b/src/api/k2v/error.rs @@ -1,4 +1,4 @@ -use err_derive::Error; +use thiserror::Error; use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; @@ -14,38 +14,38 @@ use garage_api_common::signature::error::Error as SignatureError; /// Errors of this crate #[derive(Debug, Error)] pub enum Error { - #[error(display = "{}", _0)] + #[error("{0}")] /// Error from common error - Common(#[error(source)] CommonError), + Common(#[from] CommonError), // Category: cannot process /// Authorization Header Malformed - #[error(display = "Authorization header malformed, unexpected scope: {}", _0)] + #[error("Authorization header malformed, unexpected scope: {0}")] AuthorizationHeaderMalformed(String), /// The provided digest (checksum) value was invalid - #[error(display = "Invalid digest: {}", _0)] + #[error("Invalid digest: {0}")] InvalidDigest(String), /// The object requested don't exists - #[error(display = "Key not found")] + #[error("Key not found")] NoSuchKey, /// Some base64 encoded data was badly encoded - #[error(display = "Invalid base64: {}", _0)] - InvalidBase64(#[error(source)] base64::DecodeError), + #[error("Invalid base64: {0}")] + InvalidBase64(#[from] base64::DecodeError), /// Invalid causality token - #[error(display = "Invalid causality token")] + #[error("Invalid causality token")] InvalidCausalityToken, /// The client asked for an invalid return format (invalid Accept header) - #[error(display = "Not acceptable: {}", _0)] + #[error("Not acceptable: {0}")] NotAcceptable(String), /// The request contained an invalid UTF-8 sequence in its path or in other parameters - #[error(display = "Invalid UTF-8: {}", _0)] - InvalidUtf8Str(#[error(source)] std::str::Utf8Error), + #[error("Invalid UTF-8: {0}")] + InvalidUtf8Str(#[from] std::str::Utf8Error), } commonErrorDerivative!(Error); diff --git a/src/api/s3/Cargo.toml b/src/api/s3/Cargo.toml index 15f6858c..56f90864 100644 --- a/src/api/s3/Cargo.toml +++ b/src/api/s3/Cargo.toml @@ -29,7 +29,7 @@ bytes.workspace = true chrono.workspace = true crc32fast.workspace = true crc32c.workspace = true -err-derive.workspace = true +thiserror.workspace = true hex.workspace = true tracing.workspace = true md-5.workspace = true diff --git a/src/api/s3/error.rs b/src/api/s3/error.rs index 6d4b7a11..6f4dfb5c 100644 --- a/src/api/s3/error.rs +++ b/src/api/s3/error.rs @@ -1,6 +1,6 @@ use std::convert::TryInto; -use err_derive::Error; +use thiserror::Error; use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; @@ -25,67 +25,67 @@ use crate::xml as s3_xml; /// Errors of this crate #[derive(Debug, Error)] pub enum Error { - #[error(display = "{}", _0)] + #[error("{0}")] /// Error from common error - Common(#[error(source)] CommonError), + Common(#[from] CommonError), // Category: cannot process /// Authorization Header Malformed - #[error(display = "Authorization header malformed, unexpected scope: {}", _0)] + #[error("Authorization header malformed, unexpected scope: {0}")] AuthorizationHeaderMalformed(String), /// The object requested don't exists - #[error(display = "Key not found")] + #[error("Key not found")] NoSuchKey, /// The multipart upload requested don't exists - #[error(display = "Upload not found")] + #[error("Upload not found")] NoSuchUpload, /// Precondition failed (e.g. x-amz-copy-source-if-match) - #[error(display = "At least one of the preconditions you specified did not hold")] + #[error("At least one of the preconditions you specified did not hold")] PreconditionFailed, /// Parts specified in CMU request do not match parts actually uploaded - #[error(display = "Parts given to CompleteMultipartUpload do not match uploaded parts")] + #[error("Parts given to CompleteMultipartUpload do not match uploaded parts")] InvalidPart, /// Parts given to CompleteMultipartUpload were not in ascending order - #[error(display = "Parts given to CompleteMultipartUpload were not in ascending order")] + #[error("Parts given to CompleteMultipartUpload were not in ascending order")] InvalidPartOrder, /// In CompleteMultipartUpload: not enough data /// (here we are more lenient than AWS S3) - #[error(display = "Proposed upload is smaller than the minimum allowed object size")] + #[error("Proposed upload is smaller than the minimum allowed object size")] EntityTooSmall, // Category: bad request /// The request contained an invalid UTF-8 sequence in its path or in other parameters - #[error(display = "Invalid UTF-8: {}", _0)] - InvalidUtf8Str(#[error(source)] std::str::Utf8Error), + #[error("Invalid UTF-8: {0}")] + InvalidUtf8Str(#[from] std::str::Utf8Error), /// The request used an invalid path - #[error(display = "Invalid UTF-8: {}", _0)] - InvalidUtf8String(#[error(source)] std::string::FromUtf8Error), + #[error("Invalid UTF-8: {0}")] + InvalidUtf8String(#[from] std::string::FromUtf8Error), /// The client sent invalid XML data - #[error(display = "Invalid XML: {}", _0)] + #[error("Invalid XML: {0}")] InvalidXml(String), /// The client sent a range header with invalid value - #[error(display = "Invalid HTTP range: {:?}", _0)] - InvalidRange(#[error(from)] (http_range::HttpRangeParseError, u64)), + #[error("Invalid HTTP range: {0:?}")] + InvalidRange((http_range::HttpRangeParseError, u64)), /// The client sent a range header with invalid value - #[error(display = "Invalid encryption algorithm: {:?}, should be AES256", _0)] + #[error("Invalid encryption algorithm: {0:?}, should be AES256")] InvalidEncryptionAlgorithm(String), /// The provided digest (checksum) value was invalid - #[error(display = "Invalid digest: {}", _0)] + #[error("Invalid digest: {0}")] InvalidDigest(String), /// The client sent a request for an action not supported by garage - #[error(display = "Unimplemented action: {}", _0)] + #[error("Unimplemented action: {0}")] NotImplemented(String), } @@ -99,6 +99,12 @@ impl From for Error { } } +impl From<(http_range::HttpRangeParseError, u64)> for Error { + fn from (err: (http_range::HttpRangeParseError, u64)) -> Error { + Error::InvalidRange(err) + } +} + impl From for Error { fn from(err: roxmltree::Error) -> Self { Self::InvalidXml(format!("{}", err)) diff --git a/src/db/Cargo.toml b/src/db/Cargo.toml index 6dee2fa6..7c1c8d90 100644 --- a/src/db/Cargo.toml +++ b/src/db/Cargo.toml @@ -12,7 +12,7 @@ readme = "../../README.md" path = "lib.rs" [dependencies] -err-derive.workspace = true +thiserror.workspace = true tracing.workspace = true heed = { workspace = true, optional = true } diff --git a/src/db/lib.rs b/src/db/lib.rs index 71826255..2a467c7c 100644 --- a/src/db/lib.rs +++ b/src/db/lib.rs @@ -20,7 +20,7 @@ use std::cell::Cell; use std::path::PathBuf; use std::sync::Arc; -use err_derive::Error; +use thiserror::Error; pub use open::*; @@ -44,7 +44,7 @@ pub type TxValueIter<'a> = Box); impl From for Error { @@ -56,7 +56,7 @@ impl From for Error { pub type Result = std::result::Result; #[derive(Debug, Error)] -#[error(display = "{}", _0)] +#[error("{0}")] pub struct TxOpError(pub(crate) Error); pub type TxOpResult = std::result::Result; diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml index e59765d7..579092d2 100644 --- a/src/model/Cargo.toml +++ b/src/model/Cargo.toml @@ -24,7 +24,7 @@ garage_net.workspace = true async-trait.workspace = true blake2.workspace = true chrono.workspace = true -err-derive.workspace = true +thiserror.workspace = true hex.workspace = true http.workspace = true base64.workspace = true diff --git a/src/model/garage.rs b/src/model/garage.rs index 38f8f1f7..f4f6f693 100644 --- a/src/model/garage.rs +++ b/src/model/garage.rs @@ -315,15 +315,15 @@ impl Garage { Ok(()) } - pub fn bucket_helper(&self) -> helper::bucket::BucketHelper { + pub fn bucket_helper(&self) -> helper::bucket::BucketHelper<'_> { helper::bucket::BucketHelper(self) } - pub fn key_helper(&self) -> helper::key::KeyHelper { + pub fn key_helper(&self) -> helper::key::KeyHelper<'_> { helper::key::KeyHelper(self) } - pub async fn locked_helper(&self) -> helper::locked::LockedHelper { + pub async fn locked_helper(&self) -> helper::locked::LockedHelper<'_> { let lock = self.bucket_lock.lock().await; helper::locked::LockedHelper(self, Some(lock)) } diff --git a/src/model/helper/error.rs b/src/model/helper/error.rs index e2ffdd68..6a78546d 100644 --- a/src/model/helper/error.rs +++ b/src/model/helper/error.rs @@ -1,24 +1,24 @@ -use err_derive::Error; +use thiserror::Error; use serde::{Deserialize, Serialize}; use garage_util::error::Error as GarageError; #[derive(Debug, Error, Serialize, Deserialize)] pub enum Error { - #[error(display = "Internal error: {}", _0)] - Internal(#[error(source)] GarageError), + #[error("Internal error: {0}")] + Internal(#[from] GarageError), - #[error(display = "Bad request: {}", _0)] + #[error("Bad request: {0}")] BadRequest(String), /// Bucket name is not valid according to AWS S3 specs - #[error(display = "Invalid bucket name: {}", _0)] + #[error("Invalid bucket name: {0}")] InvalidBucketName(String), - #[error(display = "Access key not found: {}", _0)] + #[error("Access key not found: {0}")] NoSuchAccessKey(String), - #[error(display = "Bucket not found: {}", _0)] + #[error("Bucket not found: {0}")] NoSuchBucket(String), } diff --git a/src/net/Cargo.toml b/src/net/Cargo.toml index 83b3b15b..8ff78680 100644 --- a/src/net/Cargo.toml +++ b/src/net/Cargo.toml @@ -30,7 +30,7 @@ rand.workspace = true log.workspace = true arc-swap.workspace = true -err-derive.workspace = true +thiserror.workspace = true bytes.workspace = true cfg-if.workspace = true diff --git a/src/net/endpoint.rs b/src/net/endpoint.rs index d46acc42..3ab1048a 100644 --- a/src/net/endpoint.rs +++ b/src/net/endpoint.rs @@ -159,7 +159,7 @@ where pub(crate) type DynEndpoint = Box; pub(crate) trait GenericEndpoint { - fn handle(&self, req_enc: ReqEnc, from: NodeID) -> BoxFuture>; + fn handle(&self, req_enc: ReqEnc, from: NodeID) -> BoxFuture<'_, Result>; fn drop_handler(&self); fn clone_endpoint(&self) -> DynEndpoint; } @@ -175,7 +175,7 @@ where M: Message, H: StreamingEndpointHandler + 'static, { - fn handle(&self, req_enc: ReqEnc, from: NodeID) -> BoxFuture> { + fn handle(&self, req_enc: ReqEnc, from: NodeID) -> BoxFuture<'_, Result> { async move { match self.0.handler.load_full() { None => Err(Error::NoHandler), diff --git a/src/net/error.rs b/src/net/error.rs index cddb1eaa..899fe21c 100644 --- a/src/net/error.rs +++ b/src/net/error.rs @@ -1,49 +1,49 @@ use std::io; -use err_derive::Error; +use thiserror::Error; use log::error; #[derive(Debug, Error)] pub enum Error { - #[error(display = "IO error: {}", _0)] - Io(#[error(source)] io::Error), + #[error("IO error: {0}")] + Io(#[from] io::Error), - #[error(display = "Messagepack encode error: {}", _0)] - RMPEncode(#[error(source)] rmp_serde::encode::Error), - #[error(display = "Messagepack decode error: {}", _0)] - RMPDecode(#[error(source)] rmp_serde::decode::Error), + #[error("Messagepack encode error: {0}")] + RMPEncode(#[from] rmp_serde::encode::Error), + #[error("Messagepack decode error: {0}")] + RMPDecode(#[from] rmp_serde::decode::Error), - #[error(display = "Tokio join error: {}", _0)] - TokioJoin(#[error(source)] tokio::task::JoinError), + #[error("Tokio join error: {0}")] + TokioJoin(#[from] tokio::task::JoinError), - #[error(display = "oneshot receive error: {}", _0)] - OneshotRecv(#[error(source)] tokio::sync::oneshot::error::RecvError), + #[error("oneshot receive error: {0}")] + OneshotRecv(#[from] tokio::sync::oneshot::error::RecvError), - #[error(display = "Handshake error: {}", _0)] - Handshake(#[error(source)] kuska_handshake::async_std::Error), + #[error("Handshake error: {0}")] + Handshake(#[from] kuska_handshake::async_std::Error), - #[error(display = "UTF8 error: {}", _0)] - UTF8(#[error(source)] std::string::FromUtf8Error), + #[error("UTF8 error: {0}")] + UTF8(#[from] std::string::FromUtf8Error), - #[error(display = "Framing protocol error")] + #[error("Framing protocol error")] Framing, - #[error(display = "Remote error ({:?}): {}", _0, _1)] + #[error("Remote error ({0:?}): {1}")] Remote(io::ErrorKind, String), - #[error(display = "Request ID collision")] + #[error("Request ID collision")] IdCollision, - #[error(display = "{}", _0)] + #[error("{0}")] Message(String), - #[error(display = "No handler / shutting down")] + #[error("No handler / shutting down")] NoHandler, - #[error(display = "Connection closed")] + #[error("Connection closed")] ConnectionClosed, - #[error(display = "Version mismatch: {}", _0)] + #[error("Version mismatch: {0}")] VersionMismatch(String), } diff --git a/src/rpc/Cargo.toml b/src/rpc/Cargo.toml index 1e764c77..9e886748 100644 --- a/src/rpc/Cargo.toml +++ b/src/rpc/Cargo.toml @@ -33,7 +33,7 @@ async-trait.workspace = true serde.workspace = true serde_bytes.workspace = true serde_json.workspace = true -err-derive = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } # newer version requires rust edition 2021 kube = { workspace = true, optional = true } @@ -49,5 +49,5 @@ opentelemetry.workspace = true [features] kubernetes-discovery = [ "kube", "k8s-openapi", "schemars" ] -consul-discovery = [ "reqwest", "err-derive" ] +consul-discovery = [ "reqwest", "thiserror" ] system-libs = [ "sodiumoxide/use-pkg-config" ] diff --git a/src/rpc/consul.rs b/src/rpc/consul.rs index f088bf3f..801e937f 100644 --- a/src/rpc/consul.rs +++ b/src/rpc/consul.rs @@ -3,7 +3,7 @@ use std::fs::File; use std::io::Read; use std::net::{IpAddr, SocketAddr}; -use err_derive::Error; +use thiserror::Error; use serde::{Deserialize, Serialize}; use garage_net::NodeID; @@ -219,12 +219,12 @@ impl ConsulDiscovery { /// Regroup all Consul discovery errors #[derive(Debug, Error)] pub enum ConsulError { - #[error(display = "IO error: {}", _0)] - Io(#[error(source)] std::io::Error), - #[error(display = "HTTP error: {}", _0)] - Reqwest(#[error(source)] reqwest::Error), - #[error(display = "Invalid Consul TLS configuration")] + #[error("IO error: {0}")] + Io(#[from] std::io::Error), + #[error("HTTP error: {0}")] + Reqwest(#[from] reqwest::Error), + #[error("Invalid Consul TLS configuration")] InvalidTLSConfig, - #[error(display = "Token error: {}", _0)] - Token(#[error(source)] reqwest::header::InvalidHeaderValue), + #[error("Token error: {0}")] + Token(#[from] reqwest::header::InvalidHeaderValue), } diff --git a/src/util/Cargo.toml b/src/util/Cargo.toml index 0d693a97..b5c1454f 100644 --- a/src/util/Cargo.toml +++ b/src/util/Cargo.toml @@ -21,7 +21,7 @@ arc-swap.workspace = true async-trait.workspace = true blake2.workspace = true bytesize.workspace = true -err-derive.workspace = true +thiserror.workspace = true hexdump.workspace = true xxhash-rust.workspace = true hex.workspace = true diff --git a/src/util/error.rs b/src/util/error.rs index 75fd3f9c..170d2687 100644 --- a/src/util/error.rs +++ b/src/util/error.rs @@ -2,7 +2,7 @@ use std::fmt; use std::io; -use err_derive::Error; +use thiserror::Error; use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; @@ -12,68 +12,61 @@ use crate::encode::debug_serialize; /// Regroup all Garage errors #[derive(Debug, Error)] pub enum Error { - #[error(display = "IO error: {}", _0)] - Io(#[error(source)] io::Error), + #[error("IO error: {0}")] + Io(#[from] io::Error), - #[error(display = "Hyper error: {}", _0)] - Hyper(#[error(source)] hyper::Error), + #[error("Hyper error: {0}")] + Hyper(#[from] hyper::Error), - #[error(display = "HTTP error: {}", _0)] - Http(#[error(source)] http::Error), + #[error("HTTP error: {0}")] + Http(#[from] http::Error), - #[error(display = "Invalid HTTP header value: {}", _0)] - HttpHeader(#[error(source)] http::header::ToStrError), + #[error("Invalid HTTP header value: {0}")] + HttpHeader(#[from] http::header::ToStrError), - #[error(display = "Network error: {}", _0)] - Net(#[error(source)] garage_net::error::Error), + #[error("Network error: {0}")] + Net(#[from] garage_net::error::Error), - #[error(display = "DB error: {}", _0)] - Db(#[error(source)] garage_db::Error), + #[error("DB error: {0}")] + Db(#[from] garage_db::Error), - #[error(display = "Messagepack encode error: {}", _0)] - RmpEncode(#[error(source)] rmp_serde::encode::Error), - #[error(display = "Messagepack decode error: {}", _0)] - RmpDecode(#[error(source)] rmp_serde::decode::Error), - #[error(display = "JSON error: {}", _0)] - Json(#[error(source)] serde_json::error::Error), - #[error(display = "TOML decode error: {}", _0)] - TomlDecode(#[error(source)] toml::de::Error), + #[error("Messagepack encode error: {0}")] + RmpEncode(#[from] rmp_serde::encode::Error), + #[error("Messagepack decode error: {0}")] + RmpDecode(#[from] rmp_serde::decode::Error), + #[error("JSON error: {0}")] + Json(#[from] serde_json::error::Error), + #[error("TOML decode error: {0}")] + TomlDecode(#[from] toml::de::Error), - #[error(display = "Tokio join error: {}", _0)] - TokioJoin(#[error(source)] tokio::task::JoinError), + #[error("Tokio join error: {0}")] + TokioJoin(#[from] tokio::task::JoinError), - #[error(display = "Tokio semaphore acquire error: {}", _0)] - TokioSemAcquire(#[error(source)] tokio::sync::AcquireError), + #[error("Tokio semaphore acquire error: {0}")] + TokioSemAcquire(#[from] tokio::sync::AcquireError), - #[error(display = "Tokio broadcast receive error: {}", _0)] - TokioBcastRecv(#[error(source)] tokio::sync::broadcast::error::RecvError), + #[error("Tokio broadcast receive error: {0}")] + TokioBcastRecv(#[from] tokio::sync::broadcast::error::RecvError), - #[error(display = "Remote error: {}", _0)] + #[error("Remote error: {0}")] RemoteError(String), - #[error(display = "Timeout")] + #[error("Timeout")] Timeout, - #[error( - display = "Could not reach quorum of {} (sets={:?}). {} of {} request succeeded, others returned errors: {:?}", - _0, - _1, - _2, - _3, - _4 - )] + #[error("Could not reach quorum of {0} (sets={1:?}). {2} of {3} request succeeded, others returned errors: {4:?}")] Quorum(usize, Option, usize, usize, Vec), - #[error(display = "Unexpected RPC message: {}", _0)] + #[error("Unexpected RPC message: {0}")] UnexpectedRpcMessage(String), - #[error(display = "Corrupt data: does not match hash {:?}", _0)] + #[error("Corrupt data: does not match hash {0:?}")] CorruptData(Hash), - #[error(display = "Missing block {:?}: no node returned a valid block", _0)] + #[error("Missing block {0:?}: no node returned a valid block")] MissingBlock(Hash), - #[error(display = "{}", _0)] + #[error("{0}")] Message(String), } diff --git a/src/web/Cargo.toml b/src/web/Cargo.toml index c1056509..a2daf84d 100644 --- a/src/web/Cargo.toml +++ b/src/web/Cargo.toml @@ -20,7 +20,7 @@ garage_model.workspace = true garage_util.workspace = true garage_table.workspace = true -err-derive.workspace = true +thiserror.workspace = true tracing.workspace = true percent-encoding.workspace = true diff --git a/src/web/error.rs b/src/web/error.rs index 7e6d4542..49650b1d 100644 --- a/src/web/error.rs +++ b/src/web/error.rs @@ -1,4 +1,4 @@ -use err_derive::Error; +use thiserror::Error; use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; @@ -8,15 +8,15 @@ use garage_api_common::generic_server::ApiError; #[derive(Debug, Error)] pub enum Error { /// An error received from the API crate - #[error(display = "API error: {}", _0)] + #[error("API error: {0}")] ApiError(garage_api_s3::error::Error), /// The file does not exist - #[error(display = "Not found")] + #[error("Not found")] NotFound, /// The client sent a request without host, or with unsupported method - #[error(display = "Bad request: {}", _0)] + #[error("Bad request: {0}")] BadRequest(String), } From ac851d6dee762576415541cf1b6eb5345d03ea9b Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Sat, 1 Nov 2025 18:04:54 +0100 Subject: [PATCH 63/73] fmt --- src/api/admin/error.rs | 2 +- src/api/common/common_error.rs | 2 +- src/api/k2v/error.rs | 2 +- src/api/s3/error.rs | 8 ++++---- src/model/helper/error.rs | 2 +- src/net/error.rs | 2 +- src/rpc/consul.rs | 2 +- src/web/error.rs | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/api/admin/error.rs b/src/api/admin/error.rs index 97f02156..17d4c200 100644 --- a/src/api/admin/error.rs +++ b/src/api/admin/error.rs @@ -1,8 +1,8 @@ use std::convert::TryFrom; -use thiserror::Error; use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; +use thiserror::Error; pub use garage_model::helper::error::Error as HelperError; diff --git a/src/api/common/common_error.rs b/src/api/common/common_error.rs index 1335fece..e596a6e9 100644 --- a/src/api/common/common_error.rs +++ b/src/api/common/common_error.rs @@ -1,7 +1,7 @@ use std::convert::TryFrom; -use thiserror::Error; use hyper::StatusCode; +use thiserror::Error; use garage_util::error::Error as GarageError; diff --git a/src/api/k2v/error.rs b/src/api/k2v/error.rs index c860ab98..f1937fe5 100644 --- a/src/api/k2v/error.rs +++ b/src/api/k2v/error.rs @@ -1,6 +1,6 @@ -use thiserror::Error; use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; +use thiserror::Error; use garage_api_common::common_error::{commonErrorDerivative, CommonError}; pub(crate) use garage_api_common::common_error::{helper_error_as_internal, pass_helper_error}; diff --git a/src/api/s3/error.rs b/src/api/s3/error.rs index 6f4dfb5c..64112084 100644 --- a/src/api/s3/error.rs +++ b/src/api/s3/error.rs @@ -1,8 +1,8 @@ use std::convert::TryInto; -use thiserror::Error; use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; +use thiserror::Error; use garage_model::helper::error::Error as HelperError; @@ -100,9 +100,9 @@ impl From for Error { } impl From<(http_range::HttpRangeParseError, u64)> for Error { - fn from (err: (http_range::HttpRangeParseError, u64)) -> Error { - Error::InvalidRange(err) - } + fn from(err: (http_range::HttpRangeParseError, u64)) -> Error { + Error::InvalidRange(err) + } } impl From for Error { diff --git a/src/model/helper/error.rs b/src/model/helper/error.rs index 6a78546d..bc483c7d 100644 --- a/src/model/helper/error.rs +++ b/src/model/helper/error.rs @@ -1,5 +1,5 @@ -use thiserror::Error; use serde::{Deserialize, Serialize}; +use thiserror::Error; use garage_util::error::Error as GarageError; diff --git a/src/net/error.rs b/src/net/error.rs index 899fe21c..f67794ed 100644 --- a/src/net/error.rs +++ b/src/net/error.rs @@ -1,7 +1,7 @@ use std::io; -use thiserror::Error; use log::error; +use thiserror::Error; #[derive(Debug, Error)] pub enum Error { diff --git a/src/rpc/consul.rs b/src/rpc/consul.rs index 801e937f..760e9fcb 100644 --- a/src/rpc/consul.rs +++ b/src/rpc/consul.rs @@ -3,8 +3,8 @@ use std::fs::File; use std::io::Read; use std::net::{IpAddr, SocketAddr}; -use thiserror::Error; use serde::{Deserialize, Serialize}; +use thiserror::Error; use garage_net::NodeID; diff --git a/src/web/error.rs b/src/web/error.rs index 49650b1d..aef74923 100644 --- a/src/web/error.rs +++ b/src/web/error.rs @@ -1,6 +1,6 @@ -use thiserror::Error; use hyper::header::HeaderValue; use hyper::{HeaderMap, StatusCode}; +use thiserror::Error; use garage_api_common::generic_server::ApiError; From a057ab23ea19221e9c646bc55092fe7c20648e80 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 24 Nov 2025 11:09:46 +0100 Subject: [PATCH 64/73] Update rust toolchain --- flake.lock | 16 ++++++++-------- flake.nix | 8 ++++---- nix/compile.nix | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index 2cfbfda4..211b70e0 100644 --- a/flake.lock +++ b/flake.lock @@ -50,17 +50,17 @@ }, "nixpkgs": { "locked": { - "lastModified": 1736692550, - "narHash": "sha256-7tk8xH+g0sJkKLTJFOxphJxxOjMDFMWv24nXslaU2ro=", + "lastModified": 1763977559, + "narHash": "sha256-g4MKqsIRy5yJwEsI+fYODqLUnAqIY4kZai0nldAP6EM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7c4869c47090dd7f9f1bdfb49a22aea026996815", + "rev": "cfe2c7d5b5d3032862254e68c37a6576b633d632", "type": "github" }, "original": { "owner": "NixOS", "repo": "nixpkgs", - "rev": "7c4869c47090dd7f9f1bdfb49a22aea026996815", + "rev": "cfe2c7d5b5d3032862254e68c37a6576b633d632", "type": "github" } }, @@ -80,17 +80,17 @@ ] }, "locked": { - "lastModified": 1738549608, - "narHash": "sha256-GdyT9QEUSx5k/n8kILuNy83vxxdyUfJ8jL5mMpQZWfw=", + "lastModified": 1763952169, + "narHash": "sha256-+PeDBD8P+NKauH+w7eO/QWCIp8Cx4mCfWnh9sJmy9CM=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "35c6f8c4352f995ecd53896200769f80a3e8f22d", + "rev": "ab726555a9a72e6dc80649809147823a813fa95b", "type": "github" }, "original": { "owner": "oxalica", "repo": "rust-overlay", - "rev": "35c6f8c4352f995ecd53896200769f80a3e8f22d", + "rev": "ab726555a9a72e6dc80649809147823a813fa95b", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 2fb8c48e..48880347 100644 --- a/flake.nix +++ b/flake.nix @@ -2,13 +2,13 @@ description = "Garage, an S3-compatible distributed object store for self-hosted deployments"; - # Nixpkgs 24.11 as of 2025-01-12 + # Nixpkgs 25.05 as of 2025-11-24 inputs.nixpkgs.url = - "github:NixOS/nixpkgs/7c4869c47090dd7f9f1bdfb49a22aea026996815"; + "github:NixOS/nixpkgs/cfe2c7d5b5d3032862254e68c37a6576b633d632"; - # Rust overlay as of 2025-02-03 + # Rust overlay as of 2025-11-24 inputs.rust-overlay.url = - "github:oxalica/rust-overlay/35c6f8c4352f995ecd53896200769f80a3e8f22d"; + "github:oxalica/rust-overlay/ab726555a9a72e6dc80649809147823a813fa95b"; inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; inputs.crane.url = "github:ipetkov/crane"; diff --git a/nix/compile.nix b/nix/compile.nix index 7e9f79ab..5a49526f 100644 --- a/nix/compile.nix +++ b/nix/compile.nix @@ -48,7 +48,7 @@ let inherit (pkgs) lib stdenv; - toolchainFn = (p: p.rust-bin.stable."1.82.0".default.override { + toolchainFn = (p: p.rust-bin.stable."1.91.0".default.override { targets = lib.optionals (target != null) [ rustTarget ]; extensions = [ "rust-src" From ca3b4a050d25cbfe774cb0db14aefdc61a1f2446 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 24 Nov 2025 17:03:02 +0100 Subject: [PATCH 65/73] update nixos image used in woodpecker ci --- .woodpecker/debug.yaml | 12 ++++++------ .woodpecker/publish.yaml | 4 ++-- .woodpecker/release.yaml | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.woodpecker/debug.yaml b/.woodpecker/debug.yaml index 4c729672..0f60b4e3 100644 --- a/.woodpecker/debug.yaml +++ b/.woodpecker/debug.yaml @@ -12,32 +12,32 @@ when: steps: - name: check formatting - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 commands: - nix-shell --attr devShell --run "cargo fmt -- --check" - name: build - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 commands: - nix-build -j4 --attr flakePackages.dev - name: unit + func tests (lmdb) - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 commands: - nix-build -j4 --attr flakePackages.tests-lmdb - name: unit + func tests (sqlite) - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 commands: - nix-build -j4 --attr flakePackages.tests-sqlite - name: unit + func tests (fjall) - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 commands: - nix-build -j4 --attr flakePackages.tests-fjall - name: integration tests - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 commands: - nix-build -j4 --attr flakePackages.dev - nix-shell --attr ci --run ./script/test-smoke.sh || (cat /tmp/garage.log; false) diff --git a/.woodpecker/publish.yaml b/.woodpecker/publish.yaml index 24a84463..8f3b482f 100644 --- a/.woodpecker/publish.yaml +++ b/.woodpecker/publish.yaml @@ -11,7 +11,7 @@ depends_on: steps: - name: refresh-index - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 environment: AWS_ACCESS_KEY_ID: from_secret: garagehq_aws_access_key_id @@ -22,7 +22,7 @@ steps: - nix-shell --attr ci --run "refresh_index" - name: multiarch-docker - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 environment: DOCKER_AUTH: from_secret: docker_auth diff --git a/.woodpecker/release.yaml b/.woodpecker/release.yaml index bf2bd8ba..a94a9ccf 100644 --- a/.woodpecker/release.yaml +++ b/.woodpecker/release.yaml @@ -19,17 +19,17 @@ matrix: steps: - name: build - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 commands: - nix-build --attr releasePackages.${ARCH} --argstr git_version ${CI_COMMIT_TAG:-$CI_COMMIT_SHA} - name: check is static binary - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 commands: - nix-shell --attr ci --run "./script/not-dynamic.sh result/bin/garage" - name: integration tests - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 commands: - nix-shell --attr ci --run ./script/test-smoke.sh || (cat /tmp/garage.log; false) when: @@ -39,7 +39,7 @@ steps: ARCH: i386 - name: upgrade tests - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 commands: - nix-shell --attr ci --run "./script/test-upgrade.sh v0.8.4 x86_64-unknown-linux-musl" || (cat /tmp/garage.log; false) when: @@ -47,7 +47,7 @@ steps: ARCH: amd64 - name: push static binary - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 environment: TARGET: "${TARGET}" AWS_ACCESS_KEY_ID: @@ -58,7 +58,7 @@ steps: - nix-shell --attr ci --run "to_s3" - name: docker build and publish - image: nixpkgs/nix:nixos-22.05 + image: nixpkgs/nix:nixos-24.05 environment: DOCKER_PLATFORM: "linux/${ARCH}" CONTAINER_NAME: "dxflrs/${ARCH}_garage" From ca296477f3adc024b6606712c4f47b8ef877868f Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 24 Nov 2025 17:56:28 +0100 Subject: [PATCH 66/73] disable checksums in aws cli (todo: revert in main-v2) --- script/dev-env-aws.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/script/dev-env-aws.sh b/script/dev-env-aws.sh index 808f9cf1..41f1fdde 100644 --- a/script/dev-env-aws.sh +++ b/script/dev-env-aws.sh @@ -1,6 +1,7 @@ export AWS_ACCESS_KEY_ID=`cat /tmp/garage.s3 |cut -d' ' -f1` export AWS_SECRET_ACCESS_KEY=`cat /tmp/garage.s3 |cut -d' ' -f2` export AWS_DEFAULT_REGION='garage' +export AWS_REQUEST_CHECKSUM_CALCULATION='when_required' # FUTUREWORK: set AWS_ENDPOINT_URL instead, once nixpkgs bumps awscli to >=2.13.0. function aws { command aws --endpoint-url http://127.0.0.1:3911 $@ ; } From 95693d45b20c08122c9b9cdcb259f9c70d233522 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 24 Nov 2025 18:09:53 +0100 Subject: [PATCH 67/73] run cargo fmt as a nix derivation --- .woodpecker/debug.yaml | 2 +- flake.nix | 8 ++++++++ nix/compile.nix | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.woodpecker/debug.yaml b/.woodpecker/debug.yaml index 0f60b4e3..4dc7d3c9 100644 --- a/.woodpecker/debug.yaml +++ b/.woodpecker/debug.yaml @@ -14,7 +14,7 @@ steps: - name: check formatting image: nixpkgs/nix:nixos-24.05 commands: - - nix-shell --attr devShell --run "cargo fmt -- --check" + - nix-build -j4 --attr flakePackages.fmt - name: build image: nixpkgs/nix:nixos-24.05 diff --git a/flake.nix b/flake.nix index 48880347..01a077c4 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,10 @@ inherit system nixpkgs crane rust-overlay extraTestEnv; release = false; }).garage-test; + lints = (compile { + inherit system nixpkgs crane rust-overlay; + release = false; + }); in { packages = { @@ -56,6 +60,10 @@ tests-fjall = testWith { GARAGE_TEST_INTEGRATION_DB_ENGINE = "fjall"; }; + + # lints (fmt, clippy) + fmt = lints.garage-cargo-fmt; + clippy = lints.garage-cargo-clippy; }; # ---- developpment shell, for making native builds only ---- diff --git a/nix/compile.nix b/nix/compile.nix index 5a49526f..c6df9dbd 100644 --- a/nix/compile.nix +++ b/nix/compile.nix @@ -190,4 +190,15 @@ in rec { pkgs.cacert ]; } // extraTestEnv); + + # ---- source code linting ---- + + garage-cargo-fmt = craneLib.cargoFmt (commonArgs // { + cargoExtraArgs = ""; + }); + + garage-cargo-clippy = craneLib.cargoClippy (commonArgs // { + cargoArtifacts = garage-deps; + cargoClippyExtraArgs = "--all-targets -- -D warnings"; + }); } From 511cf0c6ec3d4ab6cd5a40cd0be299765e15671e Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 24 Nov 2025 18:37:34 +0100 Subject: [PATCH 68/73] disable awscli checksumming in ci scripts required because garage.deuxfleurs.fr is still running v1.x --- shell.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell.nix b/shell.nix index cfccfe94..c3dedca8 100644 --- a/shell.nix +++ b/shell.nix @@ -34,6 +34,8 @@ in jq ]; shellHook = '' + export AWS_REQUEST_CHECKSUM_CALCULATION='when_required' + function to_s3 { aws \ --endpoint-url https://garage.deuxfleurs.fr \ From 4d124e1c76b1ffdd9e1944500c0587194a9aa05d Mon Sep 17 00:00:00 2001 From: "perrynzhou@gmail.com" Date: Wed, 10 Dec 2025 06:43:51 +0800 Subject: [PATCH 69/73] Add the parameter, which replaces . This is to accommodate different storage media such as HDD and NVMe. --- src/api/s3/put.rs | 4 +--- src/util/config.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/api/s3/put.rs b/src/api/s3/put.rs index 830a7998..5f8845e7 100644 --- a/src/api/s3/put.rs +++ b/src/api/s3/put.rs @@ -39,8 +39,6 @@ use crate::encryption::EncryptionParams; use crate::error::*; use crate::website::X_AMZ_WEBSITE_REDIRECT_LOCATION; -const PUT_BLOCKS_MAX_PARALLEL: usize = 3; - pub(crate) struct SaveStreamResult { pub(crate) version_uuid: Uuid, pub(crate) version_timestamp: u64, @@ -493,7 +491,7 @@ pub(crate) async fn read_and_put_blocks> + }; let recv_next = async { // If more than a maximum number of writes are in progress, don't add more for now - if currently_running >= PUT_BLOCKS_MAX_PARALLEL { + if currently_running >= ctx.garage.config.put_blocks_max_parallel { futures::future::pending().await } else { block_rx3.recv().await diff --git a/src/util/config.rs b/src/util/config.rs index e351185f..76b40aa9 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -45,6 +45,11 @@ pub struct Config { )] pub block_size: usize, + /// Maximum number of parallel block writes per PUT request + /// Higher values improve throughput but increase memory usage + /// Default: 3, Recommended: 10-30 for NVMe, 3-10 for HDD + #[serde(default = "default_put_blocks_max_parallel")] + pub put_blocks_max_parallel: usize, /// Number of replicas. Can be any positive integer, but uneven numbers are more favorable. /// - 1 for single-node clusters, or to disable replication /// - 3 is the recommended and supported setting. @@ -267,6 +272,9 @@ pub struct KubernetesDiscoveryConfig { pub skip_crd: bool, } +pub fn default_put_blocks_max_parallel() -> usize { + 3 +} /// Read and parse configuration pub fn read_config(config_file: PathBuf) -> Result { let config = std::fs::read_to_string(config_file)?; From e3a5ec6ef6ab1cc4741e1e26f10aa6cde591a214 Mon Sep 17 00:00:00 2001 From: "perrynzhou@gmail.com" Date: Fri, 12 Dec 2025 07:09:38 +0800 Subject: [PATCH 70/73] rename put_blocks_max_parallel to block_max_concurrent_writes_per_request and update configuration.md --- doc/book/reference-manual/configuration.md | 11 ++++++++++- src/api/s3/put.rs | 2 +- src/util/config.rs | 6 +++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/doc/book/reference-manual/configuration.md b/doc/book/reference-manual/configuration.md index c6dce089..1f583fe6 100644 --- a/doc/book/reference-manual/configuration.md +++ b/doc/book/reference-manual/configuration.md @@ -25,7 +25,7 @@ db_engine = "lmdb" block_size = "1M" block_ram_buffer_max = "256MiB" block_max_concurrent_reads = 16 - +block_max_concurrent_writes_per_request =10 lmdb_map_size = "1T" compression_level = 1 @@ -99,6 +99,7 @@ Top-level configuration options, in alphabetical order: [`allow_world_readable_secrets`](#allow_world_readable_secrets), [`block_max_concurrent_reads`](`block_max_concurrent_reads), [`block_ram_buffer_max`](#block_ram_buffer_max), +[`block_max_concurrent_writes_per_request`](#block_max_concurrent_writes_per_request), [`block_size`](#block_size), [`bootstrap_peers`](#bootstrap_peers), [`compression_level`](#compression_level), @@ -547,6 +548,14 @@ metric in Prometheus: a non-zero number of such events indicates an I/O bottleneck on HDD read speed. +#### `block_max_concurrent_writes_per_request` (since `v2.1.0`) {#block_max_concurrent_writes_per_request} + +This parameter is designed to adapt to the concurrent write performance of +different storage media.Maximum number of parallel block writes per put request +Higher values improve throughput but increase memory usage. + +Default: 3, Recommended: 10-30 for NVMe, 3-10 for HDD + #### `lmdb_map_size` {#lmdb_map_size} This parameters can be used to set the map size used by LMDB, diff --git a/src/api/s3/put.rs b/src/api/s3/put.rs index 5f8845e7..b915f2ec 100644 --- a/src/api/s3/put.rs +++ b/src/api/s3/put.rs @@ -491,7 +491,7 @@ pub(crate) async fn read_and_put_blocks> + }; let recv_next = async { // If more than a maximum number of writes are in progress, don't add more for now - if currently_running >= ctx.garage.config.put_blocks_max_parallel { + if currently_running >= ctx.garage.config.block_max_concurrent_writes_per_request { futures::future::pending().await } else { block_rx3.recv().await diff --git a/src/util/config.rs b/src/util/config.rs index 76b40aa9..eb889ebe 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -48,8 +48,8 @@ pub struct Config { /// Maximum number of parallel block writes per PUT request /// Higher values improve throughput but increase memory usage /// Default: 3, Recommended: 10-30 for NVMe, 3-10 for HDD - #[serde(default = "default_put_blocks_max_parallel")] - pub put_blocks_max_parallel: usize, + #[serde(default = "default_block_max_concurrent_writes_per_request")] + pub block_max_concurrent_writes_per_request: usize, /// Number of replicas. Can be any positive integer, but uneven numbers are more favorable. /// - 1 for single-node clusters, or to disable replication /// - 3 is the recommended and supported setting. @@ -272,7 +272,7 @@ pub struct KubernetesDiscoveryConfig { pub skip_crd: bool, } -pub fn default_put_blocks_max_parallel() -> usize { +pub fn default_block_max_concurrent_writes_per_request() -> usize { 3 } /// Read and parse configuration From dcc2fe4ac549e07bbefa1879743e7bd42296dcc5 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Tue, 16 Dec 2025 10:16:44 +0100 Subject: [PATCH 71/73] docs: fix typo in doc/book/cookbook/kubernetes.md --- doc/book/cookbook/kubernetes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/book/cookbook/kubernetes.md b/doc/book/cookbook/kubernetes.md index 1e7674d7..f5bceec8 100644 --- a/doc/book/cookbook/kubernetes.md +++ b/doc/book/cookbook/kubernetes.md @@ -11,7 +11,7 @@ Firstly clone the repository: ```bash git clone https://git.deuxfleurs.fr/Deuxfleurs/garage -cd garage/scripts/helm +cd garage/script/helm ``` Deploy with default options: From bf5290036f16563818293d3367ac84a024f46587 Mon Sep 17 00:00:00 2001 From: Pierre Mavro Date: Thu, 18 Dec 2025 18:12:22 +0100 Subject: [PATCH 72/73] feat: add service annotations --- script/helm/garage/templates/service.yaml | 6 +++++- script/helm/garage/values.yaml | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/script/helm/garage/templates/service.yaml b/script/helm/garage/templates/service.yaml index 37218872..887c90d0 100644 --- a/script/helm/garage/templates/service.yaml +++ b/script/helm/garage/templates/service.yaml @@ -4,6 +4,10 @@ metadata: name: {{ include "garage.fullname" . }} labels: {{- include "garage.labels" . | nindent 4 }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: type: {{ .Values.service.type }} ports: @@ -37,4 +41,4 @@ spec: name: metrics selector: {{- include "garage.selectorLabels" . | nindent 4 }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/script/helm/garage/values.yaml b/script/helm/garage/values.yaml index bbb60db2..5e419fe2 100644 --- a/script/helm/garage/values.yaml +++ b/script/helm/garage/values.yaml @@ -124,6 +124,8 @@ service: # - NodePort (+ Ingress) # - LoadBalancer type: ClusterIP + # -- Annotations to add to the service + annotations: {} s3: api: port: 3900 From 424d4f8d4d6cfd2dff5ab027b82fda9a233e2b31 Mon Sep 17 00:00:00 2001 From: nmstoker Date: Sat, 20 Dec 2025 13:16:38 +0000 Subject: [PATCH 73/73] Update doc/book/cookbook/binary-packages.md Correct the Arch Linux link as garage is now available in the official repos under extra, and no longer in AUR. --- doc/book/cookbook/binary-packages.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/book/cookbook/binary-packages.md b/doc/book/cookbook/binary-packages.md index 6476ff51..ce6beb7b 100644 --- a/doc/book/cookbook/binary-packages.md +++ b/doc/book/cookbook/binary-packages.md @@ -27,7 +27,7 @@ it's stable). ## Arch Linux -Garage is available in the [AUR](https://aur.archlinux.org/packages/garage). +Garage is available in the official repositories under [extra](https://archlinux.org/packages/extra/x86_64/garage). ## FreeBSD