mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-07-26 16:08:13 +00:00
Merge pull request 'throw error on legacy replication_mode setting' (#1018) from yuka/garage:remove-replication-mode into next-v2
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1018
This commit is contained in:
@@ -45,7 +45,7 @@ This is an example `values.overrride.yaml` for deploying in a microk8s cluster w
|
||||
```yaml
|
||||
garage:
|
||||
# Use only 2 replicas per object
|
||||
replicationMode: "2"
|
||||
replicationFactor: 2
|
||||
|
||||
# Start 4 instances (StatefulSets) of garage
|
||||
deployment:
|
||||
|
||||
@@ -30,6 +30,12 @@ for count in $(seq 1 3); do
|
||||
CONF_PATH="/tmp/config.$count.toml"
|
||||
LABEL="\e[${FANCYCOLORS[$count]}[$count]\e[49m"
|
||||
|
||||
if [ "$GARAGE_OLDVER" == "v08" ]; then
|
||||
REPLICATION_MODE="replication_mode = \"3\""
|
||||
else
|
||||
REPLICATION_MODE="replication_factor = 3"
|
||||
fi
|
||||
|
||||
cat > $CONF_PATH <<EOF
|
||||
block_size = 1048576 # objects are split in blocks of maximum this number of bytes
|
||||
metadata_dir = "/tmp/garage-meta-$count"
|
||||
@@ -38,7 +44,7 @@ data_dir = "/tmp/garage-data-$count"
|
||||
rpc_bind_addr = "0.0.0.0:$((3900+$count))" # the port other Garage nodes will use to talk to this node
|
||||
rpc_public_addr = "127.0.0.1:$((3900+$count))"
|
||||
bootstrap_peers = []
|
||||
replication_mode = "3"
|
||||
$REPLICATION_MODE
|
||||
rpc_secret = "$NETWORK_SECRET"
|
||||
|
||||
[s3_api]
|
||||
|
||||
@@ -16,14 +16,15 @@ S3-compatible object store for small self-hosted geo-distributed deployments
|
||||
| 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.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.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 |
|
||||
| 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.replicationFactor | string | `"3"` | Default to 3 replicas, see the replication_factor section at https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#replication_factor |
|
||||
| garage.consistencyMode | string | `"consistent"` | Default to read-after-write consistency, see the consistency_mode section at https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#consistency_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"` | |
|
||||
|
||||
@@ -15,7 +15,8 @@ data:
|
||||
|
||||
block_size = {{ .Values.garage.blockSize }}
|
||||
|
||||
replication_mode = "{{ .Values.garage.replicationMode }}"
|
||||
replication_factor = {{ .Values.garage.replicationFactor }}
|
||||
consistency_mode = "{{ .Values.garage.consistencyMode }}"
|
||||
|
||||
compression_level = {{ .Values.garage.compressionLevel }}
|
||||
|
||||
|
||||
@@ -5,20 +5,24 @@
|
||||
# Garage configuration. These values go to garage.toml
|
||||
garage:
|
||||
# -- 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
|
||||
dbEngine: "lmdb"
|
||||
|
||||
# -- Defaults is 1MB
|
||||
# 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"
|
||||
|
||||
# -- Default to 3 replicas, see the replication_mode section at
|
||||
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#replication-mode
|
||||
replicationMode: "3"
|
||||
# -- Default to 3 replicas, see the replication_factor section at
|
||||
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#replication_factor
|
||||
replicationFactor: "3"
|
||||
|
||||
# -- By default, enable read-after-write consistency guarantees, see the consistency_mode section at
|
||||
# https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#consistency_mode
|
||||
consistencyMode: "consistent"
|
||||
|
||||
# -- 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"
|
||||
|
||||
rpcBindAddr: "[::]:3901"
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"rpc_bind_addr = \"0.0.0.0:3901\"\n"
|
||||
"rpc_public_addr = \"" node ":3901\"\n"
|
||||
"db_engine = \"lmdb\"\n"
|
||||
"replication_mode = \"3\"\n"
|
||||
"replication_factor = 3\n"
|
||||
"data_dir = \"" data-dir "\"\n"
|
||||
"metadata_dir = \"" meta-dir "\"\n"
|
||||
"[s3_api]\n"
|
||||
|
||||
@@ -8,7 +8,7 @@ data:
|
||||
metadata_dir = "/tmp/meta"
|
||||
data_dir = "/tmp/data"
|
||||
|
||||
replication_mode = "3"
|
||||
replication_factor = 3
|
||||
|
||||
rpc_bind_addr = "[::]:3901"
|
||||
rpc_secret = "1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec"
|
||||
|
||||
+14
-22
@@ -71,26 +71,18 @@ pub fn parse_replication_mode(
|
||||
config: &Config,
|
||||
) -> Result<(ReplicationFactor, ConsistencyMode), Error> {
|
||||
match (&config.replication_mode, config.replication_factor, config.consistency_mode.as_str()) {
|
||||
(Some(replication_mode), None, "consistent") => {
|
||||
tracing::warn!("Legacy config option replication_mode in use. Please migrate to replication_factor and consistency_mode");
|
||||
let parsed_replication_mode = match replication_mode.as_str() {
|
||||
"1" | "none" => Some((ReplicationFactor(1), ConsistencyMode::Consistent)),
|
||||
"2" => Some((ReplicationFactor(2), ConsistencyMode::Consistent)),
|
||||
"2-dangerous" => Some((ReplicationFactor(2), ConsistencyMode::Dangerous)),
|
||||
"3" => Some((ReplicationFactor(3), ConsistencyMode::Consistent)),
|
||||
"3-degraded" => Some((ReplicationFactor(3), ConsistencyMode::Degraded)),
|
||||
"3-dangerous" => Some((ReplicationFactor(3), ConsistencyMode::Dangerous)),
|
||||
_ => None,
|
||||
};
|
||||
Some(parsed_replication_mode.ok_or_message("Invalid replication_mode in config file.")?)
|
||||
},
|
||||
(None, Some(replication_factor), consistency_mode) => {
|
||||
let replication_factor = ReplicationFactor::new(replication_factor)
|
||||
.ok_or_message("Invalid replication_factor in config file.")?;
|
||||
let consistency_mode = ConsistencyMode::parse(consistency_mode)
|
||||
.ok_or_message("Invalid consistency_mode in config file.")?;
|
||||
Some((replication_factor, consistency_mode))
|
||||
}
|
||||
_ => None,
|
||||
}.ok_or_message("Either the legacy replication_mode or replication_level and consistency_mode can be set, not both.")
|
||||
(Some(_replication_mode), _, _) => {
|
||||
Err(Error::Message("The legacy replication_mode is no longer supported. Use replication_factor and consistency_mode instead.".into()))
|
||||
}
|
||||
(None, Some(replication_factor), consistency_mode) => {
|
||||
let replication_factor = ReplicationFactor::new(replication_factor)
|
||||
.ok_or_message("Invalid replication_factor in config file.")?;
|
||||
let consistency_mode = ConsistencyMode::parse(consistency_mode)
|
||||
.ok_or_message("Invalid consistency_mode in config file.")?;
|
||||
Ok((replication_factor, consistency_mode))
|
||||
}
|
||||
(None, None, _) => {
|
||||
Err(Error::Message("The option replication_factor is required.".into()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user