Merge pull request #148061 from astro/drbd_upstream

drbd: update, fix, add test

authored by Ryan Mulligan and committed by GitHub 542e917e 4722a8e1

+257 -73
+5 -7
nixos/modules/services/network-filesystems/drbd.nix
··· 47 options drbd usermode_helper=/run/current-system/sw/bin/drbdadm 48 ''; 49 50 - environment.etc.drbd.conf = 51 { source = pkgs.writeText "drbd.conf" cfg.config; }; 52 53 systemd.services.drbd = { 54 after = [ "systemd-udev.settle.service" "network.target" ]; 55 wants = [ "systemd-udev.settle.service" ]; 56 wantedBy = [ "multi-user.target" ]; 57 - script = '' 58 - ${pkgs.drbd}/sbin/drbdadm up all 59 - ''; 60 - serviceConfig.ExecStop = '' 61 - ${pkgs.drbd}/sbin/drbdadm down all 62 - ''; 63 }; 64 }; 65 }
··· 47 options drbd usermode_helper=/run/current-system/sw/bin/drbdadm 48 ''; 49 50 + environment.etc."drbd.conf" = 51 { source = pkgs.writeText "drbd.conf" cfg.config; }; 52 53 systemd.services.drbd = { 54 after = [ "systemd-udev.settle.service" "network.target" ]; 55 wants = [ "systemd-udev.settle.service" ]; 56 wantedBy = [ "multi-user.target" ]; 57 + serviceConfig = { 58 + ExecStart = "${pkgs.drbd}/sbin/drbdadm up all"; 59 + ExecStop = "${pkgs.drbd}/sbin/drbdadm down all"; 60 + }; 61 }; 62 }; 63 }
+1
nixos/tests/all-tests.nix
··· 111 dokuwiki = handleTest ./dokuwiki.nix {}; 112 domination = handleTest ./domination.nix {}; 113 dovecot = handleTest ./dovecot.nix {}; 114 ec2-config = (handleTestOn ["x86_64-linux"] ./ec2.nix {}).boot-ec2-config or {}; 115 ec2-nixops = (handleTestOn ["x86_64-linux"] ./ec2.nix {}).boot-ec2-nixops or {}; 116 ecryptfs = handleTest ./ecryptfs.nix {};
··· 111 dokuwiki = handleTest ./dokuwiki.nix {}; 112 domination = handleTest ./domination.nix {}; 113 dovecot = handleTest ./dovecot.nix {}; 114 + drbd = handleTest ./drbd.nix {}; 115 ec2-config = (handleTestOn ["x86_64-linux"] ./ec2.nix {}).boot-ec2-config or {}; 116 ec2-nixops = (handleTestOn ["x86_64-linux"] ./ec2.nix {}).boot-ec2-nixops or {}; 117 ecryptfs = handleTest ./ecryptfs.nix {};
+87
nixos/tests/drbd.nix
···
··· 1 + import ./make-test-python.nix ( 2 + { pkgs, lib, ... }: 3 + let 4 + drbdPort = 7789; 5 + 6 + drbdConfig = 7 + { nodes, ... }: 8 + { 9 + virtualisation.emptyDiskImages = [ 1 ]; 10 + networking.firewall.allowedTCPPorts = [ drbdPort ]; 11 + 12 + services.drbd = { 13 + enable = true; 14 + config = '' 15 + global { 16 + usage-count yes; 17 + } 18 + 19 + common { 20 + net { 21 + protocol C; 22 + ping-int 1; 23 + } 24 + } 25 + 26 + resource r0 { 27 + volume 0 { 28 + device /dev/drbd0; 29 + disk /dev/vdb; 30 + meta-disk internal; 31 + } 32 + 33 + on drbd1 { 34 + address ${nodes.drbd1.config.networking.primaryIPAddress}:${toString drbdPort}; 35 + } 36 + 37 + on drbd2 { 38 + address ${nodes.drbd2.config.networking.primaryIPAddress}:${toString drbdPort}; 39 + } 40 + } 41 + ''; 42 + }; 43 + }; 44 + in 45 + { 46 + name = "drbd"; 47 + meta = with pkgs.lib.maintainers; { 48 + maintainers = [ ryantm astro ]; 49 + }; 50 + 51 + nodes.drbd1 = drbdConfig; 52 + nodes.drbd2 = drbdConfig; 53 + 54 + testScript = { nodes }: '' 55 + drbd1.start() 56 + drbd2.start() 57 + 58 + drbd1.wait_for_unit("network.target") 59 + drbd2.wait_for_unit("network.target") 60 + 61 + drbd1.succeed( 62 + "drbdadm create-md r0", 63 + "drbdadm up r0", 64 + "drbdadm primary r0 --force", 65 + ) 66 + 67 + drbd2.succeed("drbdadm create-md r0", "drbdadm up r0") 68 + 69 + drbd1.succeed( 70 + "mkfs.ext4 /dev/drbd0", 71 + "mkdir -p /mnt/drbd", 72 + "mount /dev/drbd0 /mnt/drbd", 73 + "touch /mnt/drbd/hello", 74 + "umount /mnt/drbd", 75 + "drbdadm secondary r0", 76 + ) 77 + drbd1.sleep(1) 78 + 79 + drbd2.succeed( 80 + "drbdadm primary r0", 81 + "mkdir -p /mnt/drbd", 82 + "mount /dev/drbd0 /mnt/drbd", 83 + "ls /mnt/drbd/hello", 84 + ) 85 + ''; 86 + } 87 + )
+106 -27
pkgs/os-specific/linux/drbd/default.nix
··· 1 - { lib, stdenv, fetchurl, flex, systemd, perl }: 2 3 stdenv.mkDerivation rec { 4 pname = "drbd"; 5 - version = "8.4.4"; 6 7 src = fetchurl { 8 - url = "http://oss.linbit.com/drbd/8.4/drbd-${version}.tar.gz"; 9 - sha256 = "1w4889h1ak7gy9w33kd4fgjlfpgmp6hzfya16p1pkc13bjf22mm0"; 10 }; 11 12 - patches = [ ./pass-force.patch ./fix-glibc-compilation.patch ]; 13 14 - nativeBuildInputs = [ flex ]; 15 - buildInputs = [ perl ]; 16 17 configureFlags = [ 18 - "--without-distro" 19 - "--without-pacemaker" 20 "--localstatedir=/var" 21 "--sysconfdir=/etc" 22 ]; 23 24 - preConfigure = 25 - '' 26 - export PATH=${systemd}/sbin:$PATH 27 - substituteInPlace user/Makefile.in \ 28 - --replace /sbin '$(sbindir)' 29 - substituteInPlace user/legacy/Makefile.in \ 30 - --replace '$(DESTDIR)/lib/drbd' '$(DESTDIR)$(LIBDIR)' 31 - substituteInPlace user/drbdadm_usage_cnt.c --replace /lib/drbd $out/lib/drbd 32 - substituteInPlace scripts/drbd.rules --replace /usr/sbin/drbdadm $out/sbin/drbdadm 33 - ''; 34 - 35 - makeFlags = [ "SHELL=${stdenv.shell}" ]; 36 37 installFlags = [ 38 - "localstatedir=$(TMPDIR)/var" 39 - "sysconfdir=$(out)/etc" 40 - "INITDIR=$(out)/etc/init.d" 41 ]; 42 43 meta = with lib; { 44 - homepage = "http://www.drbd.org/"; 45 - description = "Distributed Replicated Block Device, a distributed storage system for Linux"; 46 - license = licenses.gpl2; 47 platforms = platforms.linux; 48 }; 49 }
··· 1 + { lib 2 + , stdenv 3 + , docbook_xml_dtd_44 4 + , docbook_xml_dtd_45 5 + , docbook_xsl 6 + , asciidoctor 7 + , fetchurl 8 + , flex 9 + , kmod 10 + , libxslt 11 + , nixosTests 12 + , perl 13 + , systemd 14 + 15 + # drbd-utils are compiled twice, once with forOCF = true to extract 16 + # its OCF definitions for use in the ocf-resource-agents derivation, 17 + # then again with forOCF = false, where the ocf-resource-agents is 18 + # provided as the OCF_ROOT. 19 + , forOCF ? false 20 + , ocf-resource-agents 21 + }: 22 23 stdenv.mkDerivation rec { 24 pname = "drbd"; 25 + version = "9.19.1"; 26 27 src = fetchurl { 28 + url = "https://pkg.linbit.com/downloads/drbd/utils/${pname}-utils-${version}.tar.gz"; 29 + sha256 = "1l99kcrb0j85wxxmrdihpx9bk1a4sdi7wlp5m1x5l24k8ck1m5cf"; 30 }; 31 32 + nativeBuildInputs = [ 33 + flex 34 + libxslt 35 + docbook_xsl 36 + asciidoctor 37 + ]; 38 39 + buildInputs = [ 40 + perl 41 + # perlPackages.Po4a used by ja documentation 42 + ]; 43 44 configureFlags = [ 45 + "--libdir=${placeholder "out"}/lib" 46 + "--sbindir=${placeholder "out"}/bin" 47 "--localstatedir=/var" 48 "--sysconfdir=/etc" 49 + "--without-distro" 50 ]; 51 52 + makeFlags = [ 53 + "SOURCE_DATE_EPOCH=1" 54 + "WANT_DRBD_REPRODUCIBLE_BUILD=1" 55 + ] ++ lib.optional (!forOCF) "OCF_ROOT=${ocf-resource-agents}/usr/lib/ocf}"; 56 57 installFlags = [ 58 + "prefix=" 59 + "DESTDIR=${placeholder "out"}" 60 + "localstatedir=/var" 61 + "DRBD_LIB_DIR=/var/lib" 62 + "INITDIR=/etc/init.d" 63 + "udevrulesdir=/etc/udev/rules.d" 64 + "sysconfdir=/etc" 65 + "sbindir=/bin" 66 + "datadir=" 67 + "LIBDIR=/lib/drbd" 68 + "mandir=/share/man" 69 ]; 70 71 + postPatch = '' 72 + patchShebangs . 73 + substituteInPlace user/v84/drbdadm_usage_cnt.c \ 74 + --replace '"/lib/drbd");' \ 75 + '"${placeholder "out"}/lib/drbd");' 76 + substituteInPlace user/v9/drbdsetup_linux.c \ 77 + --replace 'ret = system("/sbin/modprobe drbd");' \ 78 + 'ret = system("${kmod}/bin/modprobe drbd");' 79 + substituteInPlace user/v84/drbdsetup.c \ 80 + --replace 'system("/sbin/modprobe drbd")' \ 81 + 'system("${kmod}/bin/modprobe drbd")' 82 + substituteInPlace documentation/ra2refentry.xsl \ 83 + --replace "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" \ 84 + "${docbook_xml_dtd_44}/xml/dtd/docbook/docbookx.dtd" 85 + function patch_docbook45() { 86 + substituteInPlace $1 \ 87 + --replace "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" \ 88 + "${docbook_xml_dtd_45}/xml/dtd/docbook/docbookx.dtd" 89 + } 90 + patch_docbook45 documentation/v9/drbd.conf.xml.in 91 + patch_docbook45 documentation/v9/drbdsetup.xml.in 92 + patch_docbook45 documentation/v84/drbdsetup.xml 93 + patch_docbook45 documentation/v84/drbd.conf.xml 94 + # The ja documentation is disabled because: 95 + # make[1]: Entering directory '/build/drbd-utils-9.16.0/documentation/ja/v84' 96 + # /nix/store/wyx2nn2pjcn50lc95c6qgsgm606rn0x2-perl5.32.1-po4a-0.62/bin/po4a-translate -f docbook -M utf-8 -L utf-8 -keep 0 -m ../../v84/drbdsetup.xml -p drbdsetup.xml.po -l drbdsetup.xml 97 + # Use of uninitialized value $args[1] in sprintf at /nix/store/wyx2nn2pjcn50lc95c6qgsgm606rn0x2-perl5.32.1-po4a-0.62/lib/perl5/site_perl/Locale/Po4a/Common.pm line 134. 98 + # Invalid po file drbdsetup.xml.po: 99 + substituteInPlace Makefile.in \ 100 + --replace 'DOC_DIRS := documentation/v9 documentation/ja/v9' \ 101 + 'DOC_DIRS := documentation/v9' \ 102 + --replace 'DOC_DIRS += documentation/v84 documentation/ja/v84' \ 103 + 'DOC_DIRS += documentation/v84' \ 104 + --replace '$(MAKE) -C documentation/ja/v9 doc' \ 105 + "" \ 106 + --replace '$(MAKE) -C documentation/ja/v84 doc' \ 107 + "" 108 + substituteInPlace user/v9/drbdtool_common.c \ 109 + --replace 'add_component_to_path("/lib/drbd");' \ 110 + 'add_component_to_path("${placeholder "out"}/lib/drbd");' 111 + ''; 112 + 113 + preConfigure = '' 114 + export PATH=${systemd}/sbin:$PATH 115 + ''; 116 + 117 + enableParallelBuilding = true; 118 + 119 + passthru.tests.drbd = nixosTests.drbd; 120 + 121 meta = with lib; { 122 + homepage = "https://linbit.com/drbd/"; 123 + description = "Distributed Replicated Block Device, a distributed storage system for Linux (userspace utilities)"; 124 + license = licenses.gpl2Plus; 125 platforms = platforms.linux; 126 + maintainers = with maintainers; [ ryantm astro ]; 127 }; 128 }
-24
pkgs/os-specific/linux/drbd/fix-glibc-compilation.patch
··· 1 - diff --git a/user/drbdadm_adjust.c b/user/drbdadm_adjust.c 2 - index cb23270..3a751ca 100644 3 - --- a/user/drbdadm_adjust.c 4 - +++ b/user/drbdadm_adjust.c 5 - @@ -29,6 +29,7 @@ 6 - #include <sys/types.h> 7 - #include <sys/stat.h> 8 - #include <sys/wait.h> 9 - +#include <sys/sysmacros.h> 10 - #include <unistd.h> 11 - #include <fcntl.h> 12 - 13 - diff --git a/user/legacy/drbdadm_adjust.c b/user/legacy/drbdadm_adjust.c 14 - index c79163c..6990ffb 100644 15 - --- a/user/legacy/drbdadm_adjust.c 16 - +++ b/user/legacy/drbdadm_adjust.c 17 - @@ -27,6 +27,7 @@ 18 - #include <sys/types.h> 19 - #include <sys/stat.h> 20 - #include <sys/wait.h> 21 - +#include <sys/sysmacros.h> 22 - #include <unistd.h> 23 - #include <fcntl.h> 24 -
···
-15
pkgs/os-specific/linux/drbd/pass-force.patch
··· 1 - Propagate the --force flag in the legacy drbdadm to drbdsetup. 2 - Otherwise "drbdadm primary --force" won't work as expected (the kernel 3 - will say "State change failed: Need access to UpToDate data"). 4 - 5 - diff -ru -x '*~' drbd-8.4.0-orig/user/legacy/drbdadm_main.c drbd-8.4.0/user/legacy/drbdadm_main.c 6 - --- drbd-8.4.0-orig/user/legacy/drbdadm_main.c 2011-07-07 06:55:39.000000000 -0400 7 - +++ drbd-8.4.0/user/legacy/drbdadm_main.c 2011-11-02 14:51:04.000000000 -0400 8 - @@ -1547,6 +1547,7 @@ 9 - for (i = 0; i < soi; i++) { 10 - argv[NA(argc)] = setup_opts[i]; 11 - } 12 - + if (force) argv[NA(argc)] = "--force"; 13 - argv[NA(argc)] = 0; 14 - 15 - setenv("DRBD_RESOURCE", res->name, 1);
···
+56
pkgs/os-specific/linux/ocf-resource-agents/default.nix
···
··· 1 + { stdenv 2 + , lib 3 + , runCommand 4 + , lndir 5 + , fetchFromGitHub 6 + , autoreconfHook 7 + , pkg-config 8 + , python3 9 + , glib 10 + , drbd 11 + }: 12 + 13 + let 14 + drbdForOCF = drbd.override { 15 + forOCF = true; 16 + }; 17 + 18 + resource-agentsForOCF = stdenv.mkDerivation rec { 19 + pname = "resource-agents"; 20 + version = "4.10.0"; 21 + 22 + src = fetchFromGitHub { 23 + owner = "ClusterLabs"; 24 + repo = pname; 25 + rev = "v${version}"; 26 + sha256 = "0haryi3yrszdfpqnkfnppxj1yiy6ipah6m80snvayc7v0ss0wnir"; 27 + }; 28 + 29 + nativeBuildInputs = [ 30 + autoreconfHook 31 + pkg-config 32 + ]; 33 + 34 + buildInputs = [ 35 + glib 36 + python3 37 + ]; 38 + 39 + meta = with lib; { 40 + homepage = "https://github.com/ClusterLabs/resource-agents"; 41 + description = "Combined repository of OCF agents from the RHCS and Linux-HA projects"; 42 + license = licenses.gpl2Plus; 43 + platforms = platforms.linux; 44 + maintainers = with maintainers; [ ryantm astro ]; 45 + }; 46 + }; 47 + 48 + in 49 + 50 + # This combines together OCF definitions from other derivations. 51 + # https://github.com/ClusterLabs/resource-agents/blob/master/doc/dev-guides/ra-dev-guide.asc 52 + runCommand "ocf-resource-agents" {} '' 53 + mkdir -p $out/usr/lib/ocf 54 + ${lndir}/bin/lndir -silent "${resource-agentsForOCF}/lib/ocf/" $out/usr/lib/ocf 55 + ${lndir}/bin/lndir -silent "${drbdForOCF}/usr/lib/ocf/" $out/usr/lib/ocf 56 + ''
+2
pkgs/top-level/all-packages.nix
··· 22387 22388 system76-firmware = callPackage ../os-specific/linux/firmware/system76-firmware { }; 22389 22390 open-vm-tools = callPackage ../applications/virtualization/open-vm-tools { }; 22391 open-vm-tools-headless = open-vm-tools.override { withX = false; }; 22392
··· 22387 22388 system76-firmware = callPackage ../os-specific/linux/firmware/system76-firmware { }; 22389 22390 + ocf-resource-agents = callPackage ../os-specific/linux/ocf-resource-agents { }; 22391 + 22392 open-vm-tools = callPackage ../applications/virtualization/open-vm-tools { }; 22393 open-vm-tools-headless = open-vm-tools.override { withX = false; }; 22394