From 2a76f9c95795c27f53c1a26cd1167f5170718958 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 21 Oct 2015 23:07:13 +0200 Subject: [PATCH 1/6] tests/none: Properly propagate store dependencies. Because the coordinator machine needs to build the test machines, we need to make sure that every package that can't be built without networking is already available. So far, the test has used environment.systemPackages to add those references. However, using pkgs.stdenv won't export a single reference to the store path of stdenv, because it doesn't contain any paths that are in the default environment.pathsToLink. This usually shouldn't be a problem, because stdenv had a nix-support/propagated-user-env-packages file, which made sure that every package listed there was recursively added to the system path as well. Unfortunately, since NixOS/nixpkgs@328f7a6, stdenv doesn't contain propagatedUserEnvPkgs anymore, so these dependencies aren't available to the coordinator machine anymore. Either way, if any of the packages listed in environment.systemPackages do not contain paths that are not in environment.pathsToLink, we don't get any reference to the path and that in turn might lead to unexpected behaviour. One example I can think of is if /lib is removed from pathsToLink, which is already marked as "FIXME: remove" since NixOS/nixpkgs@e636e0a. Signed-off-by: aszlig --- tests/none-backend.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/none-backend.nix b/tests/none-backend.nix index 2de924d89..a81c33c51 100644 --- a/tests/none-backend.nix +++ b/tests/none-backend.nix @@ -80,9 +80,15 @@ makeTest { nodes = { coordinator = { config, pkgs, ... }: - { environment.systemPackages = - [ nixops pkgs.stdenv pkgs.vim pkgs.apacheHttpd pkgs.busybox - pkgs.module_init_tools pkgs.perlPackages.ArchiveCpio ]; + { environment.systemPackages = [ nixops ]; + # This is needed to make sure the coordinator can build the + # deployment without network availability. + environment.etc.nix-references.source = let + refs = [ + pkgs.stdenv pkgs.vim pkgs.apacheHttpd pkgs.busybox + pkgs.module_init_tools pkgs.perlPackages.ArchiveCpio + ]; + in pkgs.writeText "refs" (concatStringsSep "\n" refs); networking.firewall.enable = false; virtualisation.writableStore = true; }; From 92a1651b31e19ca89067edc8ff9b16074d3fde0e Mon Sep 17 00:00:00 2001 From: aszlig Date: Fri, 23 Oct 2015 01:38:04 +0200 Subject: [PATCH 2/6] tests/none: Fix configuration of load balancer. The default load balancing method has been split off into its own module since Apache 2.4, so we need to add that in the config to ensure proper start up of the web server. Here are the details about the module: https://httpd.apache.org/docs/2.4/mod/mod_lbmethod_byrequests.html Signed-off-by: aszlig --- tests/none-backend.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/none-backend.nix b/tests/none-backend.nix index a81c33c51..7f94552a5 100644 --- a/tests/none-backend.nix +++ b/tests/none-backend.nix @@ -45,7 +45,10 @@ let services.httpd.adminAddr = "e.dolstra@tudelft.nl"; ''} ${optionalString (n == 3) '' - services.httpd.extraModules = ["proxy_balancer"]; + services.httpd.extraModules = [ + "proxy_balancer" + "lbmethod_byrequests" + ]; services.httpd.extraConfig = " From a2691454ab8e584f9e8b6510d11978069d7ac572 Mon Sep 17 00:00:00 2001 From: aszlig Date: Fri, 23 Oct 2015 01:41:22 +0200 Subject: [PATCH 3/6] tests/none: Don't try to remount /nix/store. We have virtualisation.writableStore active for the targets that are not yet deployed by NixOps but not within the NixOps network specification. This has worked regardless in the past, because using a writable store was implemented solely using boot.initrd.postMountCommands, so switching to a new configuration didn't change anything and left the store untouched. But after NixOS/nixpkgs@e68b0c7, the mounts for the writable store are now using the fileSystems configuration attribute, which causes the mount points to be changed on switch. Another problem is that the mount units weren't escaped properly. But that isn't the problem here anymore (because we don't change the mounts between activation) and has been (or is going to be) dealt with in NixOS/nixpkgs#10546. Signed-off-by: aszlig --- tests/none-backend.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/none-backend.nix b/tests/none-backend.nix index 7f94552a5..8a683cc95 100644 --- a/tests/none-backend.nix +++ b/tests/none-backend.nix @@ -21,6 +21,7 @@ let boot.loader.grub.enable = false; # Should NixOps fill in extraHosts for the "none" backend? networking.extraHosts = "192.168.1.3 target2\n"; + virtualisation.writableStore = true; }; target2 = target1; From 356347f2e9ca251b272deee221d2f0bc6f028e0d Mon Sep 17 00:00:00 2001 From: aszlig Date: Fri, 23 Oct 2015 02:12:19 +0200 Subject: [PATCH 4/6] tests/none: Disable the firewall to physical.nix. Just an asthetics change, so we have defined it once rather than twice: Once for each logical specification. So we spare one line, yay! Signed-off-by: aszlig --- tests/none-backend.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/none-backend.nix b/tests/none-backend.nix index 8a683cc95..de88d0a8b 100644 --- a/tests/none-backend.nix +++ b/tests/none-backend.nix @@ -22,6 +22,7 @@ let # Should NixOps fill in extraHosts for the "none" backend? networking.extraHosts = "192.168.1.3 target2\n"; virtualisation.writableStore = true; + networking.firewall.enable = false; }; target2 = target1; @@ -36,7 +37,6 @@ let target1 = { config, pkgs, ... }: { services.openssh.enable = true; - networking.firewall.enable = false; users.extraUsers.root.openssh.authorizedKeys.keyFiles = [ ./id_test.pub ]; ${optionalString (n == 1) '' environment.systemPackages = [ pkgs.vim ]; @@ -65,7 +65,6 @@ let target2 = { config, pkgs, ... }: { services.openssh.enable = true; - networking.firewall.enable = false; users.extraUsers.root.openssh.authorizedKeys.keyFiles = [ ./id_test.pub ]; ${optionalString (n == 3) '' services.httpd.enable = true; From 6dcfb6e9f18131758853e00d427ec68bdb05fc8d Mon Sep 17 00:00:00 2001 From: aszlig Date: Fri, 23 Oct 2015 03:44:44 +0200 Subject: [PATCH 5/6] tests/none: Properly set IP addresses for eth1. This has never been done in this test but it's actually done in using assignIPAddresses. The reason this hasn't been failing was that the IP address reconfiguration wasn't done properly back then when this test was happily succeeding. The implementation in actually didn't stop the interface at all, which is why this passed unnoticed. Since then, we also have proper networking tests in , so we shouldn't assume a broken implementation in . However, the implementation is still a bit ugly, because we're now statically setting the IP address instead of reusing assignIPAddresses. We can't reuse the latter, because it requires us to insert a dummy node (coordinator), which we can't remove later on because the node name is referenced in the configuration via getAttrs on the node attribute. Signed-off-by: aszlig --- tests/none-backend.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/none-backend.nix b/tests/none-backend.nix index de88d0a8b..07a0475ca 100644 --- a/tests/none-backend.nix +++ b/tests/none-backend.nix @@ -38,6 +38,11 @@ let { config, pkgs, ... }: { services.openssh.enable = true; users.extraUsers.root.openssh.authorizedKeys.keyFiles = [ ./id_test.pub ]; + # Ugly again: Replicates assignIPAddresses from build-vms.nix. + networking.interfaces.eth1.ip4 = [ { + address = "192.168.1.2"; + prefixLength = 24; + } ]; ${optionalString (n == 1) '' environment.systemPackages = [ pkgs.vim ]; ''} @@ -66,6 +71,11 @@ let { config, pkgs, ... }: { services.openssh.enable = true; users.extraUsers.root.openssh.authorizedKeys.keyFiles = [ ./id_test.pub ]; + # Ugly again: Replicates assignIPAddresses from build-vms.nix. + networking.interfaces.eth1.ip4 = [ { + address = "192.168.1.3"; + prefixLength = 24; + } ]; ${optionalString (n == 3) '' services.httpd.enable = true; services.httpd.adminAddr = "e.dolstra@tudelft.nl"; From 425079caf0e9f43d9f0a95332fe56a39cc31173a Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 26 Oct 2015 11:53:31 +0100 Subject: [PATCH 6/6] tests/none: Switch to system.extraDependencies. Didn't notice that there is an option just for that, thanks to @edolstra for the heads-up in: https://github.com/NixOS/nixops/pull/350#discussion_r42978140 Signed-off-by: aszlig --- tests/none-backend.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/none-backend.nix b/tests/none-backend.nix index 07a0475ca..d6ab4b126 100644 --- a/tests/none-backend.nix +++ b/tests/none-backend.nix @@ -96,12 +96,10 @@ makeTest { { environment.systemPackages = [ nixops ]; # This is needed to make sure the coordinator can build the # deployment without network availability. - environment.etc.nix-references.source = let - refs = [ - pkgs.stdenv pkgs.vim pkgs.apacheHttpd pkgs.busybox - pkgs.module_init_tools pkgs.perlPackages.ArchiveCpio - ]; - in pkgs.writeText "refs" (concatStringsSep "\n" refs); + system.extraDependencies = [ + pkgs.stdenv pkgs.vim pkgs.apacheHttpd pkgs.busybox + pkgs.module_init_tools pkgs.perlPackages.ArchiveCpio + ]; networking.firewall.enable = false; virtualisation.writableStore = true; };