forked from Deuxfleurs/garage
Compare commits
24 commits
feat/rocks
...
main
Author | SHA1 | Date | |
---|---|---|---|
294cb99409 | |||
|
2eb9fcae20 | ||
255b01b626 | |||
58a765c51f | |||
1c431b8457 | |||
39ac034de5 | |||
8ddb0dd485 | |||
83887a8519 | |||
0a15db6960 | |||
295237476e | |||
9d83605736 | |||
4b1a7fb5e3 | |||
b6aaebaf4c | |||
7bbc8fec50 | |||
6689800986 | |||
d2246baab7 | |||
afac1d4d4a | |||
6ca99fd02c | |||
b568bb863d | |||
b8f301a61d | |||
428ad2075d | |||
3661a597fa | |||
0fd3c0e794 | |||
4c1bf42192 |
85 changed files with 1026 additions and 1753 deletions
|
@ -16,7 +16,7 @@ steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: nixpkgs/nix:nixos-22.05
|
image: nixpkgs/nix:nixos-22.05
|
||||||
commands:
|
commands:
|
||||||
- nix-build --no-build-output --attr clippy.amd64 --argstr git_version ${CI_COMMIT_TAG:-$CI_COMMIT_SHA}
|
- nix-build --no-build-output --attr pkgs.amd64.debug --argstr git_version ${CI_COMMIT_TAG:-$CI_COMMIT_SHA}
|
||||||
|
|
||||||
- name: unit + func tests
|
- name: unit + func tests
|
||||||
image: nixpkgs/nix:nixos-22.05
|
image: nixpkgs/nix:nixos-22.05
|
||||||
|
@ -24,7 +24,7 @@ steps:
|
||||||
GARAGE_TEST_INTEGRATION_EXE: result-bin/bin/garage
|
GARAGE_TEST_INTEGRATION_EXE: result-bin/bin/garage
|
||||||
GARAGE_TEST_INTEGRATION_PATH: tmp-garage-integration
|
GARAGE_TEST_INTEGRATION_PATH: tmp-garage-integration
|
||||||
commands:
|
commands:
|
||||||
- nix-build --no-build-output --attr clippy.amd64 --argstr git_version ${CI_COMMIT_TAG:-$CI_COMMIT_SHA}
|
- nix-build --no-build-output --attr pkgs.amd64.debug --argstr git_version ${CI_COMMIT_TAG:-$CI_COMMIT_SHA}
|
||||||
- nix-build --no-build-output --attr test.amd64
|
- nix-build --no-build-output --attr test.amd64
|
||||||
- ./result/bin/garage_db-*
|
- ./result/bin/garage_db-*
|
||||||
- ./result/bin/garage_api-*
|
- ./result/bin/garage_api-*
|
||||||
|
@ -37,13 +37,11 @@ steps:
|
||||||
- GARAGE_TEST_INTEGRATION_DB_ENGINE=lmdb ./result/bin/integration-* || (cat tmp-garage-integration/stderr.log; false)
|
- GARAGE_TEST_INTEGRATION_DB_ENGINE=lmdb ./result/bin/integration-* || (cat tmp-garage-integration/stderr.log; false)
|
||||||
- nix-shell --attr ci --run "killall -9 garage" || true
|
- nix-shell --attr ci --run "killall -9 garage" || true
|
||||||
- GARAGE_TEST_INTEGRATION_DB_ENGINE=sqlite ./result/bin/integration-* || (cat tmp-garage-integration/stderr.log; false)
|
- GARAGE_TEST_INTEGRATION_DB_ENGINE=sqlite ./result/bin/integration-* || (cat tmp-garage-integration/stderr.log; false)
|
||||||
- nix-shell --attr ci --run "killall -9 garage" || true
|
|
||||||
- GARAGE_TEST_INTEGRATION_DB_ENGINE=rocksdb ./result/bin/integration-* || (cat tmp-garage-integration/stderr.log; false)
|
|
||||||
- rm result
|
- rm result
|
||||||
- rm -rv tmp-garage-integration
|
- rm -rv tmp-garage-integration
|
||||||
|
|
||||||
- name: integration tests
|
- name: integration tests
|
||||||
image: nixpkgs/nix:nixos-22.05
|
image: nixpkgs/nix:nixos-22.05
|
||||||
commands:
|
commands:
|
||||||
- nix-build --no-build-output --attr clippy.amd64 --argstr git_version ${CI_COMMIT_TAG:-$CI_COMMIT_SHA}
|
- nix-build --no-build-output --attr pkgs.amd64.debug --argstr git_version ${CI_COMMIT_TAG:-$CI_COMMIT_SHA}
|
||||||
- nix-shell --attr ci --run ./script/test-smoke.sh || (cat /tmp/garage.log; false)
|
- nix-shell --attr ci --run ./script/test-smoke.sh || (cat /tmp/garage.log; false)
|
||||||
|
|
|
@ -9,11 +9,11 @@ depends_on:
|
||||||
steps:
|
steps:
|
||||||
- name: refresh-index
|
- name: refresh-index
|
||||||
image: nixpkgs/nix:nixos-22.05
|
image: nixpkgs/nix:nixos-22.05
|
||||||
secrets:
|
environment:
|
||||||
- source: garagehq_aws_access_key_id
|
AWS_ACCESS_KEY_ID:
|
||||||
target: AWS_ACCESS_KEY_ID
|
from_secret: garagehq_aws_access_key_id
|
||||||
- source: garagehq_aws_secret_access_key
|
AWS_SECRET_ACCESS_KEY:
|
||||||
target: AWS_SECRET_ACCESS_KEY
|
from_secret: garagehq_aws_secret_access_key
|
||||||
commands:
|
commands:
|
||||||
- mkdir -p /etc/nix && cp nix/nix.conf /etc/nix/nix.conf
|
- mkdir -p /etc/nix && cp nix/nix.conf /etc/nix/nix.conf
|
||||||
- nix-shell --attr ci --run "refresh_index"
|
- nix-shell --attr ci --run "refresh_index"
|
||||||
|
|
|
@ -48,11 +48,10 @@ steps:
|
||||||
image: nixpkgs/nix:nixos-22.05
|
image: nixpkgs/nix:nixos-22.05
|
||||||
environment:
|
environment:
|
||||||
TARGET: "${TARGET}"
|
TARGET: "${TARGET}"
|
||||||
secrets:
|
AWS_ACCESS_KEY_ID:
|
||||||
- source: garagehq_aws_access_key_id
|
from_secret: garagehq_aws_access_key_id
|
||||||
target: AWS_ACCESS_KEY_ID
|
AWS_SECRET_ACCESS_KEY:
|
||||||
- source: garagehq_aws_secret_access_key
|
from_secret: garagehq_aws_secret_access_key
|
||||||
target: AWS_SECRET_ACCESS_KEY
|
|
||||||
commands:
|
commands:
|
||||||
- nix-shell --attr ci --run "to_s3"
|
- nix-shell --attr ci --run "to_s3"
|
||||||
|
|
||||||
|
|
1422
Cargo.lock
generated
1422
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
27
Cargo.nix
27
Cargo.nix
|
@ -25,6 +25,7 @@ args@{
|
||||||
target ? null,
|
target ? null,
|
||||||
codegenOpts ? null,
|
codegenOpts ? null,
|
||||||
profileOpts ? null,
|
profileOpts ? null,
|
||||||
|
cargoUnstableFlags ? null,
|
||||||
rustcLinkFlags ? null,
|
rustcLinkFlags ? null,
|
||||||
rustcBuildFlags ? null,
|
rustcBuildFlags ? null,
|
||||||
mkRustCrate,
|
mkRustCrate,
|
||||||
|
@ -51,7 +52,7 @@ else let
|
||||||
rootFeatures' = expandFeatures rootFeatures;
|
rootFeatures' = expandFeatures rootFeatures;
|
||||||
overridableMkRustCrate = f:
|
overridableMkRustCrate = f:
|
||||||
let
|
let
|
||||||
drvs = genDrvsByProfile profilesByName ({ profile, profileName }: mkRustCrate ({ inherit release profile hostPlatformCpu hostPlatformFeatures target profileOpts codegenOpts rustcLinkFlags rustcBuildFlags; } // (f profileName)));
|
drvs = genDrvsByProfile profilesByName ({ profile, profileName }: mkRustCrate ({ inherit release profile hostPlatformCpu hostPlatformFeatures target profileOpts codegenOpts cargoUnstableFlags rustcLinkFlags rustcBuildFlags; } // (f profileName)));
|
||||||
in { compileMode ? null, profileName ? decideProfile compileMode release }:
|
in { compileMode ? null, profileName ? decideProfile compileMode release }:
|
||||||
let drv = drvs.${profileName}; in if compileMode == null then drv else drv.override { inherit compileMode; };
|
let drv = drvs.${profileName}; in if compileMode == null then drv else drv.override { inherit compileMode; };
|
||||||
in
|
in
|
||||||
|
@ -1756,7 +1757,7 @@ in
|
||||||
name = "format_table";
|
name = "format_table";
|
||||||
version = "0.1.1";
|
version = "0.1.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/format-table");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
});
|
});
|
||||||
|
|
||||||
"registry+https://github.com/rust-lang/crates.io-index".futures."0.3.30" = overridableMkRustCrate (profileName: rec {
|
"registry+https://github.com/rust-lang/crates.io-index".futures."0.3.30" = overridableMkRustCrate (profileName: rec {
|
||||||
|
@ -1914,7 +1915,7 @@ in
|
||||||
name = "garage";
|
name = "garage";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/garage");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
features = builtins.concatLists [
|
features = builtins.concatLists [
|
||||||
(lib.optional (rootFeatures' ? "garage/bundled-libs" || rootFeatures' ? "garage/default") "bundled-libs")
|
(lib.optional (rootFeatures' ? "garage/bundled-libs" || rootFeatures' ? "garage/default") "bundled-libs")
|
||||||
(lib.optional (rootFeatures' ? "garage/consul-discovery") "consul-discovery")
|
(lib.optional (rootFeatures' ? "garage/consul-discovery") "consul-discovery")
|
||||||
|
@ -1992,7 +1993,7 @@ in
|
||||||
name = "garage_api";
|
name = "garage_api";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/api");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
features = builtins.concatLists [
|
features = builtins.concatLists [
|
||||||
(lib.optional (rootFeatures' ? "garage/default" || rootFeatures' ? "garage/k2v" || rootFeatures' ? "garage_api/k2v") "k2v")
|
(lib.optional (rootFeatures' ? "garage/default" || rootFeatures' ? "garage/k2v" || rootFeatures' ? "garage_api/k2v") "k2v")
|
||||||
(lib.optional (rootFeatures' ? "garage/default" || rootFeatures' ? "garage/metrics" || rootFeatures' ? "garage_api/metrics") "metrics")
|
(lib.optional (rootFeatures' ? "garage/default" || rootFeatures' ? "garage/metrics" || rootFeatures' ? "garage_api/metrics") "metrics")
|
||||||
|
@ -2056,7 +2057,7 @@ in
|
||||||
name = "garage_block";
|
name = "garage_block";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/block");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
features = builtins.concatLists [
|
features = builtins.concatLists [
|
||||||
(lib.optional (rootFeatures' ? "garage/system-libs" || rootFeatures' ? "garage_block/system-libs") "system-libs")
|
(lib.optional (rootFeatures' ? "garage/system-libs" || rootFeatures' ? "garage_block/system-libs") "system-libs")
|
||||||
];
|
];
|
||||||
|
@ -2089,7 +2090,7 @@ in
|
||||||
name = "garage_db";
|
name = "garage_db";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/db");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
features = builtins.concatLists [
|
features = builtins.concatLists [
|
||||||
(lib.optional (rootFeatures' ? "garage/bundled-libs" || rootFeatures' ? "garage/default" || rootFeatures' ? "garage_db/bundled-libs") "bundled-libs")
|
(lib.optional (rootFeatures' ? "garage/bundled-libs" || rootFeatures' ? "garage/default" || rootFeatures' ? "garage_db/bundled-libs") "bundled-libs")
|
||||||
(lib.optional (rootFeatures' ? "garage_db/default") "default")
|
(lib.optional (rootFeatures' ? "garage_db/default") "default")
|
||||||
|
@ -2118,7 +2119,7 @@ in
|
||||||
name = "garage_model";
|
name = "garage_model";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/model");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
features = builtins.concatLists [
|
features = builtins.concatLists [
|
||||||
(lib.optional (rootFeatures' ? "garage_model/default") "default")
|
(lib.optional (rootFeatures' ? "garage_model/default") "default")
|
||||||
(lib.optional (rootFeatures' ? "garage/default" || rootFeatures' ? "garage/k2v" || rootFeatures' ? "garage_api/k2v" || rootFeatures' ? "garage_model/k2v") "k2v")
|
(lib.optional (rootFeatures' ? "garage/default" || rootFeatures' ? "garage/k2v" || rootFeatures' ? "garage_api/k2v" || rootFeatures' ? "garage_model/k2v") "k2v")
|
||||||
|
@ -2157,7 +2158,7 @@ in
|
||||||
name = "garage_net";
|
name = "garage_net";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/net");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
features = builtins.concatLists [
|
features = builtins.concatLists [
|
||||||
[ "default" ]
|
[ "default" ]
|
||||||
(lib.optional (rootFeatures' ? "garage_net/opentelemetry" || rootFeatures' ? "garage_net/telemetry") "opentelemetry")
|
(lib.optional (rootFeatures' ? "garage_net/opentelemetry" || rootFeatures' ? "garage_net/telemetry") "opentelemetry")
|
||||||
|
@ -2194,7 +2195,7 @@ in
|
||||||
name = "garage_rpc";
|
name = "garage_rpc";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/rpc");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
features = builtins.concatLists [
|
features = builtins.concatLists [
|
||||||
(lib.optional (rootFeatures' ? "garage/consul-discovery" || rootFeatures' ? "garage_rpc/consul-discovery") "consul-discovery")
|
(lib.optional (rootFeatures' ? "garage/consul-discovery" || rootFeatures' ? "garage_rpc/consul-discovery") "consul-discovery")
|
||||||
(lib.optional (rootFeatures' ? "garage/consul-discovery" || rootFeatures' ? "garage_rpc/consul-discovery" || rootFeatures' ? "garage_rpc/err-derive") "err-derive")
|
(lib.optional (rootFeatures' ? "garage/consul-discovery" || rootFeatures' ? "garage_rpc/consul-discovery" || rootFeatures' ? "garage_rpc/err-derive") "err-derive")
|
||||||
|
@ -2243,7 +2244,7 @@ in
|
||||||
name = "garage_table";
|
name = "garage_table";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/table");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
dependencies = {
|
dependencies = {
|
||||||
arc_swap = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".arc-swap."1.6.0" { inherit profileName; }).out;
|
arc_swap = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".arc-swap."1.6.0" { inherit profileName; }).out;
|
||||||
async_trait = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".async-trait."0.1.77" { profileName = "__noProfile"; }).out;
|
async_trait = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".async-trait."0.1.77" { profileName = "__noProfile"; }).out;
|
||||||
|
@ -2268,7 +2269,7 @@ in
|
||||||
name = "garage_util";
|
name = "garage_util";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/util");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
features = builtins.concatLists [
|
features = builtins.concatLists [
|
||||||
(lib.optional (rootFeatures' ? "garage/default" || rootFeatures' ? "garage/k2v" || rootFeatures' ? "garage_api/k2v" || rootFeatures' ? "garage_model/k2v" || rootFeatures' ? "garage_util/k2v") "k2v")
|
(lib.optional (rootFeatures' ? "garage/default" || rootFeatures' ? "garage/k2v" || rootFeatures' ? "garage_api/k2v" || rootFeatures' ? "garage_model/k2v" || rootFeatures' ? "garage_util/k2v") "k2v")
|
||||||
];
|
];
|
||||||
|
@ -2312,7 +2313,7 @@ in
|
||||||
name = "garage_web";
|
name = "garage_web";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/web");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
dependencies = {
|
dependencies = {
|
||||||
err_derive = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".err-derive."0.3.1" { profileName = "__noProfile"; }).out;
|
err_derive = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".err-derive."0.3.1" { profileName = "__noProfile"; }).out;
|
||||||
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.30" { inherit profileName; }).out;
|
futures = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.3.30" { inherit profileName; }).out;
|
||||||
|
@ -3148,7 +3149,7 @@ in
|
||||||
name = "k2v-client";
|
name = "k2v-client";
|
||||||
version = "0.0.4";
|
version = "0.0.4";
|
||||||
registry = "unknown";
|
registry = "unknown";
|
||||||
src = fetchCrateLocal (workspaceSrc + "/src/k2v-client");
|
src = fetchCrateLocal workspaceSrc;
|
||||||
features = builtins.concatLists [
|
features = builtins.concatLists [
|
||||||
(lib.optional (rootFeatures' ? "k2v-client/clap" || rootFeatures' ? "k2v-client/cli") "clap")
|
(lib.optional (rootFeatures' ? "k2v-client/clap" || rootFeatures' ? "k2v-client/cli") "clap")
|
||||||
(lib.optional (rootFeatures' ? "k2v-client/cli") "cli")
|
(lib.optional (rootFeatures' ? "k2v-client/cli") "cli")
|
||||||
|
|
|
@ -61,7 +61,6 @@ md-5 = "0.10"
|
||||||
mktemp = "0.5"
|
mktemp = "0.5"
|
||||||
nix = { version = "0.27", default-features = false, features = ["fs"] }
|
nix = { version = "0.27", default-features = false, features = ["fs"] }
|
||||||
nom = "7.1"
|
nom = "7.1"
|
||||||
num_cpus = "1.0"
|
|
||||||
parse_duration = "2.1"
|
parse_duration = "2.1"
|
||||||
pin-project = "1.0.12"
|
pin-project = "1.0.12"
|
||||||
pnet_datalink = "0.34"
|
pnet_datalink = "0.34"
|
||||||
|
@ -86,7 +85,6 @@ heed = { version = "0.11", default-features = false, features = ["lmdb"] }
|
||||||
rusqlite = "0.31.0"
|
rusqlite = "0.31.0"
|
||||||
r2d2 = "0.8"
|
r2d2 = "0.8"
|
||||||
r2d2_sqlite = "0.24"
|
r2d2_sqlite = "0.24"
|
||||||
rocksdb = { version = "0.22", features = ["multi-threaded-cf"] }
|
|
||||||
|
|
||||||
async-compression = { version = "0.4", features = ["tokio", "zstd"] }
|
async-compression = { version = "0.4", features = ["tokio", "zstd"] }
|
||||||
zstd = { version = "0.13", default-features = false }
|
zstd = { version = "0.13", default-features = false }
|
||||||
|
|
|
@ -45,11 +45,4 @@ in {
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
clippy = {
|
|
||||||
amd64 = (compile {
|
|
||||||
inherit system git_version pkgsSrc cargo2nixOverlay;
|
|
||||||
target = "x86_64-unknown-linux-musl";
|
|
||||||
compiler = "clippy";
|
|
||||||
}).workspace.garage { compileMode = "build"; };
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ For instance here you could write just `garage layout assign -z dc1 -c 1G 563e`.
|
||||||
The layout then has to be applied to the cluster, using:
|
The layout then has to be applied to the cluster, using:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
garage layout apply
|
garage layout apply --version 1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ Check [our s3 compatibility list](@/documentation/reference-manual/s3-compatibil
|
||||||
|
|
||||||
### Other tools for interacting with Garage
|
### Other tools for interacting with Garage
|
||||||
|
|
||||||
The following tools can also be used to send and recieve files from/to Garage:
|
The following tools can also be used to send and receive files from/to Garage:
|
||||||
|
|
||||||
- [minio-client](@/documentation/connect/cli.md#minio-client)
|
- [minio-client](@/documentation/connect/cli.md#minio-client)
|
||||||
- [s3cmd](@/documentation/connect/cli.md#s3cmd)
|
- [s3cmd](@/documentation/connect/cli.md#s3cmd)
|
||||||
|
|
|
@ -16,6 +16,7 @@ data_dir = "/var/lib/garage/data"
|
||||||
metadata_fsync = true
|
metadata_fsync = true
|
||||||
data_fsync = false
|
data_fsync = false
|
||||||
disable_scrub = false
|
disable_scrub = false
|
||||||
|
use_local_tz = false
|
||||||
metadata_auto_snapshot_interval = "6h"
|
metadata_auto_snapshot_interval = "6h"
|
||||||
|
|
||||||
db_engine = "lmdb"
|
db_engine = "lmdb"
|
||||||
|
@ -99,6 +100,7 @@ Top-level configuration options:
|
||||||
[`data_fsync`](#data_fsync),
|
[`data_fsync`](#data_fsync),
|
||||||
[`db_engine`](#db_engine),
|
[`db_engine`](#db_engine),
|
||||||
[`disable_scrub`](#disable_scrub),
|
[`disable_scrub`](#disable_scrub),
|
||||||
|
[`use_local_tz`](#use_local_tz),
|
||||||
[`lmdb_map_size`](#lmdb_map_size),
|
[`lmdb_map_size`](#lmdb_map_size),
|
||||||
[`metadata_auto_snapshot_interval`](#metadata_auto_snapshot_interval),
|
[`metadata_auto_snapshot_interval`](#metadata_auto_snapshot_interval),
|
||||||
[`metadata_dir`](#metadata_dir),
|
[`metadata_dir`](#metadata_dir),
|
||||||
|
@ -427,6 +429,13 @@ you should delete it from the data directory and then call `garage repair
|
||||||
blocks` on the node to ensure that it re-obtains a copy from another node on
|
blocks` on the node to ensure that it re-obtains a copy from another node on
|
||||||
the network.
|
the network.
|
||||||
|
|
||||||
|
#### `use_local_tz` {#use_local_tz}
|
||||||
|
|
||||||
|
By default, Garage runs the lifecycle worker every day at midnight in UTC. Set the
|
||||||
|
`use_local_tz` configuration value to `true` if you want Garage to run the
|
||||||
|
lifecycle worker at midnight in your local timezone. If you have multiple nodes,
|
||||||
|
you should also ensure that each node has the same timezone configuration.
|
||||||
|
|
||||||
#### `block_size` {#block_size}
|
#### `block_size` {#block_size}
|
||||||
|
|
||||||
Garage splits stored objects in consecutive chunks of size `block_size`
|
Garage splits stored objects in consecutive chunks of size `block_size`
|
||||||
|
|
|
@ -61,7 +61,7 @@ directed to a Garage cluster can be handled independently of one another instead
|
||||||
of going through a central bottleneck (the leader node).
|
of going through a central bottleneck (the leader node).
|
||||||
As a consequence, requests can be handled much faster, even in cases where latency
|
As a consequence, requests can be handled much faster, even in cases where latency
|
||||||
between cluster nodes is important (see our [benchmarks](@/documentation/design/benchmarks/index.md) for data on this).
|
between cluster nodes is important (see our [benchmarks](@/documentation/design/benchmarks/index.md) for data on this).
|
||||||
This is particularly usefull when nodes are far from one another and talk to one other through standard Internet connections.
|
This is particularly useful when nodes are far from one another and talk to one other through standard Internet connections.
|
||||||
|
|
||||||
### Web server for static websites
|
### Web server for static websites
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,7 @@ table_merkle_updater_todo_queue_length{table_name="block_ref"} 0
|
||||||
|
|
||||||
#### `table_sync_items_received`, `table_sync_items_sent` (counters)
|
#### `table_sync_items_received`, `table_sync_items_sent` (counters)
|
||||||
|
|
||||||
Number of data items sent to/recieved from other nodes during resync procedures
|
Number of data items sent to/received from other nodes during resync procedures
|
||||||
|
|
||||||
```
|
```
|
||||||
table_sync_items_received{from="<remote node>",table_name="bucket_v2"} 3
|
table_sync_items_received{from="<remote node>",table_name="bucket_v2"} 3
|
||||||
|
|
|
@ -42,7 +42,7 @@ The general principle are similar, but details have not been updated.**
|
||||||
A version is defined by the existence of at least one entry in the blocks table for a certain version UUID.
|
A version is defined by the existence of at least one entry in the blocks table for a certain version UUID.
|
||||||
We must keep the following invariant: if a version exists in the blocks table, it has to be referenced in the objects table.
|
We must keep the following invariant: if a version exists in the blocks table, it has to be referenced in the objects table.
|
||||||
We explicitly manage concurrent versions of an object: the version timestamp and version UUID columns are index columns, thus we may have several concurrent versions of an object.
|
We explicitly manage concurrent versions of an object: the version timestamp and version UUID columns are index columns, thus we may have several concurrent versions of an object.
|
||||||
Important: before deleting an older version from the objects table, we must make sure that we did a successfull delete of the blocks of that version from the blocks table.
|
Important: before deleting an older version from the objects table, we must make sure that we did a successful delete of the blocks of that version from the blocks table.
|
||||||
|
|
||||||
Thus, the workflow for reading an object is as follows:
|
Thus, the workflow for reading an object is as follows:
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ Known issue: if someone is reading from a version that we want to delete and the
|
||||||
Usefull metadata:
|
Usefull metadata:
|
||||||
|
|
||||||
- list of versions that reference this block in the Casandra table, so that we can do GC by checking in Cassandra that the lines still exist
|
- list of versions that reference this block in the Casandra table, so that we can do GC by checking in Cassandra that the lines still exist
|
||||||
- list of other nodes that we know have acknowledged a write of this block, usefull in the rebalancing algorithm
|
- list of other nodes that we know have acknowledged a write of this block, useful in the rebalancing algorithm
|
||||||
|
|
||||||
Write strategy: have a single thread that does all write IO so that it is serialized (or have several threads that manage independent parts of the hash space). When writing a blob, write it to a temporary file, close, then rename so that a concurrent read gets a consistent result (either not found or found with whole content).
|
Write strategy: have a single thread that does all write IO so that it is serialized (or have several threads that manage independent parts of the hash space). When writing a blob, write it to a temporary file, close, then rename so that a concurrent read gets a consistent result (either not found or found with whole content).
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ The migration steps are as follows:
|
||||||
5. Turn off Garage 0.3
|
5. Turn off Garage 0.3
|
||||||
|
|
||||||
6. Backup metadata folders if you can (i.e. if you have space to do it
|
6. Backup metadata folders if you can (i.e. if you have space to do it
|
||||||
somewhere). Backuping data folders could also be usefull but that's much
|
somewhere). Backuping data folders could also be useful but that's much
|
||||||
harder to do. If your filesystem supports snapshots, this could be a good
|
harder to do. If your filesystem supports snapshots, this could be a good
|
||||||
time to use them.
|
time to use them.
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ There are two reasons for this:
|
||||||
|
|
||||||
Reminder: rules of simplicity, concerning changes to Garage's source code.
|
Reminder: rules of simplicity, concerning changes to Garage's source code.
|
||||||
Always question what we are doing.
|
Always question what we are doing.
|
||||||
Never do anything just because it looks nice or because we "think" it might be usefull at some later point but without knowing precisely why/when.
|
Never do anything just because it looks nice or because we "think" it might be useful at some later point but without knowing precisely why/when.
|
||||||
Only do things that make perfect sense in the context of what we currently know.
|
Only do things that make perfect sense in the context of what we currently know.
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
|
@ -562,7 +562,7 @@ token>", v: ["<value1>", ...] }`, with the following fields:
|
||||||
- in case of concurrent update and deletion, a `null` is added to the list of concurrent values
|
- in case of concurrent update and deletion, a `null` is added to the list of concurrent values
|
||||||
|
|
||||||
- if the `tombstones` query parameter is set to `true`, tombstones are returned
|
- if the `tombstones` query parameter is set to `true`, tombstones are returned
|
||||||
for items that have been deleted (this can be usefull for inserting after an
|
for items that have been deleted (this can be useful for inserting after an
|
||||||
item that has been deleted, so that the insert is not considered
|
item that has been deleted, so that the insert is not considered
|
||||||
concurrent with the delete). Tombstones are returned as tuples in the
|
concurrent with the delete). Tombstones are returned as tuples in the
|
||||||
same format with only `null` values
|
same format with only `null` values
|
||||||
|
|
50
flake.lock
50
flake.lock
|
@ -12,17 +12,17 @@
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1666087781,
|
"lastModified": 1705129117,
|
||||||
"narHash": "sha256-trKVdjMZ8mNkGfLcY5LsJJGtdV3xJDZnMVrkFjErlcs=",
|
"narHash": "sha256-LgdDHibvimzYhxBK3kxCk2gAL7k4Hyigl5KI0X9cijA=",
|
||||||
"owner": "Alexis211",
|
"owner": "cargo2nix",
|
||||||
"repo": "cargo2nix",
|
"repo": "cargo2nix",
|
||||||
"rev": "a7a61179b66054904ef6a195d8da736eaaa06c36",
|
"rev": "ae19a9e1f8f0880c088ea155ab66cee1fa001f59",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "Alexis211",
|
"owner": "cargo2nix",
|
||||||
"repo": "cargo2nix",
|
"repo": "cargo2nix",
|
||||||
"rev": "a7a61179b66054904ef6a195d8da736eaaa06c36",
|
"rev": "ae19a9e1f8f0880c088ea155ab66cee1fa001f59",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -58,33 +58,17 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1724395761,
|
"lastModified": 1736692550,
|
||||||
"narHash": "sha256-zRkDV/nbrnp3Y8oCADf5ETl1sDrdmAW6/bBVJ8EbIdQ=",
|
"narHash": "sha256-7tk8xH+g0sJkKLTJFOxphJxxOjMDFMWv24nXslaU2ro=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "ae815cee91b417be55d43781eb4b73ae1ecc396c",
|
"rev": "7c4869c47090dd7f9f1bdfb49a22aea026996815",
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixpkgs-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1724681257,
|
|
||||||
"narHash": "sha256-EJRuc5Qp7yfXko5ZNeEMYAs4DzAvkCyALuJ/tGllhN4=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "0239aeb2f82ea27ccd6b61582b8f7fb8750eeada",
|
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "0239aeb2f82ea27ccd6b61582b8f7fb8750eeada",
|
"rev": "7c4869c47090dd7f9f1bdfb49a22aea026996815",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -96,24 +80,28 @@
|
||||||
"cargo2nix",
|
"cargo2nix",
|
||||||
"flake-utils"
|
"flake-utils"
|
||||||
],
|
],
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": [
|
||||||
|
"cargo2nix",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1724638882,
|
"lastModified": 1736649126,
|
||||||
"narHash": "sha256-ap2jIQi/FuUHR6HCht6ASWhoz8EiB99XmI8Esot38VE=",
|
"narHash": "sha256-XCw5sv/ePsroqiF3lJM6Y2X9EhPdHeE47gr3Q8b0UQw=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "19b70f147b9c67a759e35824b241f1ed92e46694",
|
"rev": "162ab0edc2936508470199b2e8e6c444a2535019",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
|
"rev": "162ab0edc2936508470199b2e8e6c444a2535019",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
flake.nix
13
flake.nix
|
@ -2,24 +2,27 @@
|
||||||
description =
|
description =
|
||||||
"Garage, an S3-compatible distributed object store for self-hosted deployments";
|
"Garage, an S3-compatible distributed object store for self-hosted deployments";
|
||||||
|
|
||||||
# Nixpkgs 24.05 as of 2024-08-26 has rustc v1.77
|
# Nixpkgs 24.11 as of 2025-01-12 has rustc v1.82
|
||||||
inputs.nixpkgs.url =
|
inputs.nixpkgs.url =
|
||||||
"github:NixOS/nixpkgs/0239aeb2f82ea27ccd6b61582b8f7fb8750eeada";
|
"github:NixOS/nixpkgs/7c4869c47090dd7f9f1bdfb49a22aea026996815";
|
||||||
|
|
||||||
inputs.flake-compat.url = "github:nix-community/flake-compat";
|
inputs.flake-compat.url = "github:nix-community/flake-compat";
|
||||||
|
|
||||||
inputs.cargo2nix = {
|
inputs.cargo2nix = {
|
||||||
# As of 2022-10-18: two small patches over unstable branch, one for clippy and one to fix feature detection
|
# As of 2022-10-18: two small patches over unstable branch, one for clippy and one to fix feature detection
|
||||||
url = "github:Alexis211/cargo2nix/a7a61179b66054904ef6a195d8da736eaaa06c36";
|
#url = "github:Alexis211/cargo2nix/a7a61179b66054904ef6a195d8da736eaaa06c36";
|
||||||
|
|
||||||
# As of 2023-04-25:
|
# As of 2023-04-25:
|
||||||
# - my two patches were merged into unstable (one for clippy and one to "fix" feature detection)
|
# - my two patches were merged into unstable (one for clippy and one to "fix" feature detection)
|
||||||
# - rustc v1.66
|
# - rustc v1.66
|
||||||
# url = "github:cargo2nix/cargo2nix/8fb57a670f7993bfc24099c33eb9c5abb51f29a2";
|
# url = "github:cargo2nix/cargo2nix/8fb57a670f7993bfc24099c33eb9c5abb51f29a2";
|
||||||
|
|
||||||
# Rust overlay as of 2024-08-26
|
# Mainline cargo2nix as of of 2025-01-12 (branch release-0.11.0)
|
||||||
|
url = "github:cargo2nix/cargo2nix/ae19a9e1f8f0880c088ea155ab66cee1fa001f59";
|
||||||
|
|
||||||
|
# Rust overlay as of 2025-01-12
|
||||||
inputs.rust-overlay.url =
|
inputs.rust-overlay.url =
|
||||||
"github:oxalica/rust-overlay/19b70f147b9c67a759e35824b241f1ed92e46694";
|
"github:oxalica/rust-overlay/162ab0edc2936508470199b2e8e6c444a2535019";
|
||||||
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
inputs.flake-compat.follows = "flake-compat";
|
inputs.flake-compat.follows = "flake-compat";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ system, target ? null, pkgsSrc, cargo2nixOverlay, compiler ? "rustc"
|
{ system, target ? null, pkgsSrc, cargo2nixOverlay
|
||||||
, release ? false, git_version ? null, features ? null, }:
|
, release ? false, git_version ? null, features ? null, }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -20,24 +20,10 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
toolchainOptions = {
|
toolchainOptions = {
|
||||||
rustVersion = "1.77.0";
|
rustVersion = "1.78.0";
|
||||||
extraRustComponents = [ "clippy" ];
|
extraRustComponents = [ "clippy" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
buildEnv = (drv:
|
|
||||||
{
|
|
||||||
rustc = drv.setBuildEnv;
|
|
||||||
clippy = ''
|
|
||||||
${drv.setBuildEnv or ""}
|
|
||||||
echo
|
|
||||||
echo --- BUILDING WITH CLIPPY ---
|
|
||||||
echo
|
|
||||||
|
|
||||||
export NIX_RUST_BUILD_FLAGS="''${NIX_RUST_BUILD_FLAGS} --deny warnings"
|
|
||||||
export RUSTC="''${CLIPPY_DRIVER}"
|
|
||||||
'';
|
|
||||||
}.${compiler});
|
|
||||||
|
|
||||||
/* Cargo2nix provides many overrides by default, you can take inspiration from them:
|
/* Cargo2nix provides many overrides by default, you can take inspiration from them:
|
||||||
https://github.com/cargo2nix/cargo2nix/blob/master/overlay/overrides.nix
|
https://github.com/cargo2nix/cargo2nix/blob/master/overlay/overrides.nix
|
||||||
|
|
||||||
|
@ -46,9 +32,7 @@ let
|
||||||
*/
|
*/
|
||||||
packageOverrides = pkgs:
|
packageOverrides = pkgs:
|
||||||
pkgs.rustBuilder.overrides.all ++ [
|
pkgs.rustBuilder.overrides.all ++ [
|
||||||
/* [1] We add some logic to compile our crates with clippy, it provides us many additional lints
|
/* [1] We need to alter Nix hardening to make static binaries: PIE,
|
||||||
|
|
||||||
[2] We need to alter Nix hardening to make static binaries: PIE,
|
|
||||||
Position Independent Executables seems to be supported only on amd64. Having
|
Position Independent Executables seems to be supported only on amd64. Having
|
||||||
this flag set either 1. make our executables crash or 2. compile as dynamic on some platforms.
|
this flag set either 1. make our executables crash or 2. compile as dynamic on some platforms.
|
||||||
Here, we deactivate it. Later (find `codegenOpts`), we reactivate it for supported targets
|
Here, we deactivate it. Later (find `codegenOpts`), we reactivate it for supported targets
|
||||||
|
@ -56,11 +40,11 @@ let
|
||||||
PIE is a feature used by ASLR, which helps mitigate security issues.
|
PIE is a feature used by ASLR, which helps mitigate security issues.
|
||||||
Learn more about Nix Hardening at: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/cc-wrapper/add-hardening.sh
|
Learn more about Nix Hardening at: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/cc-wrapper/add-hardening.sh
|
||||||
|
|
||||||
[3] We want to inject the git version while keeping the build deterministic.
|
[2] We want to inject the git version while keeping the build deterministic.
|
||||||
As we do not want to consider the .git folder as part of the input source,
|
As we do not want to consider the .git folder as part of the input source,
|
||||||
we ask the user (the CI often) to pass the value to Nix.
|
we ask the user (the CI often) to pass the value to Nix.
|
||||||
|
|
||||||
[4] We don't want libsodium-sys and zstd-sys to try to use pkgconfig to build against a system library.
|
[3] We don't want libsodium-sys and zstd-sys to try to use pkgconfig to build against a system library.
|
||||||
However the features to do so get activated for some reason (due to a bug in cargo2nix?),
|
However the features to do so get activated for some reason (due to a bug in cargo2nix?),
|
||||||
so disable them manually here.
|
so disable them manually here.
|
||||||
*/
|
*/
|
||||||
|
@ -68,7 +52,7 @@ let
|
||||||
name = "garage";
|
name = "garage";
|
||||||
overrideAttrs = drv:
|
overrideAttrs = drv:
|
||||||
(if git_version != null then {
|
(if git_version != null then {
|
||||||
# [3]
|
# [2]
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
${drv.preConfigure or ""}
|
${drv.preConfigure or ""}
|
||||||
export GIT_VERSION="${git_version}"
|
export GIT_VERSION="${git_version}"
|
||||||
|
@ -76,86 +60,21 @@ let
|
||||||
} else
|
} else
|
||||||
{ }) // {
|
{ }) // {
|
||||||
# [1]
|
# [1]
|
||||||
setBuildEnv = (buildEnv drv);
|
|
||||||
# [2]
|
|
||||||
hardeningDisable = [ "pie" ];
|
hardeningDisable = [ "pie" ];
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
|
||||||
name = "garage_rpc";
|
|
||||||
overrideAttrs = drv: { # [1]
|
|
||||||
setBuildEnv = (buildEnv drv);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
|
||||||
name = "garage_db";
|
|
||||||
overrideAttrs = drv: { # [1]
|
|
||||||
setBuildEnv = (buildEnv drv);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
|
||||||
name = "garage_util";
|
|
||||||
overrideAttrs = drv: { # [1]
|
|
||||||
setBuildEnv = (buildEnv drv);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
|
||||||
name = "garage_table";
|
|
||||||
overrideAttrs = drv: { # [1]
|
|
||||||
setBuildEnv = (buildEnv drv);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
|
||||||
name = "garage_block";
|
|
||||||
overrideAttrs = drv: { # [1]
|
|
||||||
setBuildEnv = (buildEnv drv);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
|
||||||
name = "garage_model";
|
|
||||||
overrideAttrs = drv: { # [1]
|
|
||||||
setBuildEnv = (buildEnv drv);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
|
||||||
name = "garage_api";
|
|
||||||
overrideAttrs = drv: { # [1]
|
|
||||||
setBuildEnv = (buildEnv drv);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
|
||||||
name = "garage_web";
|
|
||||||
overrideAttrs = drv: { # [1]
|
|
||||||
setBuildEnv = (buildEnv drv);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
|
||||||
name = "k2v-client";
|
|
||||||
overrideAttrs = drv: { # [1]
|
|
||||||
setBuildEnv = (buildEnv drv);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
(pkgs.rustBuilder.rustLib.makeOverride {
|
||||||
name = "libsodium-sys";
|
name = "libsodium-sys";
|
||||||
overrideArgs = old: {
|
overrideArgs = old: {
|
||||||
features = [ ]; # [4]
|
features = [ ]; # [3]
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(pkgs.rustBuilder.rustLib.makeOverride {
|
(pkgs.rustBuilder.rustLib.makeOverride {
|
||||||
name = "zstd-sys";
|
name = "zstd-sys";
|
||||||
overrideArgs = old: {
|
overrideArgs = old: {
|
||||||
features = [ ]; # [4]
|
features = [ ]; # [3]
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
|
@ -15,7 +15,7 @@ type: application
|
||||||
# This is the chart version. This version number should be incremented each time you make changes
|
# 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.
|
# to the chart and its templates, including the app version.
|
||||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
version: 0.5.1
|
version: 0.6.0
|
||||||
|
|
||||||
# This is the version number of the application being deployed. This version number should be
|
# 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
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
|
|
86
script/helm/garage/README.md
Normal file
86
script/helm/garage/README.md
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
S3-compatible object store for small self-hosted geo-distributed deployments
|
||||||
|
|
||||||
|
## Values
|
||||||
|
|
||||||
|
| Key | Type | Default | Description |
|
||||||
|
|-----|------|---------|-------------|
|
||||||
|
| affinity | object | `{}` | |
|
||||||
|
| deployment.kind | string | `"StatefulSet"` | Switchable to DaemonSet |
|
||||||
|
| deployment.podManagementPolicy | string | `"OrderedReady"` | If using statefulset, allow Parallel or OrderedReady (default) |
|
||||||
|
| deployment.replicaCount | int | `3` | Number of StatefulSet replicas/garage nodes to start |
|
||||||
|
| environment | object | `{}` | |
|
||||||
|
| extraVolumeMounts | object | `{}` | |
|
||||||
|
| extraVolumes | object | `{}` | |
|
||||||
|
| fullnameOverride | string | `""` | |
|
||||||
|
| garage.blockSize | string | `"1048576"` | Defaults is 1MB An increase can result in better performance in certain scenarios https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#block-size |
|
||||||
|
| garage.bootstrapPeers | list | `[]` | This is not required if you use the integrated kubernetes discovery |
|
||||||
|
| garage.compressionLevel | string | `"1"` | zstd compression level of stored blocks https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#compression-level |
|
||||||
|
| garage.dbEngine | string | `"lmdb"` | Can be changed for better performance on certain systems https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#db-engine-since-v0-8-0 |
|
||||||
|
| 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.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 |
|
||||||
|
| garage.s3.api.region | string | `"garage"` | |
|
||||||
|
| garage.s3.api.rootDomain | string | `".s3.garage.tld"` | |
|
||||||
|
| garage.s3.web.index | string | `"index.html"` | |
|
||||||
|
| garage.s3.web.rootDomain | string | `".web.garage.tld"` | |
|
||||||
|
| image.pullPolicy | string | `"IfNotPresent"` | |
|
||||||
|
| image.repository | string | `"dxflrs/amd64_garage"` | default to amd64 docker image |
|
||||||
|
| image.tag | string | `""` | set the image tag, please prefer using the chart version and not this to avoid compatibility issues |
|
||||||
|
| imagePullSecrets | list | `[]` | set if you need credentials to pull your custom image |
|
||||||
|
| ingress.s3.api.annotations | object | `{}` | Rely _either_ on the className or the annotation below but not both! If you want to use the className, set className: "nginx" and replace "nginx" by an Ingress controller name, examples [here](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers). |
|
||||||
|
| ingress.s3.api.enabled | bool | `false` | |
|
||||||
|
| ingress.s3.api.hosts[0] | object | `{"host":"s3.garage.tld","paths":[{"path":"/","pathType":"Prefix"}]}` | garage S3 API endpoint, to be used with awscli for example |
|
||||||
|
| ingress.s3.api.hosts[1] | object | `{"host":"*.s3.garage.tld","paths":[{"path":"/","pathType":"Prefix"}]}` | garage S3 API endpoint, DNS style bucket access |
|
||||||
|
| ingress.s3.api.labels | object | `{}` | |
|
||||||
|
| ingress.s3.api.tls | list | `[]` | |
|
||||||
|
| ingress.s3.web.annotations | object | `{}` | Rely _either_ on the className or the annotation below but not both! If you want to use the className, set className: "nginx" and replace "nginx" by an Ingress controller name, examples [here](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers). |
|
||||||
|
| ingress.s3.web.enabled | bool | `false` | |
|
||||||
|
| ingress.s3.web.hosts[0] | object | `{"host":"*.web.garage.tld","paths":[{"path":"/","pathType":"Prefix"}]}` | wildcard website access with bucket name prefix |
|
||||||
|
| ingress.s3.web.hosts[1] | object | `{"host":"mywebpage.example.com","paths":[{"path":"/","pathType":"Prefix"}]}` | specific bucket access with FQDN bucket |
|
||||||
|
| ingress.s3.web.labels | object | `{}` | |
|
||||||
|
| ingress.s3.web.tls | list | `[]` | |
|
||||||
|
| initImage.pullPolicy | string | `"IfNotPresent"` | |
|
||||||
|
| initImage.repository | string | `"busybox"` | |
|
||||||
|
| initImage.tag | string | `"stable"` | |
|
||||||
|
| 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"` | |
|
||||||
|
| monitoring.metrics.serviceMonitor.labels | object | `{}` | |
|
||||||
|
| monitoring.metrics.serviceMonitor.path | string | `"/metrics"` | |
|
||||||
|
| monitoring.metrics.serviceMonitor.relabelings | list | `[]` | |
|
||||||
|
| monitoring.metrics.serviceMonitor.scheme | string | `"http"` | |
|
||||||
|
| monitoring.metrics.serviceMonitor.scrapeTimeout | string | `"10s"` | |
|
||||||
|
| monitoring.metrics.serviceMonitor.tlsConfig | object | `{}` | |
|
||||||
|
| monitoring.tracing.sink | string | `""` | specify a sink endpoint for OpenTelemetry Traces, eg. `http://localhost:4317` |
|
||||||
|
| nameOverride | string | `""` | |
|
||||||
|
| nodeSelector | object | `{}` | |
|
||||||
|
| persistence.data.hostPath | string | `"/var/lib/garage/data"` | |
|
||||||
|
| persistence.data.size | string | `"100Mi"` | |
|
||||||
|
| persistence.enabled | bool | `true` | |
|
||||||
|
| persistence.meta.hostPath | string | `"/var/lib/garage/meta"` | |
|
||||||
|
| persistence.meta.size | string | `"100Mi"` | |
|
||||||
|
| podAnnotations | object | `{}` | additonal pod annotations |
|
||||||
|
| podSecurityContext.fsGroup | int | `1000` | |
|
||||||
|
| podSecurityContext.runAsGroup | int | `1000` | |
|
||||||
|
| podSecurityContext.runAsNonRoot | bool | `true` | |
|
||||||
|
| podSecurityContext.runAsUser | int | `1000` | |
|
||||||
|
| 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` | |
|
||||||
|
| service.s3.api.port | int | `3900` | |
|
||||||
|
| service.s3.web.port | int | `3902` | |
|
||||||
|
| service.type | string | `"ClusterIP"` | You can rely on any service to expose your cluster - ClusterIP (+ Ingress) - NodePort (+ Ingress) - LoadBalancer |
|
||||||
|
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
|
||||||
|
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
|
||||||
|
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
|
||||||
|
| tolerations | list | `[]` | |
|
||||||
|
|
||||||
|
----------------------------------------------
|
||||||
|
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)
|
|
@ -1,7 +1,49 @@
|
||||||
|
{{- if not .Values.garage.existingConfigMap }}
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "garage.fullname" . }}-config
|
name: {{ include "garage.fullname" . }}-config
|
||||||
data:
|
data:
|
||||||
garage.toml: |-
|
garage.toml: |-
|
||||||
{{- tpl (index (index .Values.garage) "garage.toml") $ | nindent 4 }}
|
{{- if .Values.garage.garageTomlString }}
|
||||||
|
{{- tpl (index (index .Values.garage) "garageTomlString") $ | nindent 4 }}
|
||||||
|
{{- else }}
|
||||||
|
metadata_dir = "/mnt/meta"
|
||||||
|
data_dir = "/mnt/data"
|
||||||
|
|
||||||
|
db_engine = "{{ .Values.garage.dbEngine }}"
|
||||||
|
|
||||||
|
block_size = {{ .Values.garage.blockSize }}
|
||||||
|
|
||||||
|
replication_mode = "{{ .Values.garage.replicationMode }}"
|
||||||
|
|
||||||
|
compression_level = {{ .Values.garage.compressionLevel }}
|
||||||
|
|
||||||
|
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__"
|
||||||
|
|
||||||
|
bootstrap_peers = {{ .Values.garage.bootstrapPeers }}
|
||||||
|
|
||||||
|
[kubernetes_discovery]
|
||||||
|
namespace = "{{ .Release.Namespace }}"
|
||||||
|
service_name = "{{ include "garage.fullname" . }}"
|
||||||
|
skip_crd = {{ .Values.garage.kubernetesSkipCrd }}
|
||||||
|
|
||||||
|
[s3_api]
|
||||||
|
s3_region = "{{ .Values.garage.s3.api.region }}"
|
||||||
|
api_bind_addr = "[::]:3900"
|
||||||
|
root_domain = "{{ .Values.garage.s3.api.rootDomain }}"
|
||||||
|
|
||||||
|
[s3_web]
|
||||||
|
bind_addr = "[::]:3902"
|
||||||
|
root_domain = "{{ .Values.garage.s3.web.rootDomain }}"
|
||||||
|
index = "{{ .Values.garage.s3.web.index }}"
|
||||||
|
|
||||||
|
[admin]
|
||||||
|
api_bind_addr = "[::]:3903"
|
||||||
|
{{- if .Values.monitoring.tracing.sink }}
|
||||||
|
trace_sink = "{{ .Values.monitoring.tracing.sink }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
|
@ -4,28 +4,30 @@
|
||||||
|
|
||||||
# Garage configuration. These values go to garage.toml
|
# Garage configuration. These values go to garage.toml
|
||||||
garage:
|
garage:
|
||||||
# Can be changed for better performance on certain systems
|
# -- Can be changed for better performance on certain systems
|
||||||
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#db-engine-since-v0-8-0
|
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#db-engine-since-v0-8-0
|
||||||
dbEngine: "lmdb"
|
dbEngine: "lmdb"
|
||||||
|
|
||||||
# Defaults is 1MB
|
# -- Defaults is 1MB
|
||||||
# An increase can result in better performance in certain scenarios
|
# An increase can result in better performance in certain scenarios
|
||||||
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#block-size
|
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#block-size
|
||||||
blockSize: "1048576"
|
blockSize: "1048576"
|
||||||
|
|
||||||
# Default to 3 replicas, see the replication_mode section at
|
# -- Default to 3 replicas, see the replication_mode section at
|
||||||
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#replication-mode
|
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#replication-mode
|
||||||
replicationMode: "3"
|
replicationMode: "3"
|
||||||
|
|
||||||
# zstd compression level of stored blocks
|
# -- zstd compression level of stored blocks
|
||||||
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#compression-level
|
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#compression-level
|
||||||
compressionLevel: "1"
|
compressionLevel: "1"
|
||||||
|
|
||||||
rpcBindAddr: "[::]:3901"
|
rpcBindAddr: "[::]:3901"
|
||||||
# If not given, a random secret will be generated and stored in a Secret object
|
# -- If not given, a random secret will be generated and stored in a Secret object
|
||||||
rpcSecret: ""
|
rpcSecret: ""
|
||||||
# This is not required if you use the integrated kubernetes discovery
|
# -- This is not required if you use the integrated kubernetes discovery
|
||||||
bootstrapPeers: []
|
bootstrapPeers: []
|
||||||
|
# -- 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
|
||||||
kubernetesSkipCrd: false
|
kubernetesSkipCrd: false
|
||||||
s3:
|
s3:
|
||||||
api:
|
api:
|
||||||
|
@ -34,47 +36,16 @@ garage:
|
||||||
web:
|
web:
|
||||||
rootDomain: ".web.garage.tld"
|
rootDomain: ".web.garage.tld"
|
||||||
index: "index.html"
|
index: "index.html"
|
||||||
# Template for the garage configuration
|
|
||||||
# Values can be templated
|
|
||||||
# ref: https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/
|
|
||||||
garage.toml: |-
|
|
||||||
metadata_dir = "/mnt/meta"
|
|
||||||
data_dir = "/mnt/data"
|
|
||||||
|
|
||||||
db_engine = "{{ .Values.garage.dbEngine }}"
|
# -- if not empty string, allow using an existing ConfigMap for the garage.toml,
|
||||||
|
# if set, ignores garage.toml
|
||||||
|
existingConfigMap: ""
|
||||||
|
|
||||||
block_size = {{ .Values.garage.blockSize }}
|
# -- String Template for the garage configuration
|
||||||
|
# if set, ignores above values.
|
||||||
replication_mode = "{{ .Values.garage.replicationMode }}"
|
# Values can be templated,
|
||||||
|
# see https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/
|
||||||
compression_level = {{ .Values.garage.compressionLevel }}
|
garageTomlString: ""
|
||||||
|
|
||||||
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__"
|
|
||||||
|
|
||||||
bootstrap_peers = {{ .Values.garage.bootstrapPeers }}
|
|
||||||
|
|
||||||
[kubernetes_discovery]
|
|
||||||
namespace = "{{ .Release.Namespace }}"
|
|
||||||
service_name = "{{ include "garage.fullname" . }}"
|
|
||||||
skip_crd = {{ .Values.garage.kubernetesSkipCrd }}
|
|
||||||
|
|
||||||
[s3_api]
|
|
||||||
s3_region = "{{ .Values.garage.s3.api.region }}"
|
|
||||||
api_bind_addr = "[::]:3900"
|
|
||||||
root_domain = "{{ .Values.garage.s3.api.rootDomain }}"
|
|
||||||
|
|
||||||
[s3_web]
|
|
||||||
bind_addr = "[::]:3902"
|
|
||||||
root_domain = "{{ .Values.garage.s3.web.rootDomain }}"
|
|
||||||
index = "{{ .Values.garage.s3.web.index }}"
|
|
||||||
|
|
||||||
[admin]
|
|
||||||
api_bind_addr = "[::]:3903"
|
|
||||||
{{- if .Values.monitoring.tracing.sink }}
|
|
||||||
trace_sink = "{{ .Values.monitoring.tracing.sink }}"
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
# Data persistence
|
# Data persistence
|
||||||
persistence:
|
persistence:
|
||||||
|
@ -92,16 +63,18 @@ persistence:
|
||||||
|
|
||||||
# Deployment configuration
|
# Deployment configuration
|
||||||
deployment:
|
deployment:
|
||||||
# Switchable to DaemonSet
|
# -- Switchable to DaemonSet
|
||||||
kind: StatefulSet
|
kind: StatefulSet
|
||||||
# Number of StatefulSet replicas/garage nodes to start
|
# -- Number of StatefulSet replicas/garage nodes to start
|
||||||
replicaCount: 3
|
replicaCount: 3
|
||||||
# If using statefulset, allow Parallel or OrderedReady (default)
|
# -- If using statefulset, allow Parallel or OrderedReady (default)
|
||||||
podManagementPolicy: OrderedReady
|
podManagementPolicy: OrderedReady
|
||||||
|
|
||||||
image:
|
image:
|
||||||
|
# -- default to amd64 docker image
|
||||||
repository: dxflrs/amd64_garage
|
repository: dxflrs/amd64_garage
|
||||||
# please prefer using the chart version and not this tag
|
# -- set the image tag, please prefer using the chart version and not this
|
||||||
|
# to avoid compatibility issues
|
||||||
tag: ""
|
tag: ""
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
@ -110,19 +83,21 @@ initImage:
|
||||||
tag: stable
|
tag: stable
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
# -- set if you need credentials to pull your custom image
|
||||||
imagePullSecrets: []
|
imagePullSecrets: []
|
||||||
nameOverride: ""
|
nameOverride: ""
|
||||||
fullnameOverride: ""
|
fullnameOverride: ""
|
||||||
|
|
||||||
serviceAccount:
|
serviceAccount:
|
||||||
# Specifies whether a service account should be created
|
# -- Specifies whether a service account should be created
|
||||||
create: true
|
create: true
|
||||||
# Annotations to add to the service account
|
# -- Annotations to add to the service account
|
||||||
annotations: {}
|
annotations: {}
|
||||||
# The name of the service account to use.
|
# -- The name of the service account to use.
|
||||||
# If not set and create is true, a name is generated using the fullname template
|
# If not set and create is true, a name is generated using the fullname template
|
||||||
name: ""
|
name: ""
|
||||||
|
|
||||||
|
# -- additonal pod annotations
|
||||||
podAnnotations: {}
|
podAnnotations: {}
|
||||||
|
|
||||||
podSecurityContext:
|
podSecurityContext:
|
||||||
|
@ -132,7 +107,7 @@ podSecurityContext:
|
||||||
runAsNonRoot: true
|
runAsNonRoot: true
|
||||||
|
|
||||||
securityContext:
|
securityContext:
|
||||||
# The default security context is heavily restricted
|
# -- The default security context is heavily restricted,
|
||||||
# feel free to tune it to your requirements
|
# feel free to tune it to your requirements
|
||||||
capabilities:
|
capabilities:
|
||||||
drop:
|
drop:
|
||||||
|
@ -140,7 +115,7 @@ securityContext:
|
||||||
readOnlyRootFilesystem: true
|
readOnlyRootFilesystem: true
|
||||||
|
|
||||||
service:
|
service:
|
||||||
# You can rely on any service to expose your cluster
|
# -- You can rely on any service to expose your cluster
|
||||||
# - ClusterIP (+ Ingress)
|
# - ClusterIP (+ Ingress)
|
||||||
# - NodePort (+ Ingress)
|
# - NodePort (+ Ingress)
|
||||||
# - LoadBalancer
|
# - LoadBalancer
|
||||||
|
@ -156,20 +131,23 @@ ingress:
|
||||||
s3:
|
s3:
|
||||||
api:
|
api:
|
||||||
enabled: false
|
enabled: false
|
||||||
# Rely either on the className or the annotation below but not both
|
# -- Rely _either_ on the className or the annotation below but not both!
|
||||||
# replace "nginx" by an Ingress controller
|
# If you want to use the className, set
|
||||||
# you can find examples here https://kubernetes.io/docs/concepts/services-networking/ingress-controllers
|
|
||||||
# className: "nginx"
|
# className: "nginx"
|
||||||
|
# and replace "nginx" by an Ingress controller name,
|
||||||
|
# examples [here](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers).
|
||||||
annotations: {}
|
annotations: {}
|
||||||
# kubernetes.io/ingress.class: "nginx"
|
# kubernetes.io/ingress.class: "nginx"
|
||||||
# kubernetes.io/tls-acme: "true"
|
# kubernetes.io/tls-acme: "true"
|
||||||
labels: {}
|
labels: {}
|
||||||
hosts:
|
hosts:
|
||||||
- host: "s3.garage.tld" # garage S3 API endpoint
|
# -- garage S3 API endpoint, to be used with awscli for example
|
||||||
|
- host: "s3.garage.tld"
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
- host: "*.s3.garage.tld" # garage S3 API endpoint, DNS style bucket access
|
# -- garage S3 API endpoint, DNS style bucket access
|
||||||
|
- host: "*.s3.garage.tld"
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
|
@ -179,20 +157,23 @@ ingress:
|
||||||
# - kubernetes.docker.internal
|
# - kubernetes.docker.internal
|
||||||
web:
|
web:
|
||||||
enabled: false
|
enabled: false
|
||||||
# Rely either on the className or the annotation below but not both
|
# -- Rely _either_ on the className or the annotation below but not both!
|
||||||
# replace "nginx" by an Ingress controller
|
# If you want to use the className, set
|
||||||
# you can find examples here https://kubernetes.io/docs/concepts/services-networking/ingress-controllers
|
|
||||||
# className: "nginx"
|
# className: "nginx"
|
||||||
|
# and replace "nginx" by an Ingress controller name,
|
||||||
|
# examples [here](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers).
|
||||||
annotations: {}
|
annotations: {}
|
||||||
# kubernetes.io/ingress.class: nginx
|
# kubernetes.io/ingress.class: nginx
|
||||||
# kubernetes.io/tls-acme: "true"
|
# kubernetes.io/tls-acme: "true"
|
||||||
labels: {}
|
labels: {}
|
||||||
hosts:
|
hosts:
|
||||||
- host: "*.web.garage.tld" # wildcard website access with bucket name prefix
|
# -- wildcard website access with bucket name prefix
|
||||||
|
- host: "*.web.garage.tld"
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
- host: "mywebpage.example.com" # specific bucket access with FQDN bucket
|
# -- specific bucket access with FQDN bucket
|
||||||
|
- host: "mywebpage.example.com"
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
|
@ -224,10 +205,10 @@ extraVolumeMounts: {}
|
||||||
|
|
||||||
monitoring:
|
monitoring:
|
||||||
metrics:
|
metrics:
|
||||||
# If true, a service for monitoring is created with a prometheus.io/scrape annotation
|
# -- If true, a service for monitoring is created with a prometheus.io/scrape annotation
|
||||||
enabled: false
|
enabled: false
|
||||||
serviceMonitor:
|
serviceMonitor:
|
||||||
# If true, a ServiceMonitor CRD is created for a prometheus operator
|
# -- If true, a ServiceMonitor CRD is created for a prometheus operator
|
||||||
# https://github.com/coreos/prometheus-operator
|
# https://github.com/coreos/prometheus-operator
|
||||||
enabled: false
|
enabled: false
|
||||||
path: /metrics
|
path: /metrics
|
||||||
|
@ -239,4 +220,5 @@ monitoring:
|
||||||
scrapeTimeout: 10s
|
scrapeTimeout: 10s
|
||||||
relabelings: []
|
relabelings: []
|
||||||
tracing:
|
tracing:
|
||||||
|
# -- specify a sink endpoint for OpenTelemetry Traces, eg. `http://localhost:4317`
|
||||||
sink: ""
|
sink: ""
|
||||||
|
|
|
@ -115,7 +115,7 @@ in
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
function refresh_cache {
|
function refresh_cache {
|
||||||
pass show deuxfleurs/nix_priv_key > /tmp/nix-signing-key.sec
|
pass show deuxfleurs/nix_priv_key > /tmp/nix-signing-key.sec
|
||||||
for attr in clippy.amd64 test.amd64 pkgs.{amd64,i386,arm,arm64}.release; do
|
for attr in pkgs.amd64.debug test.amd64 pkgs.{amd64,i386,arm,arm64}.release; do
|
||||||
echo "Updating cache for ''${attr}"
|
echo "Updating cache for ''${attr}"
|
||||||
nix copy -j8 \
|
nix copy -j8 \
|
||||||
--to 's3://nix?endpoint=garage.deuxfleurs.fr®ion=garage&secret-key=/tmp/nix-signing-key.sec' \
|
--to 's3://nix?endpoint=garage.deuxfleurs.fr®ion=garage&secret-key=/tmp/nix-signing-key.sec' \
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl ApiHandler for K2VApiServer {
|
||||||
} = endpoint;
|
} = endpoint;
|
||||||
let garage = self.garage.clone();
|
let garage = self.garage.clone();
|
||||||
|
|
||||||
// The OPTIONS method is procesed early, before we even check for an API key
|
// The OPTIONS method is processed early, before we even check for an API key
|
||||||
if let Endpoint::Options = endpoint {
|
if let Endpoint::Options = endpoint {
|
||||||
let options_res = handle_options_api(garage, &req, Some(bucket_name))
|
let options_res = handle_options_api(garage, &req, Some(bucket_name))
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -204,7 +204,7 @@ macro_rules! generateQueryParameters {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an error message in case not all parameters where used when extracting them to
|
/// Get an error message in case not all parameters where used when extracting them to
|
||||||
/// build an Enpoint variant
|
/// build an Endpoint variant
|
||||||
fn nonempty_message(&self) -> Option<&str> {
|
fn nonempty_message(&self) -> Option<&str> {
|
||||||
if self.keyword.is_some() {
|
if self.keyword.is_some() {
|
||||||
Some("Keyword not used")
|
Some("Keyword not used")
|
||||||
|
|
|
@ -340,8 +340,8 @@ pub(crate) fn request_checksum_value(
|
||||||
Ok(ret.pop())
|
Ok(ret.pop())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks for the presense of x-amz-checksum-algorithm
|
/// Checks for the presence of x-amz-checksum-algorithm
|
||||||
/// if so extract the corrseponding x-amz-checksum-* value
|
/// if so extract the corresponding x-amz-checksum-* value
|
||||||
pub(crate) fn request_checksum_algorithm_value(
|
pub(crate) fn request_checksum_algorithm_value(
|
||||||
headers: &HeaderMap<HeaderValue>,
|
headers: &HeaderMap<HeaderValue>,
|
||||||
) -> Result<Option<ChecksumValue>, Error> {
|
) -> Result<Option<ChecksumValue>, Error> {
|
||||||
|
|
|
@ -63,7 +63,7 @@ pub async fn handle_copy(
|
||||||
let source_checksum_algorithm = source_checksum.map(|x| x.algorithm());
|
let source_checksum_algorithm = source_checksum.map(|x| x.algorithm());
|
||||||
|
|
||||||
// If source object has a checksum, the destination object must as well.
|
// If source object has a checksum, the destination object must as well.
|
||||||
// The x-amz-checksum-algorihtm header allows to change that algorithm,
|
// The x-amz-checksum-algorithm header allows to change that algorithm,
|
||||||
// but if it is absent, we must use the same as before
|
// but if it is absent, we must use the same as before
|
||||||
let checksum_algorithm = checksum_algorithm.or(source_checksum_algorithm);
|
let checksum_algorithm = checksum_algorithm.or(source_checksum_algorithm);
|
||||||
|
|
||||||
|
|
|
@ -398,7 +398,7 @@ enum ExtractionResult {
|
||||||
key: String,
|
key: String,
|
||||||
},
|
},
|
||||||
// Fallback key is used for legacy APIs that only support
|
// Fallback key is used for legacy APIs that only support
|
||||||
// exlusive pagination (and not inclusive one).
|
// exclusive pagination (and not inclusive one).
|
||||||
SkipTo {
|
SkipTo {
|
||||||
key: String,
|
key: String,
|
||||||
fallback_key: Option<String>,
|
fallback_key: Option<String>,
|
||||||
|
@ -408,7 +408,7 @@ enum ExtractionResult {
|
||||||
#[derive(PartialEq, Clone, Debug)]
|
#[derive(PartialEq, Clone, Debug)]
|
||||||
enum RangeBegin {
|
enum RangeBegin {
|
||||||
// Fallback key is used for legacy APIs that only support
|
// Fallback key is used for legacy APIs that only support
|
||||||
// exlusive pagination (and not inclusive one).
|
// exclusive pagination (and not inclusive one).
|
||||||
IncludingKey {
|
IncludingKey {
|
||||||
key: String,
|
key: String,
|
||||||
fallback_key: Option<String>,
|
fallback_key: Option<String>,
|
||||||
|
|
|
@ -213,7 +213,7 @@ pub async fn handle_post_object(
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we ever start supporting ACLs, we likely want to map "acl" to x-amz-acl" somewhere
|
// if we ever start supporting ACLs, we likely want to map "acl" to x-amz-acl" somewhere
|
||||||
// arround here to make sure the rest of the machinery takes our acl into account.
|
// around here to make sure the rest of the machinery takes our acl into account.
|
||||||
let headers = get_headers(¶ms)?;
|
let headers = get_headers(¶ms)?;
|
||||||
|
|
||||||
let expected_checksums = ExpectedChecksums {
|
let expected_checksums = ExpectedChecksums {
|
||||||
|
|
|
@ -276,7 +276,7 @@ impl Redirect {
|
||||||
return Err(Error::bad_request("Bad XML: invalid protocol"));
|
return Err(Error::bad_request("Bad XML: invalid protocol"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO there are probably more invalide cases, but which ones?
|
// TODO there are probably more invalid cases, but which ones?
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ pub async fn check_payload_signature(
|
||||||
let query = parse_query_map(request.uri())?;
|
let query = parse_query_map(request.uri())?;
|
||||||
|
|
||||||
if query.contains_key(&X_AMZ_ALGORITHM) {
|
if query.contains_key(&X_AMZ_ALGORITHM) {
|
||||||
// We check for presigned-URL-style authentification first, because
|
// We check for presigned-URL-style authentication first, because
|
||||||
// the browser or someting else could inject an Authorization header
|
// the browser or something else could inject an Authorization header
|
||||||
// that is totally unrelated to AWS signatures.
|
// that is totally unrelated to AWS signatures.
|
||||||
check_presigned_signature(garage, service, request, query).await
|
check_presigned_signature(garage, service, request, query).await
|
||||||
} else if request.headers().contains_key(AUTHORIZATION) {
|
} else if request.headers().contains_key(AUTHORIZATION) {
|
||||||
|
@ -132,7 +132,7 @@ async fn check_presigned_signature(
|
||||||
let authorization = Authorization::parse_presigned(&algorithm.value, &query)?;
|
let authorization = Authorization::parse_presigned(&algorithm.value, &query)?;
|
||||||
|
|
||||||
// Verify that all necessary request headers are included in signed_headers
|
// Verify that all necessary request headers are included in signed_headers
|
||||||
// For AWSv4 pre-signed URLs, the following must be incldued:
|
// For AWSv4 pre-signed URLs, the following must be included:
|
||||||
// - the Host header (mandatory)
|
// - the Host header (mandatory)
|
||||||
// - all x-amz-* headers used in the request
|
// - all x-amz-* headers used in the request
|
||||||
let signed_headers = split_signed_headers(&authorization)?;
|
let signed_headers = split_signed_headers(&authorization)?;
|
||||||
|
@ -306,7 +306,7 @@ pub fn canonical_request(
|
||||||
// Note that there is also the issue of path normalization, which I hope is unrelated to the
|
// Note that there is also the issue of path normalization, which I hope is unrelated to the
|
||||||
// one of URI-encoding. At least in aws-sigv4 both parameters can be set independently,
|
// one of URI-encoding. At least in aws-sigv4 both parameters can be set independently,
|
||||||
// and rusoto_signature does not seem to do any effective path normalization, even though
|
// and rusoto_signature does not seem to do any effective path normalization, even though
|
||||||
// it mentions it in the comments (same link to the souce code as above).
|
// it mentions it in the comments (same link to the source code as above).
|
||||||
// We make the explicit choice of NOT normalizing paths in the K2V API because doing so
|
// We make the explicit choice of NOT normalizing paths in the K2V API because doing so
|
||||||
// would make non-normalized paths invalid K2V partition keys, and we don't want that.
|
// would make non-normalized paths invalid K2V partition keys, and we don't want that.
|
||||||
let canonical_uri: std::borrow::Cow<str> = if service != "s3" {
|
let canonical_uri: std::borrow::Cow<str> = if service != "s3" {
|
||||||
|
|
|
@ -279,7 +279,8 @@ impl DataLayout {
|
||||||
u16::from_be_bytes([
|
u16::from_be_bytes([
|
||||||
hash.as_slice()[HASH_DRIVE_BYTES.0],
|
hash.as_slice()[HASH_DRIVE_BYTES.0],
|
||||||
hash.as_slice()[HASH_DRIVE_BYTES.1],
|
hash.as_slice()[HASH_DRIVE_BYTES.1],
|
||||||
]) as usize % DRIVE_NPART
|
]) as usize
|
||||||
|
% DRIVE_NPART
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_dir_from(&self, hash: &Hash, dir: &PathBuf) -> PathBuf {
|
fn block_dir_from(&self, hash: &Hash, dir: &PathBuf) -> PathBuf {
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl BlockResyncManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get lenght of resync queue
|
/// Get length of resync queue
|
||||||
pub fn queue_len(&self) -> Result<usize, Error> {
|
pub fn queue_len(&self) -> Result<usize, Error> {
|
||||||
Ok(self.queue.len()?)
|
Ok(self.queue.len()?)
|
||||||
}
|
}
|
||||||
|
@ -185,10 +185,10 @@ impl BlockResyncManager {
|
||||||
//
|
//
|
||||||
// - resync.errors: a tree that indicates for each block
|
// - resync.errors: a tree that indicates for each block
|
||||||
// if the last resync resulted in an error, and if so,
|
// if the last resync resulted in an error, and if so,
|
||||||
// the following two informations (see the ErrorCounter struct):
|
// the following two information (see the ErrorCounter struct):
|
||||||
// - how many consecutive resync errors for this block?
|
// - how many consecutive resync errors for this block?
|
||||||
// - when was the last try?
|
// - when was the last try?
|
||||||
// These two informations are used to implement an
|
// These two information are used to implement an
|
||||||
// exponential backoff retry strategy.
|
// exponential backoff retry strategy.
|
||||||
// The key in this tree is the 32-byte hash of the block,
|
// The key in this tree is the 32-byte hash of the block,
|
||||||
// and the value is the encoded ErrorCounter value.
|
// and the value is the encoded ErrorCounter value.
|
||||||
|
|
|
@ -15,14 +15,11 @@ path = "lib.rs"
|
||||||
err-derive.workspace = true
|
err-derive.workspace = true
|
||||||
hexdump.workspace = true
|
hexdump.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
opentelemetry.workspace = true
|
|
||||||
|
|
||||||
heed = { workspace = true, optional = true }
|
heed = { workspace = true, optional = true }
|
||||||
rusqlite = { workspace = true, optional = true, features = ["backup"] }
|
rusqlite = { workspace = true, optional = true, features = ["backup"] }
|
||||||
r2d2 = { workspace = true, optional = true }
|
r2d2 = { workspace = true, optional = true }
|
||||||
r2d2_sqlite = { workspace = true, optional = true }
|
r2d2_sqlite = { workspace = true, optional = true }
|
||||||
rocksdb = { workspace = true, optional = true }
|
|
||||||
num_cpus = { workspace = true, optional = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
mktemp.workspace = true
|
mktemp.workspace = true
|
||||||
|
@ -32,4 +29,3 @@ default = [ "lmdb", "sqlite" ]
|
||||||
bundled-libs = [ "rusqlite?/bundled" ]
|
bundled-libs = [ "rusqlite?/bundled" ]
|
||||||
lmdb = [ "heed" ]
|
lmdb = [ "heed" ]
|
||||||
sqlite = [ "rusqlite", "r2d2", "r2d2_sqlite" ]
|
sqlite = [ "rusqlite", "r2d2", "r2d2_sqlite" ]
|
||||||
rocksdb = [ "dep:rocksdb", "dep:num_cpus" ]
|
|
||||||
|
|
|
@ -5,10 +5,6 @@ extern crate tracing;
|
||||||
pub mod lmdb_adapter;
|
pub mod lmdb_adapter;
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
pub mod sqlite_adapter;
|
pub mod sqlite_adapter;
|
||||||
#[cfg(feature = "rocksdb")]
|
|
||||||
pub mod rocksdb_adapter;
|
|
||||||
#[cfg(feature = "rocksdb")]
|
|
||||||
pub mod metric_proxy;
|
|
||||||
|
|
||||||
pub mod open;
|
pub mod open;
|
||||||
|
|
||||||
|
@ -126,7 +122,7 @@ impl Db {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
},
|
},
|
||||||
Err(TxError::Db(e2)) => match ret {
|
Err(TxError::Db(e2)) => match ret {
|
||||||
// Ok was stored -> the error occured when finalizing
|
// Ok was stored -> the error occurred when finalizing
|
||||||
// transaction
|
// transaction
|
||||||
Ok(_) => Err(TxError::Db(e2)),
|
Ok(_) => Err(TxError::Db(e2)),
|
||||||
// An error was already stored: that's the one we want to
|
// An error was already stored: that's the one we want to
|
||||||
|
|
|
@ -233,7 +233,7 @@ impl<'a> LmdbTx<'a> {
|
||||||
fn get_tree(&self, i: usize) -> TxOpResult<&Database> {
|
fn get_tree(&self, i: usize) -> TxOpResult<&Database> {
|
||||||
self.trees.get(i).ok_or_else(|| {
|
self.trees.get(i).ok_or_else(|| {
|
||||||
TxOpError(Error(
|
TxOpError(Error(
|
||||||
"invalid tree id (it might have been openned after the transaction started)".into(),
|
"invalid tree id (it might have been opened after the transaction started)".into(),
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,217 +0,0 @@
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use std::time::Instant;
|
|
||||||
|
|
||||||
use crate::rocksdb_adapter::RocksDb;
|
|
||||||
use crate::{
|
|
||||||
Bound, Db, IDb, ITx, ITxFn, OnCommit, Result, TxFnResult, TxOpResult, TxResult, TxValueIter,
|
|
||||||
Value, ValueIter,
|
|
||||||
};
|
|
||||||
use opentelemetry::{
|
|
||||||
global,
|
|
||||||
metrics::{Unit, ValueRecorder},
|
|
||||||
KeyValue,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct MetricDbProxy {
|
|
||||||
//@FIXME Replace with a template
|
|
||||||
db: RocksDb,
|
|
||||||
op: ValueRecorder<f64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MetricDbProxy {
|
|
||||||
pub fn init(db: RocksDb) -> Db {
|
|
||||||
let meter = global::meter("garage/db");
|
|
||||||
let s = Self {
|
|
||||||
db,
|
|
||||||
op: meter
|
|
||||||
.f64_value_recorder("db.op")
|
|
||||||
.with_description("Duration and amount of operations on the local metadata engine")
|
|
||||||
.with_unit(Unit::new("ms"))
|
|
||||||
.init(),
|
|
||||||
};
|
|
||||||
Db(Arc::new(s))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn instrument<T>(
|
|
||||||
&self,
|
|
||||||
fx: impl FnOnce() -> T,
|
|
||||||
op: &'static str,
|
|
||||||
cat: &'static str,
|
|
||||||
tx: &'static str,
|
|
||||||
) -> T {
|
|
||||||
let metric_tags = [
|
|
||||||
KeyValue::new("op", op),
|
|
||||||
KeyValue::new("cat", cat),
|
|
||||||
KeyValue::new("tx", tx),
|
|
||||||
];
|
|
||||||
|
|
||||||
let request_start = Instant::now();
|
|
||||||
let res = fx();
|
|
||||||
let delay_nanos = Instant::now()
|
|
||||||
.saturating_duration_since(request_start)
|
|
||||||
.as_nanos();
|
|
||||||
let delay_millis: f64 = delay_nanos as f64 / 1_000_000f64;
|
|
||||||
self.op.record(delay_millis, &metric_tags);
|
|
||||||
|
|
||||||
res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IDb for MetricDbProxy {
|
|
||||||
fn engine(&self) -> String {
|
|
||||||
format!("Metric Proxy on {}", self.db.engine())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn open_tree(&self, name: &str) -> Result<usize> {
|
|
||||||
self.instrument(|| self.db.open_tree(name), "open_tree", "control", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn list_trees(&self) -> Result<Vec<String>> {
|
|
||||||
self.instrument(|| self.db.list_trees(), "list_trees", "control", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn snapshot(&self, to: &PathBuf) -> Result<()> {
|
|
||||||
self.instrument(|| self.db.snapshot(to), "snapshot", "control", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---
|
|
||||||
|
|
||||||
fn get(&self, tree: usize, key: &[u8]) -> Result<Option<Value>> {
|
|
||||||
self.instrument(|| self.db.get(tree, key), "get", "data", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn len(&self, tree: usize) -> Result<usize> {
|
|
||||||
self.instrument(|| self.db.len(tree), "len", "data", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> {
|
|
||||||
self.instrument(|| self.db.insert(tree, key, value), "insert", "data", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn remove(&self, tree: usize, key: &[u8]) -> Result<()> {
|
|
||||||
self.instrument(|| self.db.remove(tree, key), "remove", "data", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn clear(&self, tree: usize) -> Result<()> {
|
|
||||||
self.instrument(|| self.db.clear(tree), "clear", "data", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn iter(&self, tree: usize) -> Result<ValueIter<'_>> {
|
|
||||||
self.instrument(|| self.db.iter(tree), "iter", "data", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn iter_rev(&self, tree: usize) -> Result<ValueIter<'_>> {
|
|
||||||
self.instrument(|| self.db.iter_rev(tree), "iter_rev", "data", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn range<'r>(
|
|
||||||
&self,
|
|
||||||
tree: usize,
|
|
||||||
low: Bound<&'r [u8]>,
|
|
||||||
high: Bound<&'r [u8]>,
|
|
||||||
) -> Result<ValueIter<'_>> {
|
|
||||||
self.instrument(|| self.db.range(tree, low, high), "range", "data", "no")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn range_rev<'r>(
|
|
||||||
&self,
|
|
||||||
tree: usize,
|
|
||||||
low: Bound<&'r [u8]>,
|
|
||||||
high: Bound<&'r [u8]>,
|
|
||||||
) -> Result<ValueIter<'_>> {
|
|
||||||
self.instrument(
|
|
||||||
|| self.db.range_rev(tree, low, high),
|
|
||||||
"range_rev",
|
|
||||||
"data",
|
|
||||||
"no",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----
|
|
||||||
|
|
||||||
fn transaction(&self, f: &dyn ITxFn) -> TxResult<OnCommit, ()> {
|
|
||||||
self.instrument(
|
|
||||||
|| self.db.transaction(&MetricITxFnProxy { f, metrics: self }),
|
|
||||||
"transaction",
|
|
||||||
"control",
|
|
||||||
"yes",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct MetricITxFnProxy<'a> {
|
|
||||||
f: &'a dyn ITxFn,
|
|
||||||
metrics: &'a MetricDbProxy,
|
|
||||||
}
|
|
||||||
impl<'a> ITxFn for MetricITxFnProxy<'a> {
|
|
||||||
fn try_on(&self, tx: &mut dyn ITx) -> TxFnResult {
|
|
||||||
self.f.try_on(&mut MetricTxProxy {
|
|
||||||
tx,
|
|
||||||
metrics: self.metrics,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct MetricTxProxy<'a> {
|
|
||||||
tx: &'a mut dyn ITx,
|
|
||||||
metrics: &'a MetricDbProxy,
|
|
||||||
}
|
|
||||||
impl<'a> ITx for MetricTxProxy<'a> {
|
|
||||||
fn get(&self, tree: usize, key: &[u8]) -> TxOpResult<Option<Value>> {
|
|
||||||
self.metrics
|
|
||||||
.instrument(|| self.tx.get(tree, key), "get", "data", "yes")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn len(&self, tree: usize) -> TxOpResult<usize> {
|
|
||||||
self.metrics
|
|
||||||
.instrument(|| self.tx.len(tree), "len", "data", "yes")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn insert(&mut self, tree: usize, key: &[u8], value: &[u8]) -> TxOpResult<()> {
|
|
||||||
self.metrics
|
|
||||||
.instrument(|| self.tx.insert(tree, key, value), "insert", "data", "yes")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn remove(&mut self, tree: usize, key: &[u8]) -> TxOpResult<()> {
|
|
||||||
self.metrics
|
|
||||||
.instrument(|| self.tx.remove(tree, key), "remove", "data", "yes")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn clear(&mut self, tree: usize) -> TxOpResult<()> {
|
|
||||||
self.metrics
|
|
||||||
.instrument(|| self.tx.clear(tree), "clear", "data", "yes")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn iter(&self, tree: usize) -> TxOpResult<TxValueIter<'_>> {
|
|
||||||
self.metrics
|
|
||||||
.instrument(|| self.tx.iter(tree), "iter", "data", "yes")
|
|
||||||
}
|
|
||||||
fn iter_rev(&self, tree: usize) -> TxOpResult<TxValueIter<'_>> {
|
|
||||||
self.metrics
|
|
||||||
.instrument(|| self.tx.iter_rev(tree), "iter_rev", "data", "yes")
|
|
||||||
}
|
|
||||||
fn range<'r>(
|
|
||||||
&self,
|
|
||||||
tree: usize,
|
|
||||||
low: Bound<&'r [u8]>,
|
|
||||||
high: Bound<&'r [u8]>,
|
|
||||||
) -> TxOpResult<TxValueIter<'_>> {
|
|
||||||
self.metrics
|
|
||||||
.instrument(|| self.tx.range(tree, low, high), "range", "data", "yes")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn range_rev<'r>(
|
|
||||||
&self,
|
|
||||||
tree: usize,
|
|
||||||
low: Bound<&'r [u8]>,
|
|
||||||
high: Bound<&'r [u8]>,
|
|
||||||
) -> TxOpResult<TxValueIter<'_>> {
|
|
||||||
self.metrics.instrument(
|
|
||||||
|| self.tx.range_rev(tree, low, high),
|
|
||||||
"range_rev",
|
|
||||||
"data",
|
|
||||||
"yes",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,8 +11,6 @@ use crate::{Db, Error, Result};
|
||||||
pub enum Engine {
|
pub enum Engine {
|
||||||
Lmdb,
|
Lmdb,
|
||||||
Sqlite,
|
Sqlite,
|
||||||
RocksDb,
|
|
||||||
RocksDbWithMetrics,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Engine {
|
impl Engine {
|
||||||
|
@ -21,8 +19,6 @@ impl Engine {
|
||||||
match self {
|
match self {
|
||||||
Self::Lmdb => "lmdb",
|
Self::Lmdb => "lmdb",
|
||||||
Self::Sqlite => "sqlite",
|
Self::Sqlite => "sqlite",
|
||||||
Self::RocksDb => "rocksdb",
|
|
||||||
Self::RocksDbWithMetrics => "rocksdb-with-metrics",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,8 +36,6 @@ impl std::str::FromStr for Engine {
|
||||||
match text {
|
match text {
|
||||||
"lmdb" | "heed" => Ok(Self::Lmdb),
|
"lmdb" | "heed" => Ok(Self::Lmdb),
|
||||||
"sqlite" | "sqlite3" | "rusqlite" => Ok(Self::Sqlite),
|
"sqlite" | "sqlite3" | "rusqlite" => Ok(Self::Sqlite),
|
||||||
"rocksdb" => Ok(Self::RocksDb),
|
|
||||||
"rocksdb-with-metrics" => Ok(Self::RocksDbWithMetrics),
|
|
||||||
"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())),
|
"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(
|
kind => Err(Error(
|
||||||
format!(
|
format!(
|
||||||
|
@ -120,31 +114,6 @@ pub fn open_db(path: &PathBuf, engine: Engine, opt: &OpenOpt) -> Result<Db> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- RocksDB ----
|
|
||||||
#[cfg(feature = "rocksdb")]
|
|
||||||
Engine::RocksDb => {
|
|
||||||
info!("Opening RocksDb database at: {}", path.display());
|
|
||||||
let mut options = rocksdb::Options::default();
|
|
||||||
options.increase_parallelism(num_cpus::get() as i32);
|
|
||||||
options.create_if_missing(true);
|
|
||||||
options.set_compression_type(rocksdb::DBCompressionType::Zstd);
|
|
||||||
let txn_options = rocksdb::TransactionDBOptions::default();
|
|
||||||
Ok(crate::rocksdb_adapter::RocksDb::init(options, txn_options, path))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- RocksDB ----
|
|
||||||
#[cfg(feature = "rocksdb")]
|
|
||||||
Engine::RocksDbWithMetrics => {
|
|
||||||
info!("Opening RocksDb database at: {}", path.display());
|
|
||||||
let mut options = rocksdb::Options::default();
|
|
||||||
options.increase_parallelism(num_cpus::get() as i32);
|
|
||||||
options.create_if_missing(true);
|
|
||||||
options.set_compression_type(rocksdb::DBCompressionType::Zstd);
|
|
||||||
let txn_options = rocksdb::TransactionDBOptions::default();
|
|
||||||
let db = crate::rocksdb_adapter::RocksDb::new(options, txn_options, path);
|
|
||||||
Ok(crate::metric_proxy::MetricDbProxy::init(db))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pattern is unreachable when all supported DB engines are compiled into binary. The allow
|
// 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
|
// 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.
|
// support for one or more engines by default.
|
||||||
|
|
|
@ -1,322 +0,0 @@
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::sync::{Arc, RwLock};
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use core::ops::Bound;
|
|
||||||
|
|
||||||
use rocksdb::{self as rks, BoundColumnFamily, Direction, IteratorMode, MultiThreaded, Options, Transaction, TransactionDB, TransactionDBOptions};
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
Db, Error, IDb, ITx, ITxFn, OnCommit, Result, TxError, TxFnResult, TxOpError, TxOpResult,
|
|
||||||
TxResult, TxValueIter, Value, ValueIter,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct RocksDb {
|
|
||||||
db: TransactionDB<MultiThreaded>,
|
|
||||||
column_families: RwLock<(Vec<String>, HashMap<String, usize>)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RocksDb {
|
|
||||||
pub fn init(options: Options, txn_options: TransactionDBOptions, path: &PathBuf) -> Db {
|
|
||||||
Db(Arc::new(Self::new(options, txn_options, path)))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(options: Options, txn_options: TransactionDBOptions, path: &PathBuf) -> RocksDb {
|
|
||||||
let db = TransactionDB::open(&options, &txn_options, path).unwrap();
|
|
||||||
let existing_cf = TransactionDB::<MultiThreaded>::list_cf(&Options::default(), path).unwrap();
|
|
||||||
let existing_cf_map = existing_cf.iter().enumerate().map(|(i, n)| (n.clone(), i)).collect();
|
|
||||||
|
|
||||||
Self {
|
|
||||||
db,
|
|
||||||
column_families: RwLock::new((existing_cf, existing_cf_map)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_cf_handle(&self, tree: usize) -> Result<Arc<BoundColumnFamily>> {
|
|
||||||
let column_families = self.column_families.read().unwrap();
|
|
||||||
let name = column_families.0.get(tree);
|
|
||||||
name.map(|n| self.db.cf_handle(n)).flatten().ok_or(
|
|
||||||
Error("trying to acquire a handle on a non-existing column family".into())
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IDb for RocksDb {
|
|
||||||
fn engine(&self) -> String {
|
|
||||||
"rocksdb".into()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn open_tree(&self, name: &str) -> Result<usize> {
|
|
||||||
let mut column_families = self.column_families.write().unwrap();
|
|
||||||
let open_tree = column_families.1.get(name);
|
|
||||||
|
|
||||||
if let Some(i) = open_tree {
|
|
||||||
Ok(*i)
|
|
||||||
} else {
|
|
||||||
self.db.create_cf(name, &Options::default())?;
|
|
||||||
column_families.0.push(name.to_string());
|
|
||||||
let i = column_families.0.len() - 1;
|
|
||||||
column_families.1.insert(name.to_string(), i);
|
|
||||||
Ok(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn list_trees(&self) -> Result<Vec<String>> {
|
|
||||||
Ok(self.column_families.read().unwrap().0.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn snapshot(&self, path: &PathBuf) -> Result<()> {
|
|
||||||
todo!("snapshots for RocksDB");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get(&self, tree: usize, key: &[u8]) -> Result<Option<Value>> {
|
|
||||||
let cf_handle = self.get_cf_handle(tree)?;
|
|
||||||
Ok(self.db.get_cf(&cf_handle, key)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn len(&self, tree: usize) -> Result<usize> {
|
|
||||||
let cf_handle = self.get_cf_handle(tree)?;
|
|
||||||
Ok(self.db.iterator_cf(&cf_handle, IteratorMode::Start).count())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn insert(&self, tree: usize, key: &[u8], value: &[u8]) -> Result<()> {
|
|
||||||
let cf_handle = self.get_cf_handle(tree)?;
|
|
||||||
Ok(self.db.put_cf(&cf_handle, key, value)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn remove(&self, tree: usize, key: &[u8]) -> Result<()> {
|
|
||||||
let cf_handle = self.get_cf_handle(tree)?;
|
|
||||||
Ok(self.db.delete_cf(&cf_handle, key)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn clear(&self, tree: usize) -> Result<()> {
|
|
||||||
let column_families = self.column_families.write().unwrap(); // locking against open_tree
|
|
||||||
let tree_name = column_families.0.get(tree).ok_or(
|
|
||||||
Error("trying to clear a non-existing column family".into())
|
|
||||||
)?;
|
|
||||||
self.db.drop_cf(tree_name)?;
|
|
||||||
self.db.create_cf(tree_name, &Options::default())?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn iter(&self, tree: usize) -> Result<ValueIter<'_>> {
|
|
||||||
let cf_handle = self.get_cf_handle(tree)?;
|
|
||||||
Ok(Box::new(
|
|
||||||
self.db.iterator_cf(&cf_handle, IteratorMode::Start)
|
|
||||||
.map(|r| r
|
|
||||||
.map(|(k, v)| (k.into_vec(), v.into_vec()))
|
|
||||||
.map_err(|e| e.into()))
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn iter_rev(&self, tree: usize) -> Result<ValueIter<'_>> {
|
|
||||||
let cf_handle = self.get_cf_handle(tree)?;
|
|
||||||
Ok(Box::new(
|
|
||||||
self.db.iterator_cf(&cf_handle, IteratorMode::End)
|
|
||||||
.map(|r| r
|
|
||||||
.map(|(k, v)| (k.into_vec(), v.into_vec()))
|
|
||||||
.map_err(|e| e.into()))
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn range<'r>(
|
|
||||||
&self,
|
|
||||||
tree: usize,
|
|
||||||
low: Bound<&'r [u8]>,
|
|
||||||
high: Bound<&'r [u8]>,
|
|
||||||
) -> Result<ValueIter<'_>> {
|
|
||||||
let cf_handle = self.get_cf_handle(tree)?;
|
|
||||||
let start_mode = match low {
|
|
||||||
Bound::Included(i) | Bound::Excluded(i) => IteratorMode::From(i, Direction::Forward),
|
|
||||||
Bound::Unbounded => IteratorMode::Start,
|
|
||||||
};
|
|
||||||
let base_iterator = self.db.iterator_cf(&cf_handle, start_mode)
|
|
||||||
.map(|r| r
|
|
||||||
.map(|(k, v)| (k.into_vec(), v.into_vec()))
|
|
||||||
.map_err(|e| e.into()));
|
|
||||||
|
|
||||||
let stop_value = match high {
|
|
||||||
Bound::Included(i) | Bound::Excluded(i) => i.to_vec(),
|
|
||||||
Bound::Unbounded => return Ok(Box::new(base_iterator)),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Box::new(
|
|
||||||
base_iterator
|
|
||||||
.take_while(move |r| r.as_ref().map(|(k, _v)| *k < stop_value).unwrap_or(false))
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn range_rev<'r>(
|
|
||||||
&self,
|
|
||||||
tree: usize,
|
|
||||||
low: Bound<&'r [u8]>,
|
|
||||||
high: Bound<&'r [u8]>,
|
|
||||||
) -> Result<ValueIter<'_>> {
|
|
||||||
let cf_handle = self.get_cf_handle(tree)?;
|
|
||||||
let start_mode = match high {
|
|
||||||
Bound::Included(i) | Bound::Excluded(i) => IteratorMode::From(i, Direction::Reverse),
|
|
||||||
Bound::Unbounded => IteratorMode::End,
|
|
||||||
};
|
|
||||||
let base_iterator = self.db.iterator_cf(&cf_handle, start_mode)
|
|
||||||
.map(|r| r
|
|
||||||
.map(|(k, v)| (k.into_vec(), v.into_vec()))
|
|
||||||
.map_err(|e| e.into()));
|
|
||||||
|
|
||||||
let stop_value = match low {
|
|
||||||
Bound::Included(i) | Bound::Excluded(i) => i.to_vec(),
|
|
||||||
Bound::Unbounded => return Ok(Box::new(base_iterator)),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Box::new(
|
|
||||||
base_iterator
|
|
||||||
.take_while(move |r| r.as_ref().map(|(k, _v)| *k >= stop_value).unwrap_or(false))
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn transaction(&self, f: &dyn ITxFn) -> TxResult<OnCommit, ()> {
|
|
||||||
let txn = self.db.transaction();
|
|
||||||
let mut tx = RocksTx {
|
|
||||||
db: &self,
|
|
||||||
txn,
|
|
||||||
};
|
|
||||||
|
|
||||||
match f.try_on(&mut tx) {
|
|
||||||
TxFnResult::Ok(on_commit) => {
|
|
||||||
tx.txn.commit().map_err(Error::from).map_err(TxError::Db)?;
|
|
||||||
Ok(on_commit)
|
|
||||||
}
|
|
||||||
TxFnResult::Abort => {
|
|
||||||
tx.txn.rollback().map_err(Error::from).map_err(TxError::Db)?;
|
|
||||||
Err(TxError::Abort(()))
|
|
||||||
}
|
|
||||||
TxFnResult::DbErr => {
|
|
||||||
tx.txn.rollback().map_err(Error::from).map_err(TxError::Db)?;
|
|
||||||
Err(TxError::Db(Error(
|
|
||||||
"(this message will be discarded)".into(),
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct RocksTx<'a> {
|
|
||||||
db: &'a RocksDb,
|
|
||||||
txn: Transaction<'a, TransactionDB<MultiThreaded>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> ITx for RocksTx<'a> {
|
|
||||||
fn get(&self, tree: usize, key: &[u8]) -> TxOpResult<Option<Value>> {
|
|
||||||
let cf_handle = self.db.get_cf_handle(tree)?;
|
|
||||||
Ok(self.txn.get_cf(&cf_handle, key)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn len(&self, tree: usize) -> TxOpResult<usize> {
|
|
||||||
let cf_handle = self.db.get_cf_handle(tree)?;
|
|
||||||
Ok(self.txn.iterator_cf(&cf_handle, IteratorMode::Start).count())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn insert(&mut self, tree: usize, key: &[u8], value: &[u8]) -> TxOpResult<()> {
|
|
||||||
let cf_handle = self.db.get_cf_handle(tree)?;
|
|
||||||
Ok(self.txn.put_cf(&cf_handle, key, value)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn remove(&mut self, tree: usize, key: &[u8]) -> TxOpResult<()> {
|
|
||||||
let cf_handle = self.db.get_cf_handle(tree)?;
|
|
||||||
Ok(self.txn.delete_cf(&cf_handle, key)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn clear(&mut self, _tree: usize) -> TxOpResult<()> {
|
|
||||||
unimplemented!("transactional column family clear not supported in RocksDB")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn iter(&self, tree: usize) -> TxOpResult<TxValueIter<'_>> {
|
|
||||||
let cf_handle = self.db.get_cf_handle(tree)?;
|
|
||||||
Ok(Box::new(
|
|
||||||
self.txn.iterator_cf(&cf_handle, IteratorMode::Start)
|
|
||||||
.map(|r| r
|
|
||||||
.map(|(k, v)| (k.into_vec(), v.into_vec()))
|
|
||||||
.map_err(|e| e.into()))
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn iter_rev(&self, tree: usize) -> TxOpResult<TxValueIter<'_>> {
|
|
||||||
let cf_handle = self.db.get_cf_handle(tree)?;
|
|
||||||
Ok(Box::new(
|
|
||||||
self.txn.iterator_cf(&cf_handle, IteratorMode::End)
|
|
||||||
.map(|r| r
|
|
||||||
.map(|(k, v)| (k.into_vec(), v.into_vec()))
|
|
||||||
.map_err(|e| e.into()))
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn range<'r>(
|
|
||||||
&self,
|
|
||||||
tree: usize,
|
|
||||||
low: Bound<&'r [u8]>,
|
|
||||||
high: Bound<&'r [u8]>,
|
|
||||||
) -> TxOpResult<TxValueIter<'_>> {
|
|
||||||
let cf_handle = self.db.get_cf_handle(tree)?;
|
|
||||||
let start_mode = match low {
|
|
||||||
Bound::Included(i) | Bound::Excluded(i) => IteratorMode::From(i, Direction::Forward),
|
|
||||||
Bound::Unbounded => IteratorMode::Start,
|
|
||||||
};
|
|
||||||
let base_iterator = self.txn.iterator_cf(&cf_handle, start_mode)
|
|
||||||
.map(|r| r
|
|
||||||
.map(|(k, v)| (k.into_vec(), v.into_vec()))
|
|
||||||
.map_err(|e| e.into()));
|
|
||||||
|
|
||||||
let stop_value = match high {
|
|
||||||
Bound::Included(i) | Bound::Excluded(i) => i.to_vec(),
|
|
||||||
Bound::Unbounded => return Ok(Box::new(base_iterator)),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Box::new(
|
|
||||||
base_iterator
|
|
||||||
.take_while(move |r| r.as_ref().map(|(k, _v)| *k < stop_value).unwrap_or(false))
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn range_rev<'r>(
|
|
||||||
&self,
|
|
||||||
tree: usize,
|
|
||||||
low: Bound<&'r [u8]>,
|
|
||||||
high: Bound<&'r [u8]>,
|
|
||||||
) -> TxOpResult<TxValueIter<'_>> {
|
|
||||||
let cf_handle = self.db.get_cf_handle(tree)?;
|
|
||||||
let start_mode = match high {
|
|
||||||
Bound::Included(i) | Bound::Excluded(i) => IteratorMode::From(i, Direction::Reverse),
|
|
||||||
Bound::Unbounded => IteratorMode::End,
|
|
||||||
};
|
|
||||||
let base_iterator = self.txn.iterator_cf(&cf_handle, start_mode)
|
|
||||||
.map(|r| r
|
|
||||||
.map(|(k, v)| (k.into_vec(), v.into_vec()))
|
|
||||||
.map_err(|e| e.into()));
|
|
||||||
|
|
||||||
let stop_value = match low {
|
|
||||||
Bound::Included(i) | Bound::Excluded(i) => i.to_vec(),
|
|
||||||
Bound::Unbounded => return Ok(Box::new(base_iterator)),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Box::new(
|
|
||||||
base_iterator
|
|
||||||
.take_while(move |r| r.as_ref().map(|(k, _v)| *k >= stop_value).unwrap_or(false))
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<rks::Error> for Error {
|
|
||||||
fn from(e: rks::Error) -> Error {
|
|
||||||
Error(format!("RocksDB: {}", e).into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<rks::Error> for TxOpError {
|
|
||||||
fn from(e: rks::Error) -> TxOpError {
|
|
||||||
TxOpError(e.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Error> for TxOpError {
|
|
||||||
fn from(e: Error) -> TxOpError {
|
|
||||||
TxOpError(e.into())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -142,7 +142,7 @@ impl IDb for SqliteDb {
|
||||||
fn snapshot(&self, to: &PathBuf) -> Result<()> {
|
fn snapshot(&self, to: &PathBuf) -> Result<()> {
|
||||||
fn progress(p: rusqlite::backup::Progress) {
|
fn progress(p: rusqlite::backup::Progress) {
|
||||||
let percent = (p.pagecount - p.remaining) * 100 / p.pagecount;
|
let percent = (p.pagecount - p.remaining) * 100 / p.pagecount;
|
||||||
info!("Sqlite snapshot progres: {}%", percent);
|
info!("Sqlite snapshot progress: {}%", percent);
|
||||||
}
|
}
|
||||||
self.db
|
self.db
|
||||||
.get()?
|
.get()?
|
||||||
|
@ -304,7 +304,7 @@ impl<'a> SqliteTx<'a> {
|
||||||
fn get_tree(&self, i: usize) -> TxOpResult<&'_ str> {
|
fn get_tree(&self, i: usize) -> TxOpResult<&'_ str> {
|
||||||
self.trees.get(i).map(Arc::as_ref).ok_or_else(|| {
|
self.trees.get(i).map(Arc::as_ref).ok_or_else(|| {
|
||||||
TxOpError(Error(
|
TxOpError(Error(
|
||||||
"invalid tree id (it might have been openned after the transaction started)".into(),
|
"invalid tree id (it might have been opened after the transaction started)".into(),
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,6 @@ k2v = [ "garage_util/k2v", "garage_api/k2v" ]
|
||||||
# Database engines
|
# Database engines
|
||||||
lmdb = [ "garage_model/lmdb" ]
|
lmdb = [ "garage_model/lmdb" ]
|
||||||
sqlite = [ "garage_model/sqlite" ]
|
sqlite = [ "garage_model/sqlite" ]
|
||||||
rocksdb = [ "garage_model/rocksdb" ]
|
|
||||||
|
|
||||||
# Automatic registration and discovery via Consul API
|
# Automatic registration and discovery via Consul API
|
||||||
consul-discovery = [ "garage_rpc/consul-discovery" ]
|
consul-discovery = [ "garage_rpc/consul-discovery" ]
|
||||||
|
|
|
@ -129,7 +129,7 @@ pub async fn cmd_assign_role(
|
||||||
zone: args
|
zone: args
|
||||||
.zone
|
.zone
|
||||||
.clone()
|
.clone()
|
||||||
.ok_or("Please specifiy a zone with the -z flag")?,
|
.ok_or("Please specify a zone with the -z flag")?,
|
||||||
capacity,
|
capacity,
|
||||||
tags: args.tags.clone(),
|
tags: args.tags.clone(),
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ pub async fn cmd_assign_role(
|
||||||
|
|
||||||
send_layout(rpc_cli, rpc_host, layout).await?;
|
send_layout(rpc_cli, rpc_host, layout).await?;
|
||||||
|
|
||||||
println!("Role changes are staged but not yet commited.");
|
println!("Role changes are staged but not yet committed.");
|
||||||
println!("Use `garage layout show` to view staged role changes,");
|
println!("Use `garage layout show` to view staged role changes,");
|
||||||
println!("and `garage layout apply` to enact staged changes.");
|
println!("and `garage layout apply` to enact staged changes.");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -172,7 +172,7 @@ pub async fn cmd_remove_role(
|
||||||
|
|
||||||
send_layout(rpc_cli, rpc_host, layout).await?;
|
send_layout(rpc_cli, rpc_host, layout).await?;
|
||||||
|
|
||||||
println!("Role removal is staged but not yet commited.");
|
println!("Role removal is staged but not yet committed.");
|
||||||
println!("Use `garage layout show` to view staged role changes,");
|
println!("Use `garage layout show` to view staged role changes,");
|
||||||
println!("and `garage layout apply` to enact staged changes.");
|
println!("and `garage layout apply` to enact staged changes.");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -184,7 +184,7 @@ pub struct SkipDeadNodesOpt {
|
||||||
/// This will generally be the current layout version.
|
/// This will generally be the current layout version.
|
||||||
#[structopt(long = "version")]
|
#[structopt(long = "version")]
|
||||||
pub(crate) version: u64,
|
pub(crate) version: u64,
|
||||||
/// Allow the skip even if a quorum of ndoes could not be found for
|
/// Allow the skip even if a quorum of nodes could not be found for
|
||||||
/// the data among the remaining nodes
|
/// the data among the remaining nodes
|
||||||
#[structopt(long = "allow-missing-data")]
|
#[structopt(long = "allow-missing-data")]
|
||||||
pub(crate) allow_missing_data: bool,
|
pub(crate) allow_missing_data: bool,
|
||||||
|
|
|
@ -107,7 +107,7 @@ async fn main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Initialize panic handler that aborts on panic and shows a nice message.
|
// Initialize panic handler that aborts on panic and shows a nice message.
|
||||||
// By default, Tokio continues runing normally when a task panics. We want
|
// By default, Tokio continues running normally when a task panics. We want
|
||||||
// to avoid this behavior in Garage as this would risk putting the process in an
|
// to avoid this behavior in Garage as this would risk putting the process in an
|
||||||
// unknown/uncontrollable state. We prefer to exit the process and restart it
|
// unknown/uncontrollable state. We prefer to exit the process and restart it
|
||||||
// from scratch, so that it boots back into a fresh, known state.
|
// from scratch, so that it boots back into a fresh, known state.
|
||||||
|
|
|
@ -104,7 +104,7 @@ pub(crate) fn fill_secret(
|
||||||
|
|
||||||
if let Some(val) = cli_value {
|
if let Some(val) = cli_value {
|
||||||
if config_secret.is_some() || config_secret_file.is_some() {
|
if config_secret.is_some() || config_secret_file.is_some() {
|
||||||
debug!("Overriding secret `{}` using value specified using CLI argument or environnement variable.", name);
|
debug!("Overriding secret `{}` using value specified using CLI argument or environment variable.", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
*config_secret = Some(val);
|
*config_secret = Some(val);
|
||||||
|
|
|
@ -153,7 +153,7 @@ impl<'a> RequestBuilder<'a> {
|
||||||
|
|
||||||
pub async fn send(&mut self) -> Result<Response<Body>, String> {
|
pub async fn send(&mut self) -> Result<Response<Body>, String> {
|
||||||
// TODO this is a bit incorrect in that path and query params should be url-encoded and
|
// TODO this is a bit incorrect in that path and query params should be url-encoded and
|
||||||
// aren't, but this is good enought for now.
|
// aren't, but this is good enough for now.
|
||||||
|
|
||||||
let query = query_param_to_string(&self.query_params);
|
let query = query_param_to_string(&self.query_params);
|
||||||
let (host, path) = if self.vhost_style {
|
let (host, path) = if self.vhost_style {
|
||||||
|
@ -210,9 +210,9 @@ impl<'a> RequestBuilder<'a> {
|
||||||
HeaderName::from_static("x-amz-decoded-content-length"),
|
HeaderName::from_static("x-amz-decoded-content-length"),
|
||||||
HeaderValue::from_str(&self.body.len().to_string()).unwrap(),
|
HeaderValue::from_str(&self.body.len().to_string()).unwrap(),
|
||||||
);
|
);
|
||||||
// Get lenght of body by doing the conversion to a streaming body with an
|
// Get length of body by doing the conversion to a streaming body with an
|
||||||
// invalid signature (we don't know the seed) just to get its length. This
|
// invalid signature (we don't know the seed) just to get its length. This
|
||||||
// is a pretty lazy and inefficient way to do it, but it's enought for test
|
// is a pretty lazy and inefficient way to do it, but it's enough for test
|
||||||
// code.
|
// code.
|
||||||
all_headers.insert(
|
all_headers.insert(
|
||||||
CONTENT_LENGTH,
|
CONTENT_LENGTH,
|
||||||
|
|
|
@ -54,7 +54,7 @@ enum Command {
|
||||||
partition_key: String,
|
partition_key: String,
|
||||||
/// Sort key to read from
|
/// Sort key to read from
|
||||||
sort_key: String,
|
sort_key: String,
|
||||||
/// Output formating
|
/// Output formatting
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
output_kind: ReadOutputKind,
|
output_kind: ReadOutputKind,
|
||||||
},
|
},
|
||||||
|
@ -70,7 +70,7 @@ enum Command {
|
||||||
/// Timeout, in seconds
|
/// Timeout, in seconds
|
||||||
#[clap(short = 'T', long)]
|
#[clap(short = 'T', long)]
|
||||||
timeout: Option<u64>,
|
timeout: Option<u64>,
|
||||||
/// Output formating
|
/// Output formatting
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
output_kind: ReadOutputKind,
|
output_kind: ReadOutputKind,
|
||||||
},
|
},
|
||||||
|
@ -87,7 +87,7 @@ enum Command {
|
||||||
/// Timeout, in seconds
|
/// Timeout, in seconds
|
||||||
#[clap(short = 'T', long)]
|
#[clap(short = 'T', long)]
|
||||||
timeout: Option<u64>,
|
timeout: Option<u64>,
|
||||||
/// Output formating
|
/// Output formatting
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
output_kind: BatchOutputKind,
|
output_kind: BatchOutputKind,
|
||||||
},
|
},
|
||||||
|
@ -103,7 +103,7 @@ enum Command {
|
||||||
},
|
},
|
||||||
/// List partition keys
|
/// List partition keys
|
||||||
ReadIndex {
|
ReadIndex {
|
||||||
/// Output formating
|
/// Output formatting
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
output_kind: BatchOutputKind,
|
output_kind: BatchOutputKind,
|
||||||
/// Output only partition keys matching this filter
|
/// Output only partition keys matching this filter
|
||||||
|
@ -114,7 +114,7 @@ enum Command {
|
||||||
ReadRange {
|
ReadRange {
|
||||||
/// Partition key to read from
|
/// Partition key to read from
|
||||||
partition_key: String,
|
partition_key: String,
|
||||||
/// Output formating
|
/// Output formatting
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
output_kind: BatchOutputKind,
|
output_kind: BatchOutputKind,
|
||||||
/// Output only sort keys matching this filter
|
/// Output only sort keys matching this filter
|
||||||
|
@ -125,7 +125,7 @@ enum Command {
|
||||||
DeleteRange {
|
DeleteRange {
|
||||||
/// Partition key to delete from
|
/// Partition key to delete from
|
||||||
partition_key: String,
|
partition_key: String,
|
||||||
/// Output formating
|
/// Output formatting
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
output_kind: BatchOutputKind,
|
output_kind: BatchOutputKind,
|
||||||
/// Delete only sort keys matching this filter
|
/// Delete only sort keys matching this filter
|
||||||
|
@ -185,10 +185,10 @@ struct ReadOutputKind {
|
||||||
/// Raw output. Conflicts generate error, causality token is not returned
|
/// Raw output. Conflicts generate error, causality token is not returned
|
||||||
#[clap(short, long, group = "output-kind")]
|
#[clap(short, long, group = "output-kind")]
|
||||||
raw: bool,
|
raw: bool,
|
||||||
/// Human formated output
|
/// Human formatted output
|
||||||
#[clap(short = 'H', long, group = "output-kind")]
|
#[clap(short = 'H', long, group = "output-kind")]
|
||||||
human: bool,
|
human: bool,
|
||||||
/// JSON formated output
|
/// JSON formatted output
|
||||||
#[clap(short, long, group = "output-kind")]
|
#[clap(short, long, group = "output-kind")]
|
||||||
json: bool,
|
json: bool,
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ impl ReadOutputKind {
|
||||||
let mut val = val.value;
|
let mut val = val.value;
|
||||||
if val.len() != 1 {
|
if val.len() != 1 {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Raw mode can only read non-concurent values, found {} values, expected 1",
|
"Raw mode can only read non-concurrent values, found {} values, expected 1",
|
||||||
val.len()
|
val.len()
|
||||||
);
|
);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -265,10 +265,10 @@ impl ReadOutputKind {
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[clap(group = clap::ArgGroup::new("output-kind").multiple(false).required(false))]
|
#[clap(group = clap::ArgGroup::new("output-kind").multiple(false).required(false))]
|
||||||
struct BatchOutputKind {
|
struct BatchOutputKind {
|
||||||
/// Human formated output
|
/// Human formatted output
|
||||||
#[clap(short = 'H', long, group = "output-kind")]
|
#[clap(short = 'H', long, group = "output-kind")]
|
||||||
human: bool,
|
human: bool,
|
||||||
/// JSON formated output
|
/// JSON formatted output
|
||||||
#[clap(short, long, group = "output-kind")]
|
#[clap(short, long, group = "output-kind")]
|
||||||
json: bool,
|
json: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,7 +336,7 @@ impl K2vClient {
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform a DeleteBatch request, deleting mutiple values or range of values at once, without
|
/// Perform a DeleteBatch request, deleting multiple values or range of values at once, without
|
||||||
/// providing causality information.
|
/// providing causality information.
|
||||||
pub async fn delete_batch(&self, operations: &[BatchDeleteOp<'_>]) -> Result<Vec<u64>, Error> {
|
pub async fn delete_batch(&self, operations: &[BatchDeleteOp<'_>]) -> Result<Vec<u64>, Error> {
|
||||||
let url = self.build_url(None, &[("delete", "")]);
|
let url = self.build_url(None, &[("delete", "")]);
|
||||||
|
|
|
@ -47,4 +47,3 @@ default = [ "lmdb", "sqlite" ]
|
||||||
k2v = [ "garage_util/k2v" ]
|
k2v = [ "garage_util/k2v" ]
|
||||||
lmdb = [ "garage_db/lmdb" ]
|
lmdb = [ "garage_db/lmdb" ]
|
||||||
sqlite = [ "garage_db/sqlite" ]
|
sqlite = [ "garage_db/sqlite" ]
|
||||||
rocksdb = [ "garage_db/rocksdb" ]
|
|
||||||
|
|
|
@ -89,9 +89,9 @@ pub fn is_valid_bucket_name(n: &str) -> bool {
|
||||||
// Bucket names must start and end with a letter or a number
|
// Bucket names must start and end with a letter or a number
|
||||||
&& !n.starts_with(&['-', '.'][..])
|
&& !n.starts_with(&['-', '.'][..])
|
||||||
&& !n.ends_with(&['-', '.'][..])
|
&& !n.ends_with(&['-', '.'][..])
|
||||||
// Bucket names must not be formated as an IP address
|
// Bucket names must not be formatted as an IP address
|
||||||
&& n.parse::<std::net::IpAddr>().is_err()
|
&& n.parse::<std::net::IpAddr>().is_err()
|
||||||
// Bucket names must not start wih "xn--"
|
// Bucket names must not start with "xn--"
|
||||||
&& !n.starts_with("xn--")
|
&& !n.starts_with("xn--")
|
||||||
// Bucket names must not end with "-s3alias"
|
// Bucket names must not end with "-s3alias"
|
||||||
&& !n.ends_with("-s3alias")
|
&& !n.ends_with("-s3alias")
|
||||||
|
|
|
@ -14,7 +14,7 @@ mod v08 {
|
||||||
/// A bucket is a collection of objects
|
/// A bucket is a collection of objects
|
||||||
///
|
///
|
||||||
/// Its parameters are not directly accessible as:
|
/// Its parameters are not directly accessible as:
|
||||||
/// - It must be possible to merge paramaters, hence the use of a LWW CRDT.
|
/// - It must be possible to merge parameters, hence the use of a LWW CRDT.
|
||||||
/// - A bucket has 2 states, Present or Deleted and parameters make sense only if present.
|
/// - A bucket has 2 states, Present or Deleted and parameters make sense only if present.
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct Bucket {
|
pub struct Bucket {
|
||||||
|
@ -126,7 +126,7 @@ impl AutoCrdt for BucketQuotas {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BucketParams {
|
impl BucketParams {
|
||||||
/// Create an empty BucketParams with no authorized keys and no website accesss
|
/// Create an empty BucketParams with no authorized keys and no website access
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
BucketParams {
|
BucketParams {
|
||||||
creation_date: now_msec(),
|
creation_date: now_msec(),
|
||||||
|
|
|
@ -124,9 +124,6 @@ impl Garage {
|
||||||
db::Engine::Lmdb => {
|
db::Engine::Lmdb => {
|
||||||
db_path.push("db.lmdb");
|
db_path.push("db.lmdb");
|
||||||
}
|
}
|
||||||
db::Engine::RocksDb | db::Engine::RocksDbWithMetrics => {
|
|
||||||
db_path.push("db.rocksdb");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let db_opt = db::OpenOpt {
|
let db_opt = db::OpenOpt {
|
||||||
fsync: config.metadata_fsync,
|
fsync: config.metadata_fsync,
|
||||||
|
|
|
@ -231,7 +231,7 @@ impl<'a> LockedHelper<'a> {
|
||||||
let bucket_p_local_alias_key = (key.key_id.clone(), alias_name.clone());
|
let bucket_p_local_alias_key = (key.key_id.clone(), alias_name.clone());
|
||||||
|
|
||||||
// Calculate the timestamp to assign to this aliasing in the two local_aliases maps
|
// Calculate the timestamp to assign to this aliasing in the two local_aliases maps
|
||||||
// (the one from key to bucket, and the reverse one stored in the bucket iself)
|
// (the one from key to bucket, and the reverse one stored in the bucket itself)
|
||||||
// so that merges on both maps in case of a concurrent operation resolve
|
// so that merges on both maps in case of a concurrent operation resolve
|
||||||
// to the same alias being set
|
// to the same alias being set
|
||||||
let alias_ts = increment_logical_clock_2(
|
let alias_ts = increment_logical_clock_2(
|
||||||
|
@ -279,7 +279,8 @@ impl<'a> LockedHelper<'a> {
|
||||||
.local_aliases
|
.local_aliases
|
||||||
.get(alias_name)
|
.get(alias_name)
|
||||||
.cloned()
|
.cloned()
|
||||||
.flatten() != Some(bucket_id)
|
.flatten()
|
||||||
|
!= Some(bucket_id)
|
||||||
{
|
{
|
||||||
return Err(GarageError::Message(format!(
|
return Err(GarageError::Message(format!(
|
||||||
"Bucket {:?} does not have alias {} in namespace of key {}",
|
"Bucket {:?} does not have alias {} in namespace of key {}",
|
||||||
|
|
|
@ -310,7 +310,7 @@ impl K2VRpcHandler {
|
||||||
// - we have a response to a read quorum of requests (e.g. 2/3), and an extra delay
|
// - we have a response to a read quorum of requests (e.g. 2/3), and an extra delay
|
||||||
// has passed since the quorum was achieved
|
// has passed since the quorum was achieved
|
||||||
// - a global RPC timeout expired
|
// - a global RPC timeout expired
|
||||||
// The extra delay after a quorum was received is usefull if the third response was to
|
// The extra delay after a quorum was received is useful if the third response was to
|
||||||
// arrive during this short interval: this would allow us to consider all the data seen
|
// arrive during this short interval: this would allow us to consider all the data seen
|
||||||
// by that last node in the response we produce, and would likely help reduce the
|
// by that last node in the response we produce, and would likely help reduce the
|
||||||
// size of the seen marker that we will return (because we would have an info of the
|
// size of the seen marker that we will return (because we would have an info of the
|
||||||
|
@ -500,7 +500,7 @@ impl K2VRpcHandler {
|
||||||
} else {
|
} else {
|
||||||
// If no seen marker was specified, we do not poll for anything.
|
// If no seen marker was specified, we do not poll for anything.
|
||||||
// We return immediately with the set of known items (even if
|
// We return immediately with the set of known items (even if
|
||||||
// it is empty), which will give the client an inital view of
|
// it is empty), which will give the client an initial view of
|
||||||
// the dataset and an initial seen marker for further
|
// the dataset and an initial seen marker for further
|
||||||
// PollRange calls.
|
// PollRange calls.
|
||||||
self.poll_range_read_range(range, &RangeSeenMarker::default())
|
self.poll_range_read_range(range, &RangeSeenMarker::default())
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub fn register_bg_vars(
|
||||||
|
|
||||||
impl LifecycleWorker {
|
impl LifecycleWorker {
|
||||||
pub fn new(garage: Arc<Garage>, persister: PersisterShared<LifecycleWorkerPersisted>) -> Self {
|
pub fn new(garage: Arc<Garage>, persister: PersisterShared<LifecycleWorkerPersisted>) -> Self {
|
||||||
let today = today();
|
let today = today(garage.config.use_local_tz);
|
||||||
let last_completed = persister.get_with(|x| {
|
let last_completed = persister.get_with(|x| {
|
||||||
x.last_completed
|
x.last_completed
|
||||||
.as_deref()
|
.as_deref()
|
||||||
|
@ -205,8 +205,9 @@ impl Worker for LifecycleWorker {
|
||||||
async fn wait_for_work(&mut self) -> WorkerState {
|
async fn wait_for_work(&mut self) -> WorkerState {
|
||||||
match &self.state {
|
match &self.state {
|
||||||
State::Completed(d) => {
|
State::Completed(d) => {
|
||||||
|
let use_local_tz = self.garage.config.use_local_tz;
|
||||||
let next_day = d.succ_opt().expect("no next day");
|
let next_day = d.succ_opt().expect("no next day");
|
||||||
let next_start = midnight_ts(next_day);
|
let next_start = midnight_ts(next_day, use_local_tz);
|
||||||
loop {
|
loop {
|
||||||
let now = now_msec();
|
let now = now_msec();
|
||||||
if now < next_start {
|
if now < next_start {
|
||||||
|
@ -218,7 +219,7 @@ impl Worker for LifecycleWorker {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.state = State::start(std::cmp::max(next_day, today()));
|
self.state = State::start(std::cmp::max(next_day, today(use_local_tz)));
|
||||||
}
|
}
|
||||||
State::Running { .. } => (),
|
State::Running { .. } => (),
|
||||||
}
|
}
|
||||||
|
@ -385,10 +386,16 @@ fn check_size_filter(version_data: &ObjectVersionData, filter: &LifecycleFilter)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn midnight_ts(date: NaiveDate) -> u64 {
|
fn midnight_ts(date: NaiveDate, use_local_tz: bool) -> u64 {
|
||||||
date.and_hms_opt(0, 0, 0)
|
let midnight = date.and_hms_opt(0, 0, 0).expect("midnight does not exist");
|
||||||
.expect("midnight does not exist")
|
if use_local_tz {
|
||||||
.timestamp_millis() as u64
|
return midnight
|
||||||
|
.and_local_timezone(Local)
|
||||||
|
.single()
|
||||||
|
.expect("bad local midnight")
|
||||||
|
.timestamp_millis() as u64;
|
||||||
|
}
|
||||||
|
midnight.timestamp_millis() as u64
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_date(ts: u64) -> NaiveDate {
|
fn next_date(ts: u64) -> NaiveDate {
|
||||||
|
@ -399,6 +406,9 @@ fn next_date(ts: u64) -> NaiveDate {
|
||||||
.expect("no next day")
|
.expect("no next day")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn today() -> NaiveDate {
|
fn today(use_local_tz: bool) -> NaiveDate {
|
||||||
|
if use_local_tz {
|
||||||
|
return Local::now().naive_local().date();
|
||||||
|
}
|
||||||
Utc::now().naive_utc().date()
|
Utc::now().naive_utc().date()
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,11 @@ mod v08 {
|
||||||
/// The key at which the object is stored in its bucket, used as sorting key
|
/// The key at which the object is stored in its bucket, used as sorting key
|
||||||
pub key: String,
|
pub key: String,
|
||||||
|
|
||||||
/// The list of currenty stored versions of the object
|
/// The list of currently stored versions of the object
|
||||||
pub(super) versions: Vec<ObjectVersion>,
|
pub(super) versions: Vec<ObjectVersion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Informations about a version of an object
|
/// Information about a version of an object
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct ObjectVersion {
|
pub struct ObjectVersion {
|
||||||
/// Id of the version
|
/// Id of the version
|
||||||
|
@ -109,11 +109,11 @@ mod v09 {
|
||||||
/// The key at which the object is stored in its bucket, used as sorting key
|
/// The key at which the object is stored in its bucket, used as sorting key
|
||||||
pub key: String,
|
pub key: String,
|
||||||
|
|
||||||
/// The list of currenty stored versions of the object
|
/// The list of currently stored versions of the object
|
||||||
pub(super) versions: Vec<ObjectVersion>,
|
pub(super) versions: Vec<ObjectVersion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Informations about a version of an object
|
/// Information about a version of an object
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct ObjectVersion {
|
pub struct ObjectVersion {
|
||||||
/// Id of the version
|
/// Id of the version
|
||||||
|
@ -186,11 +186,11 @@ mod v010 {
|
||||||
/// The key at which the object is stored in its bucket, used as sorting key
|
/// The key at which the object is stored in its bucket, used as sorting key
|
||||||
pub key: String,
|
pub key: String,
|
||||||
|
|
||||||
/// The list of currenty stored versions of the object
|
/// The list of currently stored versions of the object
|
||||||
pub(super) versions: Vec<ObjectVersion>,
|
pub(super) versions: Vec<ObjectVersion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Informations about a version of an object
|
/// Information about a version of an object
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct ObjectVersion {
|
pub struct ObjectVersion {
|
||||||
/// Id of the version
|
/// Id of the version
|
||||||
|
|
|
@ -49,7 +49,7 @@ mod v08 {
|
||||||
pub offset: u64,
|
pub offset: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Informations about a single block
|
/// Information about a single block
|
||||||
#[derive(PartialEq, Eq, Ord, PartialOrd, Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Ord, PartialOrd, Clone, Copy, Debug, Serialize, Deserialize)]
|
||||||
pub struct VersionBlock {
|
pub struct VersionBlock {
|
||||||
/// Blake2 sum of the block
|
/// Blake2 sum of the block
|
||||||
|
|
|
@ -20,7 +20,7 @@ static SNAPSHOT_MUTEX: Mutex<()> = Mutex::new(());
|
||||||
|
|
||||||
// ================ snapshotting logic =====================
|
// ================ snapshotting logic =====================
|
||||||
|
|
||||||
/// Run snashot_metadata in a blocking thread and async await on it
|
/// Run snapshot_metadata in a blocking thread and async await on it
|
||||||
pub async fn async_snapshot_metadata(garage: &Arc<Garage>) -> Result<(), Error> {
|
pub async fn async_snapshot_metadata(garage: &Arc<Garage>) -> Result<(), Error> {
|
||||||
let garage = garage.clone();
|
let garage = garage.clone();
|
||||||
let worker = tokio::task::spawn_blocking(move || snapshot_metadata(&garage));
|
let worker = tokio::task::spawn_blocking(move || snapshot_metadata(&garage));
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl<T> From<tokio::sync::mpsc::error::SendError<T>> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ths trait adds a `.log_err()` method on `Result<(), E>` types,
|
/// The trait adds a `.log_err()` method on `Result<(), E>` types,
|
||||||
/// which dismisses the error by logging it to stderr.
|
/// which dismisses the error by logging it to stderr.
|
||||||
pub trait LogError {
|
pub trait LogError {
|
||||||
fn log_err(self, msg: &'static str);
|
fn log_err(self, msg: &'static str);
|
||||||
|
|
|
@ -18,7 +18,7 @@ use crate::util::*;
|
||||||
/// in the send queue of the client, and their responses in the send queue of the
|
/// in the send queue of the client, and their responses in the send queue of the
|
||||||
/// server. Lower values mean higher priority.
|
/// server. Lower values mean higher priority.
|
||||||
///
|
///
|
||||||
/// This mechanism is usefull for messages bigger than the maximum chunk size
|
/// This mechanism is useful for messages bigger than the maximum chunk size
|
||||||
/// (set at `0x4000` bytes), such as large file transfers.
|
/// (set at `0x4000` bytes), such as large file transfers.
|
||||||
/// In such case, all of the messages in the send queue with the highest priority
|
/// In such case, all of the messages in the send queue with the highest priority
|
||||||
/// will take turns to send individual chunks, in a round-robin fashion.
|
/// will take turns to send individual chunks, in a round-robin fashion.
|
||||||
|
@ -102,7 +102,7 @@ pub trait Message: Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static
|
||||||
|
|
||||||
/// The Req<M> is a helper object used to create requests and attach them
|
/// The Req<M> is a helper object used to create requests and attach them
|
||||||
/// a stream of data. If the stream is a fixed Bytes and not a ByteStream,
|
/// a stream of data. If the stream is a fixed Bytes and not a ByteStream,
|
||||||
/// Req<M> is cheaply clonable to allow the request to be sent to different
|
/// Req<M> is cheaply cloneable to allow the request to be sent to different
|
||||||
/// peers (Clone will panic if the stream is a ByteStream).
|
/// peers (Clone will panic if the stream is a ByteStream).
|
||||||
pub struct Req<M: Message> {
|
pub struct Req<M: Message> {
|
||||||
pub(crate) msg: Arc<M>,
|
pub(crate) msg: Arc<M>,
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub(crate) type VersionTag = [u8; 16];
|
||||||
pub(crate) const NETAPP_VERSION_TAG: u64 = 0x6772676e65740010; // grgnet 0x0010 (1.0)
|
pub(crate) const NETAPP_VERSION_TAG: u64 = 0x6772676e65740010; // grgnet 0x0010 (1.0)
|
||||||
|
|
||||||
/// HelloMessage is sent by the client on a Netapp connection to indicate
|
/// HelloMessage is sent by the client on a Netapp connection to indicate
|
||||||
/// that they are also a server and ready to recieve incoming connections
|
/// that they are also a server and ready to receive incoming connections
|
||||||
/// at the specified address and port. If the client doesn't know their
|
/// at the specified address and port. If the client doesn't know their
|
||||||
/// public address, they don't need to specify it and we look at the
|
/// public address, they don't need to specify it and we look at the
|
||||||
/// remote address of the socket is used instead.
|
/// remote address of the socket is used instead.
|
||||||
|
@ -290,7 +290,7 @@ impl NetApp {
|
||||||
/// Attempt to connect to a peer, given by its ip:port and its public key.
|
/// Attempt to connect to a peer, given by its ip:port and its public key.
|
||||||
/// The public key will be checked during the secret handshake process.
|
/// The public key will be checked during the secret handshake process.
|
||||||
/// This function returns once the connection has been established and a
|
/// This function returns once the connection has been established and a
|
||||||
/// successfull handshake was made. At this point we can send messages to
|
/// successful handshake was made. At this point we can send messages to
|
||||||
/// the other node with `Netapp::request`
|
/// the other node with `Netapp::request`
|
||||||
pub async fn try_connect(self: Arc<Self>, ip: SocketAddr, id: NodeID) -> Result<(), Error> {
|
pub async fn try_connect(self: Arc<Self>, ip: SocketAddr, id: NodeID) -> Result<(), Error> {
|
||||||
// Don't connect to ourself, we don't care
|
// Don't connect to ourself, we don't care
|
||||||
|
|
|
@ -138,7 +138,7 @@ pub enum PeerConnState {
|
||||||
/// A connection tentative is in progress (the nth, where n is the value stored)
|
/// A connection tentative is in progress (the nth, where n is the value stored)
|
||||||
Trying(usize),
|
Trying(usize),
|
||||||
|
|
||||||
/// We abandonned trying to connect to this peer (too many failed attempts)
|
/// We abandoned trying to connect to this peer (too many failed attempts)
|
||||||
Abandonned,
|
Abandonned,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ use crate::stream::*;
|
||||||
// - if error:
|
// - if error:
|
||||||
// - u8: error kind, encoded using error::io_errorkind_to_u8
|
// - u8: error kind, encoded using error::io_errorkind_to_u8
|
||||||
// - rest: error message
|
// - rest: error message
|
||||||
// - absent for cancel messag
|
// - absent for cancel message
|
||||||
|
|
||||||
pub(crate) type RequestID = u32;
|
pub(crate) type RequestID = u32;
|
||||||
pub(crate) type ChunkLength = u16;
|
pub(crate) type ChunkLength = u16;
|
||||||
|
@ -217,7 +217,7 @@ impl<'a> futures::Future for SendQueuePollNextReady<'a> {
|
||||||
|
|
||||||
enum DataFrame {
|
enum DataFrame {
|
||||||
/// a fixed size buffer containing some data + a boolean indicating whether
|
/// a fixed size buffer containing some data + a boolean indicating whether
|
||||||
/// there may be more data comming from this stream. Can be used for some
|
/// there may be more data coming from this stream. Can be used for some
|
||||||
/// optimization. It's an error to set it to false if there is more data, but it is correct
|
/// optimization. It's an error to set it to false if there is more data, but it is correct
|
||||||
/// (albeit sub-optimal) to set it to true if there is nothing coming after
|
/// (albeit sub-optimal) to set it to true if there is nothing coming after
|
||||||
Data(Bytes, bool),
|
Data(Bytes, bool),
|
||||||
|
@ -310,7 +310,7 @@ pub(crate) trait SendLoop: Sync {
|
||||||
// recv_fut is cancellation-safe according to tokio doc,
|
// recv_fut is cancellation-safe according to tokio doc,
|
||||||
// send_fut is cancellation-safe as implemented above?
|
// send_fut is cancellation-safe as implemented above?
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
biased; // always read incomming channel first if it has data
|
biased; // always read incoming channel first if it has data
|
||||||
sth = recv_fut => {
|
sth = recv_fut => {
|
||||||
match sth {
|
match sth {
|
||||||
Some(SendItem::Stream(id, prio, order_tag, data)) => {
|
Some(SendItem::Stream(id, prio, order_tag, data)) => {
|
||||||
|
|
|
@ -16,7 +16,7 @@ use crate::bytes_buf::BytesBuf;
|
||||||
///
|
///
|
||||||
/// Items sent in the ByteStream may be errors of type `std::io::Error`.
|
/// Items sent in the ByteStream may be errors of type `std::io::Error`.
|
||||||
/// An error indicates the end of the ByteStream: a reader should no longer read
|
/// An error indicates the end of the ByteStream: a reader should no longer read
|
||||||
/// after recieving an error, and a writer should stop writing after sending an error.
|
/// after receiving an error, and a writer should stop writing after sending an error.
|
||||||
pub type ByteStream = Pin<Box<dyn Stream<Item = Packet> + Send + Sync>>;
|
pub type ByteStream = Pin<Box<dyn Stream<Item = Packet> + Send + Sync>>;
|
||||||
|
|
||||||
/// A packet sent in a ByteStream, which may contain either
|
/// A packet sent in a ByteStream, which may contain either
|
||||||
|
|
|
@ -66,7 +66,7 @@ async fn run_test_inner(port_base: u16) {
|
||||||
println!("A pl2: {:?}", pl2);
|
println!("A pl2: {:?}", pl2);
|
||||||
assert_eq!(pl2.len(), 2);
|
assert_eq!(pl2.len(), 2);
|
||||||
|
|
||||||
// Connect third ndoe and check it peers with everyone
|
// Connect third node and check it peers with everyone
|
||||||
let (thread3, _netapp3, peering3) =
|
let (thread3, _netapp3, peering3) =
|
||||||
run_netapp(netid, pk3, sk3, addr3, vec![(pk2, addr2)], stop_rx.clone());
|
run_netapp(netid, pk3, sk3, addr3, vec![(pk2, addr2)], stop_rx.clone());
|
||||||
tokio::time::sleep(Duration::from_secs(3)).await;
|
tokio::time::sleep(Duration::from_secs(3)).await;
|
||||||
|
|
|
@ -25,7 +25,7 @@ where
|
||||||
/// This async function returns only when a true signal was received
|
/// This async function returns only when a true signal was received
|
||||||
/// from a watcher that tells us when to exit.
|
/// from a watcher that tells us when to exit.
|
||||||
///
|
///
|
||||||
/// Usefull in a select statement to interrupt another
|
/// Useful in a select statement to interrupt another
|
||||||
/// future:
|
/// future:
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// select!(
|
/// select!(
|
||||||
|
|
|
@ -133,7 +133,7 @@ impl Graph<FlowEdge> {
|
||||||
/// This function shuffles the order of the edge lists. It keeps the ids of the
|
/// This function shuffles the order of the edge lists. It keeps the ids of the
|
||||||
/// reversed edges consistent.
|
/// reversed edges consistent.
|
||||||
fn shuffle_edges(&mut self) {
|
fn shuffle_edges(&mut self) {
|
||||||
// We use deterministic randomness so that the layout calculation algorihtm
|
// We use deterministic randomness so that the layout calculation algorithm
|
||||||
// will output the same thing every time it is run. This way, the results
|
// will output the same thing every time it is run. This way, the results
|
||||||
// pre-calculated in `garage layout show` will match exactly those used
|
// pre-calculated in `garage layout show` will match exactly those used
|
||||||
// in practice with `garage layout apply`
|
// in practice with `garage layout apply`
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl LayoutHelper {
|
||||||
// sync_map_min is the minimum value of sync_map among storage nodes
|
// sync_map_min is the minimum value of sync_map among storage nodes
|
||||||
// in the cluster (non-gateway nodes only, current and previous layouts).
|
// in the cluster (non-gateway nodes only, current and previous layouts).
|
||||||
// It is the highest layout version for which we know that all relevant
|
// It is the highest layout version for which we know that all relevant
|
||||||
// storage nodes have fullfilled a sync, and therefore it is safe to
|
// storage nodes have fulfilled a sync, and therefore it is safe to
|
||||||
// use a read quorum within that layout to ensure consistency.
|
// use a read quorum within that layout to ensure consistency.
|
||||||
// Gateway nodes are excluded here because they hold no relevant data
|
// Gateway nodes are excluded here because they hold no relevant data
|
||||||
// (they store the bucket and access key tables, but we don't have
|
// (they store the bucket and access key tables, but we don't have
|
||||||
|
|
|
@ -48,7 +48,7 @@ impl LayoutManager {
|
||||||
Ok(x) => {
|
Ok(x) => {
|
||||||
if x.current().replication_factor != replication_factor.replication_factor() {
|
if x.current().replication_factor != replication_factor.replication_factor() {
|
||||||
return Err(Error::Message(format!(
|
return Err(Error::Message(format!(
|
||||||
"Prevous cluster layout has replication factor {}, which is different than the one specified in the config file ({}). The previous cluster layout can be purged, if you know what you are doing, simply by deleting the `cluster_layout` file in your metadata directory.",
|
"Previous cluster layout has replication factor {}, which is different than the one specified in the config file ({}). The previous cluster layout can be purged, if you know what you are doing, simply by deleting the `cluster_layout` file in your metadata directory.",
|
||||||
x.current().replication_factor,
|
x.current().replication_factor,
|
||||||
replication_factor.replication_factor()
|
replication_factor.replication_factor()
|
||||||
)));
|
)));
|
||||||
|
|
|
@ -241,7 +241,7 @@ mod v010 {
|
||||||
/// The versions currently in use in the cluster
|
/// The versions currently in use in the cluster
|
||||||
pub versions: Vec<LayoutVersion>,
|
pub versions: Vec<LayoutVersion>,
|
||||||
/// At most 5 of the previous versions, not used by the garage_table
|
/// At most 5 of the previous versions, not used by the garage_table
|
||||||
/// module, but usefull for the garage_block module to find data blocks
|
/// module, but useful for the garage_block module to find data blocks
|
||||||
/// that have not yet been moved
|
/// that have not yet been moved
|
||||||
pub old_versions: Vec<LayoutVersion>,
|
pub old_versions: Vec<LayoutVersion>,
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::replication_mode::ReplicationFactor;
|
||||||
|
|
||||||
// This function checks that the partition size S computed is at least better than the
|
// This function checks that the partition size S computed is at least better than the
|
||||||
// one given by a very naive algorithm. To do so, we try to run the naive algorithm
|
// one given by a very naive algorithm. To do so, we try to run the naive algorithm
|
||||||
// assuming a partion size of S+1. If we succed, it means that the optimal assignment
|
// assuming a partition size of S+1. If we succeed, it means that the optimal assignment
|
||||||
// was not optimal. The naive algorithm is the following :
|
// was not optimal. The naive algorithm is the following :
|
||||||
// - we compute the max number of partitions associated to every node, capped at the
|
// - we compute the max number of partitions associated to every node, capped at the
|
||||||
// partition number. It gives the number of tokens of every node.
|
// partition number. It gives the number of tokens of every node.
|
||||||
|
|
|
@ -471,7 +471,7 @@ impl LayoutVersion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We clear the ring assignemnt data
|
// We clear the ring assignment data
|
||||||
self.ring_assignment_data = Vec::<CompactNodeType>::new();
|
self.ring_assignment_data = Vec::<CompactNodeType>::new();
|
||||||
|
|
||||||
Ok(Some(old_assignment))
|
Ok(Some(old_assignment))
|
||||||
|
|
|
@ -413,7 +413,7 @@ impl RpcHelper {
|
||||||
/// Make a RPC call to multiple servers, returning either a Vec of responses,
|
/// Make a RPC call to multiple servers, returning either a Vec of responses,
|
||||||
/// or an error if quorum could not be reached due to too many errors
|
/// or an error if quorum could not be reached due to too many errors
|
||||||
///
|
///
|
||||||
/// Contrary to try_call_many, this fuction is especially made for broadcast
|
/// Contrary to try_call_many, this function is especially made for broadcast
|
||||||
/// write operations. In particular:
|
/// write operations. In particular:
|
||||||
///
|
///
|
||||||
/// - The request are sent to all specified nodes as soon as `try_write_many_sets`
|
/// - The request are sent to all specified nodes as soon as `try_write_many_sets`
|
||||||
|
@ -506,7 +506,7 @@ impl RpcHelper {
|
||||||
|
|
||||||
// If we have a quorum of ok in all quorum sets, then it's a success!
|
// If we have a quorum of ok in all quorum sets, then it's a success!
|
||||||
if result_tracker.all_quorums_ok() {
|
if result_tracker.all_quorums_ok() {
|
||||||
// Continue all other requets in background
|
// Continue all other requests in background
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
resp_stream.collect::<Vec<(Uuid, Result<_, _>)>>().await;
|
resp_stream.collect::<Vec<(Uuid, Result<_, _>)>>().await;
|
||||||
drop(drop_on_complete);
|
drop(drop_on_complete);
|
||||||
|
|
|
@ -54,7 +54,7 @@ pub const SYSTEM_RPC_PATH: &str = "garage_rpc/system.rs/SystemRpc";
|
||||||
/// RPC messages related to membership
|
/// RPC messages related to membership
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub enum SystemRpc {
|
pub enum SystemRpc {
|
||||||
/// Response to successfull advertisements
|
/// Response to successful advertisements
|
||||||
Ok,
|
Ok,
|
||||||
/// Request to connect to a specific node (in <pubkey>@<host>:<port> format, pubkey = full-length node ID)
|
/// Request to connect to a specific node (in <pubkey>@<host>:<port> format, pubkey = full-length node ID)
|
||||||
Connect(String),
|
Connect(String),
|
||||||
|
@ -172,7 +172,7 @@ pub struct ClusterHealth {
|
||||||
pub enum ClusterHealthStatus {
|
pub enum ClusterHealthStatus {
|
||||||
/// All nodes are available
|
/// All nodes are available
|
||||||
Healthy,
|
Healthy,
|
||||||
/// Some storage nodes are unavailable, but quorum is stil
|
/// Some storage nodes are unavailable, but quorum is still
|
||||||
/// achieved for all partitions
|
/// achieved for all partitions
|
||||||
Degraded,
|
Degraded,
|
||||||
/// Quorum is not available for some partitions
|
/// Quorum is not available for some partitions
|
||||||
|
@ -286,7 +286,7 @@ impl System {
|
||||||
let mut local_status = NodeStatus::initial(replication_factor, &layout_manager);
|
let mut local_status = NodeStatus::initial(replication_factor, &layout_manager);
|
||||||
local_status.update_disk_usage(&config.metadata_dir, &config.data_dir);
|
local_status.update_disk_usage(&config.metadata_dir, &config.data_dir);
|
||||||
|
|
||||||
// ---- if enabled, set up additionnal peer discovery methods ----
|
// ---- if enabled, set up additional peer discovery methods ----
|
||||||
#[cfg(feature = "consul-discovery")]
|
#[cfg(feature = "consul-discovery")]
|
||||||
let consul_discovery = match &config.consul_discovery {
|
let consul_discovery = match &config.consul_discovery {
|
||||||
Some(cfg) => Some(
|
Some(cfg) => Some(
|
||||||
|
@ -337,7 +337,7 @@ impl System {
|
||||||
Ok(sys)
|
Ok(sys)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform bootstraping, starting the ping loop
|
/// Perform bootstrapping, starting the ping loop
|
||||||
pub async fn run(self: Arc<Self>, must_exit: watch::Receiver<bool>) {
|
pub async fn run(self: Arc<Self>, must_exit: watch::Receiver<bool>) {
|
||||||
join!(
|
join!(
|
||||||
self.netapp.clone().listen(
|
self.netapp.clone().listen(
|
||||||
|
@ -807,6 +807,16 @@ impl NodeStatus {
|
||||||
|
|
||||||
fn update_disk_usage(&mut self, meta_dir: &Path, data_dir: &DataDirEnum) {
|
fn update_disk_usage(&mut self, meta_dir: &Path, data_dir: &DataDirEnum) {
|
||||||
use nix::sys::statvfs::statvfs;
|
use nix::sys::statvfs::statvfs;
|
||||||
|
|
||||||
|
// The HashMap used below requires a filesystem identifier from statfs (instead of statvfs) on FreeBSD, as
|
||||||
|
// FreeBSD's statvfs filesystem identifier is "not meaningful in this implementation" (man 3 statvfs).
|
||||||
|
|
||||||
|
#[cfg(target_os = "freebsd")]
|
||||||
|
let get_filesystem_id = |path: &Path| match nix::sys::statfs::statfs(path) {
|
||||||
|
Ok(fs) => Some(fs.filesystem_id()),
|
||||||
|
Err(_) => None,
|
||||||
|
};
|
||||||
|
|
||||||
let mount_avail = |path: &Path| match statvfs(path) {
|
let mount_avail = |path: &Path| match statvfs(path) {
|
||||||
Ok(x) => {
|
Ok(x) => {
|
||||||
let avail = x.blocks_available() as u64 * x.fragment_size() as u64;
|
let avail = x.blocks_available() as u64 * x.fragment_size() as u64;
|
||||||
|
@ -817,6 +827,7 @@ impl NodeStatus {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.meta_disk_avail = mount_avail(meta_dir).map(|(_, a, t)| (a, t));
|
self.meta_disk_avail = mount_avail(meta_dir).map(|(_, a, t)| (a, t));
|
||||||
|
|
||||||
self.data_disk_avail = match data_dir {
|
self.data_disk_avail = match data_dir {
|
||||||
DataDirEnum::Single(dir) => mount_avail(dir).map(|(_, a, t)| (a, t)),
|
DataDirEnum::Single(dir) => mount_avail(dir).map(|(_, a, t)| (a, t)),
|
||||||
DataDirEnum::Multiple(dirs) => (|| {
|
DataDirEnum::Multiple(dirs) => (|| {
|
||||||
|
@ -827,12 +838,25 @@ impl NodeStatus {
|
||||||
if dir.capacity.is_none() {
|
if dir.capacity.is_none() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "freebsd"))]
|
||||||
match mount_avail(&dir.path) {
|
match mount_avail(&dir.path) {
|
||||||
Some((fsid, avail, total)) => {
|
Some((fsid, avail, total)) => {
|
||||||
mounts.insert(fsid, (avail, total));
|
mounts.insert(fsid, (avail, total));
|
||||||
}
|
}
|
||||||
None => return None,
|
None => return None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "freebsd")]
|
||||||
|
match get_filesystem_id(&dir.path) {
|
||||||
|
Some(fsid) => match mount_avail(&dir.path) {
|
||||||
|
Some((_, avail, total)) => {
|
||||||
|
mounts.insert(fsid, (avail, total));
|
||||||
|
}
|
||||||
|
None => return None,
|
||||||
|
},
|
||||||
|
None => return None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some(
|
Some(
|
||||||
mounts
|
mounts
|
||||||
|
|
|
@ -258,14 +258,14 @@ impl<F: TableSchema, R: TableReplication> TableGc<F, R> {
|
||||||
.await
|
.await
|
||||||
.err_context("GC: remote delete tombstones")?;
|
.err_context("GC: remote delete tombstones")?;
|
||||||
|
|
||||||
// GC has been successfull for all of these entries.
|
// GC has been successful for all of these entries.
|
||||||
// We now remove them all from our local table and from the GC todo list.
|
// We now remove them all from our local table and from the GC todo list.
|
||||||
for item in items {
|
for item in items {
|
||||||
self.data
|
self.data
|
||||||
.delete_if_equal_hash(&item.key[..], item.value_hash)
|
.delete_if_equal_hash(&item.key[..], item.value_hash)
|
||||||
.err_context("GC: local delete tombstones")?;
|
.err_context("GC: local delete tombstones")?;
|
||||||
item.remove_if_equal(&self.data.gc_todo)
|
item.remove_if_equal(&self.data.gc_todo)
|
||||||
.err_context("GC: remove from todo list after successfull GC")?;
|
.err_context("GC: remove from todo list after successful GC")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -383,7 +383,7 @@ impl GcTodoEntry {
|
||||||
|
|
||||||
/// Removes the GcTodoEntry from the gc_todo tree if the
|
/// Removes the GcTodoEntry from the gc_todo tree if the
|
||||||
/// hash of the serialized value is the same here as in the tree.
|
/// hash of the serialized value is the same here as in the tree.
|
||||||
/// This is usefull to remove a todo entry only under the condition
|
/// This is useful to remove a todo entry only under the condition
|
||||||
/// that it has not changed since the time it was read, i.e.
|
/// that it has not changed since the time it was read, i.e.
|
||||||
/// what we have to do is still the same
|
/// what we have to do is still the same
|
||||||
pub(crate) fn remove_if_equal(&self, gc_todo_tree: &db::Tree) -> Result<(), Error> {
|
pub(crate) fn remove_if_equal(&self, gc_todo_tree: &db::Tree) -> Result<(), Error> {
|
||||||
|
|
|
@ -13,12 +13,12 @@ pub trait TableReplication: Send + Sync + 'static {
|
||||||
|
|
||||||
/// Which nodes to send read requests to
|
/// Which nodes to send read requests to
|
||||||
fn read_nodes(&self, hash: &Hash) -> Vec<Uuid>;
|
fn read_nodes(&self, hash: &Hash) -> Vec<Uuid>;
|
||||||
/// Responses needed to consider a read succesfull
|
/// Responses needed to consider a read successful
|
||||||
fn read_quorum(&self) -> usize;
|
fn read_quorum(&self) -> usize;
|
||||||
|
|
||||||
/// Which nodes to send writes to
|
/// Which nodes to send writes to
|
||||||
fn write_sets(&self, hash: &Hash) -> Self::WriteSets;
|
fn write_sets(&self, hash: &Hash) -> Self::WriteSets;
|
||||||
/// Responses needed to consider a write succesfull in each set
|
/// Responses needed to consider a write successful in each set
|
||||||
fn write_quorum(&self) -> usize;
|
fn write_quorum(&self) -> usize;
|
||||||
|
|
||||||
// Accessing partitions, for Merkle tree & sync
|
// Accessing partitions, for Merkle tree & sync
|
||||||
|
|
|
@ -316,7 +316,7 @@ impl<F: TableSchema, R: TableReplication> TableSyncer<F, R> {
|
||||||
SyncRpc::RootCkDifferent(true) => VecDeque::from(vec![root_ck_key]),
|
SyncRpc::RootCkDifferent(true) => VecDeque::from(vec![root_ck_key]),
|
||||||
x => {
|
x => {
|
||||||
return Err(Error::Message(format!(
|
return Err(Error::Message(format!(
|
||||||
"Invalid respone to RootCkHash RPC: {}",
|
"Invalid response to RootCkHash RPC: {}",
|
||||||
debug_serialize(x)
|
debug_serialize(x)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ impl<F: TableSchema, R: TableReplication> TableSyncer<F, R> {
|
||||||
SyncRpc::Node(_, node) => node,
|
SyncRpc::Node(_, node) => node,
|
||||||
x => {
|
x => {
|
||||||
return Err(Error::Message(format!(
|
return Err(Error::Message(format!(
|
||||||
"Invalid respone to GetNode RPC: {}",
|
"Invalid response to GetNode RPC: {}",
|
||||||
debug_serialize(x)
|
debug_serialize(x)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,11 +171,11 @@ impl<F: TableSchema, R: TableReplication> Table<F, R> {
|
||||||
// We will here batch all items into a single request for each concerned
|
// We will here batch all items into a single request for each concerned
|
||||||
// node, with all of the entries it must store within that request.
|
// node, with all of the entries it must store within that request.
|
||||||
// Each entry has to be saved to a specific list of "write sets", i.e. a set
|
// Each entry has to be saved to a specific list of "write sets", i.e. a set
|
||||||
// of node within wich a quorum must be achieved. In normal operation, there
|
// of node within which a quorum must be achieved. In normal operation, there
|
||||||
// is a single write set which corresponds to the quorum in the current
|
// is a single write set which corresponds to the quorum in the current
|
||||||
// cluster layout, but when the layout is updated, multiple write sets might
|
// cluster layout, but when the layout is updated, multiple write sets might
|
||||||
// have to be handled at once. Here, since we are sending many entries, we
|
// have to be handled at once. Here, since we are sending many entries, we
|
||||||
// will have to handle many write sets in all cases. The algorihtm is thus
|
// will have to handle many write sets in all cases. The algorithm is thus
|
||||||
// to send one request to each node with all the items it must save,
|
// to send one request to each node with all the items it must save,
|
||||||
// and keep track of the OK responses within each write set: if for all sets
|
// and keep track of the OK responses within each write set: if for all sets
|
||||||
// a quorum of nodes has answered OK, then the insert has succeeded and
|
// a quorum of nodes has answered OK, then the insert has succeeded and
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::background::{WorkerInfo, WorkerStatus};
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::time::now_msec;
|
use crate::time::now_msec;
|
||||||
|
|
||||||
// All workers that haven't exited for this time after an exit signal was recieved
|
// All workers that haven't exited for this time after an exit signal was received
|
||||||
// will be interrupted in the middle of whatever they are doing.
|
// will be interrupted in the middle of whatever they are doing.
|
||||||
const EXIT_DEADLINE: Duration = Duration::from_secs(8);
|
const EXIT_DEADLINE: Duration = Duration::from_secs(8);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ pub trait Worker: Send {
|
||||||
async fn work(&mut self, must_exit: &mut watch::Receiver<bool>) -> Result<WorkerState, Error>;
|
async fn work(&mut self, must_exit: &mut watch::Receiver<bool>) -> Result<WorkerState, Error>;
|
||||||
|
|
||||||
/// Wait for work: await for some task to become available. This future can be interrupted in
|
/// Wait for work: await for some task to become available. This future can be interrupted in
|
||||||
/// the middle for any reason, for example if an interrupt signal was recieved.
|
/// the middle for any reason, for example if an interrupt signal was received.
|
||||||
async fn wait_for_work(&mut self) -> WorkerState;
|
async fn wait_for_work(&mut self) -> WorkerState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,10 @@ pub struct Config {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub disable_scrub: bool,
|
pub disable_scrub: bool,
|
||||||
|
|
||||||
|
/// Use local timezone
|
||||||
|
#[serde(default)]
|
||||||
|
pub use_local_tz: bool,
|
||||||
|
|
||||||
/// Automatic snapshot interval for metadata
|
/// Automatic snapshot interval for metadata
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub metadata_auto_snapshot_interval: Option<String>,
|
pub metadata_auto_snapshot_interval: Option<String>,
|
||||||
|
@ -89,12 +93,12 @@ pub struct Config {
|
||||||
/// the addresses announced to other peers to a specific subnet.
|
/// the addresses announced to other peers to a specific subnet.
|
||||||
pub rpc_public_addr_subnet: Option<String>,
|
pub rpc_public_addr_subnet: Option<String>,
|
||||||
|
|
||||||
/// Timeout for Netapp's ping messagess
|
/// Timeout for Netapp's ping messages
|
||||||
pub rpc_ping_timeout_msec: Option<u64>,
|
pub rpc_ping_timeout_msec: Option<u64>,
|
||||||
/// Timeout for Netapp RPC calls
|
/// Timeout for Netapp RPC calls
|
||||||
pub rpc_timeout_msec: Option<u64>,
|
pub rpc_timeout_msec: Option<u64>,
|
||||||
|
|
||||||
// -- Bootstraping and discovery
|
// -- Bootstrapping and discovery
|
||||||
/// Bootstrap peers RPC address
|
/// Bootstrap peers RPC address
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub bootstrap_peers: Vec<String>,
|
pub bootstrap_peers: Vec<String>,
|
||||||
|
|
|
@ -33,8 +33,8 @@ pub trait Crdt {
|
||||||
/// arises very often, for example with a Lww or a LwwMap: the value type has to be a CRDT so that
|
/// arises very often, for example with a Lww or a LwwMap: the value type has to be a CRDT so that
|
||||||
/// we have a rule for what to do when timestamps aren't enough to disambiguate (in a distributed
|
/// we have a rule for what to do when timestamps aren't enough to disambiguate (in a distributed
|
||||||
/// system, anything can happen!), and with AutoCrdt the rule is to make an arbitrary (but
|
/// system, anything can happen!), and with AutoCrdt the rule is to make an arbitrary (but
|
||||||
/// determinstic) choice between the two. When using an Option<T> instead with this impl, ambiguity
|
/// deterministic) choice between the two. When using an Option<T> instead with this impl, ambiguity
|
||||||
/// cases are explicitely stored as None, which allows us to detect the ambiguity and handle it in
|
/// cases are explicitly stored as None, which allows us to detect the ambiguity and handle it in
|
||||||
/// the way we want. (this can only work if we are happy with losing the value when an ambiguity
|
/// the way we want. (this can only work if we are happy with losing the value when an ambiguity
|
||||||
/// arises)
|
/// arises)
|
||||||
impl<T> Crdt for Option<T>
|
impl<T> Crdt for Option<T>
|
||||||
|
|
|
@ -16,7 +16,7 @@ use crate::crdt::crdt::*;
|
||||||
/// In our case, we add the constraint that the value that is wrapped inside the LWW CRDT must
|
/// In our case, we add the constraint that the value that is wrapped inside the LWW CRDT must
|
||||||
/// itself be a CRDT: in the case when the timestamp does not allow us to decide on which value to
|
/// itself be a CRDT: in the case when the timestamp does not allow us to decide on which value to
|
||||||
/// keep, the merge rule of the inner CRDT is applied on the wrapped values. (Note that all types
|
/// keep, the merge rule of the inner CRDT is applied on the wrapped values. (Note that all types
|
||||||
/// that implement the `Ord` trait get a default CRDT implemetnation that keeps the maximum value.
|
/// that implement the `Ord` trait get a default CRDT implementation that keeps the maximum value.
|
||||||
/// This enables us to use LWW directly with primitive data types such as numbers or strings. It is
|
/// This enables us to use LWW directly with primitive data types such as numbers or strings. It is
|
||||||
/// generally desirable in this case to never explicitly produce LWW values with the same timestamp
|
/// generally desirable in this case to never explicitly produce LWW values with the same timestamp
|
||||||
/// but different inner values, as the rule to keep the maximum value isn't generally the desired
|
/// but different inner values, as the rule to keep the maximum value isn't generally the desired
|
||||||
|
@ -28,9 +28,9 @@ use crate::crdt::crdt::*;
|
||||||
///
|
///
|
||||||
/// Given that clocks are not too desynchronized, this assumption
|
/// Given that clocks are not too desynchronized, this assumption
|
||||||
/// is enough for most cases, as there is few chance that two humans
|
/// is enough for most cases, as there is few chance that two humans
|
||||||
/// coordonate themself faster than the time difference between two NTP servers.
|
/// coordinate themself faster than the time difference between two NTP servers.
|
||||||
///
|
///
|
||||||
/// As a more concret example, let's suppose you want to upload a file
|
/// As a more concrete example, let's suppose you want to upload a file
|
||||||
/// with the same key (path) in the same bucket at the very same time.
|
/// with the same key (path) in the same bucket at the very same time.
|
||||||
/// For each request, the file will be timestamped by the receiving server
|
/// For each request, the file will be timestamped by the receiving server
|
||||||
/// and may differ from what you observed with your atomic clock!
|
/// and may differ from what you observed with your atomic clock!
|
||||||
|
@ -84,16 +84,16 @@ where
|
||||||
&self.v
|
&self.v
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Take the value inside the CRDT (discards the timesamp)
|
/// Take the value inside the CRDT (discards the timestamp)
|
||||||
pub fn take(self) -> T {
|
pub fn take(self) -> T {
|
||||||
self.v
|
self.v
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a mutable reference to the CRDT's value
|
/// Get a mutable reference to the CRDT's value
|
||||||
///
|
///
|
||||||
/// This is usefull to mutate the inside value without changing the LWW timestamp.
|
/// This is useful to mutate the inside value without changing the LWW timestamp.
|
||||||
/// When such mutation is done, the merge between two LWW values is done using the inner
|
/// When such mutation is done, the merge between two LWW values is done using the inner
|
||||||
/// CRDT's merge operation. This is usefull in the case where the inner CRDT is a large
|
/// CRDT's merge operation. This is useful in the case where the inner CRDT is a large
|
||||||
/// data type, such as a map, and we only want to change a single item in the map.
|
/// data type, such as a map, and we only want to change a single item in the map.
|
||||||
/// To do this, we can produce a "CRDT delta", i.e. a LWW that contains only the modification.
|
/// To do this, we can produce a "CRDT delta", i.e. a LWW that contains only the modification.
|
||||||
/// This delta consists in a LWW with the same timestamp, and the map
|
/// This delta consists in a LWW with the same timestamp, and the map
|
||||||
|
|
|
@ -109,7 +109,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes all of the values of the map and returns them. The current map is reset to the
|
/// Takes all of the values of the map and returns them. The current map is reset to the
|
||||||
/// empty map. This is very usefull to produce in-place a new map that contains only a delta
|
/// empty map. This is very useful to produce in-place a new map that contains only a delta
|
||||||
/// that modifies a certain value:
|
/// that modifies a certain value:
|
||||||
///
|
///
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
|
@ -162,7 +162,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a reference to all of the items, as a slice. Usefull to iterate on all map values.
|
/// Gets a reference to all of the items, as a slice. Useful to iterate on all map values.
|
||||||
/// In most case you will want to ignore the timestamp (second item of the tuple).
|
/// In most case you will want to ignore the timestamp (second item of the tuple).
|
||||||
pub fn items(&self) -> &[(K, u64, V)] {
|
pub fn items(&self) -> &[(K, u64, V)] {
|
||||||
&self.vals[..]
|
&self.vals[..]
|
||||||
|
|
|
@ -57,7 +57,7 @@ where
|
||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Gets a reference to all of the items, as a slice. Usefull to iterate on all map values.
|
/// Gets a reference to all of the items, as a slice. Useful to iterate on all map values.
|
||||||
pub fn items(&self) -> &[(K, V)] {
|
pub fn items(&self) -> &[(K, V)] {
|
||||||
&self.vals[..]
|
&self.vals[..]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Serialize to MessagePacki, without versionning
|
/// Serialize to MessagePack, without versioning
|
||||||
/// (see garage_util::migrate for functions that manage versionned
|
/// (see garage_util::migrate for functions that manage versioned
|
||||||
/// data formats)
|
/// data formats)
|
||||||
pub fn nonversioned_encode<T>(val: &T) -> Result<Vec<u8>, rmp_serde::encode::Error>
|
pub fn nonversioned_encode<T>(val: &T) -> Result<Vec<u8>, rmp_serde::encode::Error>
|
||||||
where
|
where
|
||||||
|
@ -13,8 +13,8 @@ where
|
||||||
Ok(wr)
|
Ok(wr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserialize from MessagePacki, without versionning
|
/// Deserialize from MessagePack, without versioning
|
||||||
/// (see garage_util::migrate for functions that manage versionned
|
/// (see garage_util::migrate for functions that manage versioned
|
||||||
/// data formats)
|
/// data formats)
|
||||||
pub fn nonversioned_decode<T>(bytes: &[u8]) -> Result<T, rmp_serde::decode::Error>
|
pub fn nonversioned_decode<T>(bytes: &[u8]) -> Result<T, rmp_serde::decode::Error>
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in a new issue