From 1284b4f7fa36a3e4e7f05a979f56136277ac8983 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 15 May 2024 11:30:39 +0200 Subject: [PATCH 1/3] Reapply "nixos/garage: drop replication_mode setting" This reverts commit 67cf6279d046f35a3a5be87af074ef063354d1b2. Reintroduce the option, we'll fix it in followup commits. --- nixos/modules/services/web-servers/garage.nix | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/web-servers/garage.nix b/nixos/modules/services/web-servers/garage.nix index 39ea8f21b126..f75829d64d67 100644 --- a/nixos/modules/services/web-servers/garage.nix +++ b/nixos/modules/services/web-servers/garage.nix @@ -52,13 +52,6 @@ in type = types.path; description = "The main data storage, put this on your large storage (e.g. high capacity HDD)"; }; - - replication_mode = mkOption { - default = "none"; - type = types.enum ([ "none" "1" "2" "3" "2-dangerous" "3-dangerous" "3-degraded" 1 2 3 ]); - apply = v: toString v; - description = "Garage replication mode, defaults to none, see: for reference."; - }; }; }; description = "Garage configuration, see for reference."; @@ -71,6 +64,24 @@ in }; config = mkIf cfg.enable { + + assertions = [ + # We removed our module-level default for replication_mode. If a user upgraded + # to garage 1.0.0 while relying on the module-level default, they would be left + # with a config which evaluates and builds, but then garage refuses to start + # because either replication_factor or replication_mode is required. + # This assertion can be removed in NixOS 24.11, when all users have been warned once. + { + assertion = (cfg.settings ? replication_factor || cfg.settings ? replication_mode) || lib.versionOlder cfg.package "1.0.0"; + message = '' + Garage 1.0.0 requires an explicit replication factor to be set. + Please set replication_factor to 1 explicitly to preserve the previous behavior. + https://git.deuxfleurs.fr/Deuxfleurs/garage/src/tag/v1.0.0/doc/book/reference-manual/configuration.md#replication_factor + + ''; + } + ]; + environment.etc."garage.toml" = { source = configFile; }; From 24ace2abee4d9ae78cb79d3dc82cf7439d067bb2 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 15 May 2024 11:48:25 +0200 Subject: [PATCH 2/3] nixos/garage: assert that replication_mode is string The explicit `replication_mode` option in `services.garage.settings` has been removed and is now handled by the freeform settings in order to allow it being completely absent (for Garage 1.x). That module option previously `toString`'ed the value it's configured with, which is now no longer possible. Warn the user if they're still using a non-string here. --- nixos/modules/services/web-servers/garage.nix | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/web-servers/garage.nix b/nixos/modules/services/web-servers/garage.nix index f75829d64d67..d2a5109e266a 100644 --- a/nixos/modules/services/web-servers/garage.nix +++ b/nixos/modules/services/web-servers/garage.nix @@ -70,7 +70,11 @@ in # to garage 1.0.0 while relying on the module-level default, they would be left # with a config which evaluates and builds, but then garage refuses to start # because either replication_factor or replication_mode is required. - # This assertion can be removed in NixOS 24.11, when all users have been warned once. + # The replication_factor option also was `toString`'ed before, which is + # now not possible anymore, so we prompt the user to change it to a string + # if present. + # These assertions can be removed in NixOS 24.11, when all users have been + # warned once. { assertion = (cfg.settings ? replication_factor || cfg.settings ? replication_mode) || lib.versionOlder cfg.package "1.0.0"; message = '' @@ -80,6 +84,22 @@ in ''; } + { + assertion = lib.isString (cfg.settings.replication_mode or ""); + message = '' + The explicit `replication_mode` option in `services.garage.settings` + has been removed and is now handled by the freeform settings in order + to allow it being completely absent (for Garage 1.x). + That module option previously `toString`'ed the value it's configured + with, which is now no longer possible. + + You're still using a non-string here, please manually set it to + a string, or migrate to the separate setting keys introduced in 1.x. + + Refer to https://garagehq.deuxfleurs.fr/documentation/working-documents/migration-1/ + for the migration guide. + ''; + } ]; environment.etc."garage.toml" = { From ea6604c03a26ff35f1337797b721952d1990bbfc Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 15 May 2024 11:50:11 +0200 Subject: [PATCH 3/3] nixosTests.garage: migrate replicationMode to string Do the same config change steps the assertion asks users to. --- nixos/tests/garage/with-3node-replication.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nixos/tests/garage/with-3node-replication.nix b/nixos/tests/garage/with-3node-replication.nix index d4387b198d97..266a1082893f 100644 --- a/nixos/tests/garage/with-3node-replication.nix +++ b/nixos/tests/garage/with-3node-replication.nix @@ -7,10 +7,10 @@ args@{ mkNode, ver, ... }: }; nodes = { - node1 = mkNode { replicationMode = 3; publicV6Address = "fc00:1::1"; }; - node2 = mkNode { replicationMode = 3; publicV6Address = "fc00:1::2"; }; - node3 = mkNode { replicationMode = 3; publicV6Address = "fc00:1::3"; }; - node4 = mkNode { replicationMode = 3; publicV6Address = "fc00:1::4"; }; + node1 = mkNode { replicationMode = "3"; publicV6Address = "fc00:1::1"; }; + node2 = mkNode { replicationMode = "3"; publicV6Address = "fc00:1::2"; }; + node3 = mkNode { replicationMode = "3"; publicV6Address = "fc00:1::3"; }; + node4 = mkNode { replicationMode = "3"; publicV6Address = "fc00:1::4"; }; }; testScript = ''