hydra-module: Always GC to have at least 100 GiB available.

[?]
Jun 14, 2012, 8:57 AM
3FTM52B2FQBNZ4GANKVIFALA757VXJEP3K4QLVJYQSDWIK7IP5VAC

Dependencies

  • [2] QQU7AL7I hydra-module.nix: Remove `.pl' extension for binaries.
  • [3] XYZ6FQ7Z hydra-module: Fix typo in the job name in `checkSpace'.
  • [4] CTYUTPED hydra-module: Remove `nix.*' settings.
  • [5] WXW2GAJY _ -> -
  • [6] D3MDJONY

Change contents

  • replacement in hydra-module.nix at line 144
    [4.3014][4.3014:3233]()
    nix.gc.automatic = true;
    # $3 / $4 don't always work depending on length of device name
    nix.gc.options = ''--max-freed "$((200 * 1024**3 - 1024 * $(df /nix/store | tail -n 1 | awk '{ print $3 }')))"'';
    [4.2953]
    [4.3233]
    # We have our own crontab entries for GC, see below.
    nix.gc.automatic = false;
  • replacement in hydra-module.nix at line 202
    [4.5127][4.5127:5496](),[4.5496][3.0:40](),[3.40][4.5536:5704](),[4.5536][4.5536:5704](),[4.5704][3.41:78](),[3.78][4.5741:6171](),[4.5741][4.5741:6171](),[4.6171][2.519:641](),[2.641][4.6296:6304](),[4.656][4.6296:6304](),[4.6296][4.6296:6304]()
    let
    # If there is less than ... GiB of free disk space, stop the queue
    # to prevent builds from failing or aborting.
    checkSpace = pkgs.writeScript "hydra-check-space"
    ''
    #! /bin/sh
    if [ $(($(stat -f -c '%a' /nix/store) * $(stat -f -c '%S' /nix/store))) -lt $((${toString cfg.minimumDiskFree} * 1024**3)) ]; then
    stop hydra_queue_runner
    fi
    if [ $(($(stat -f -c '%a' /nix/store) * $(stat -f -c '%S' /nix/store))) -lt $((${toString cfg.minimumDiskFreeEvaluator} * 1024**3)) ]; then
    stop hydra_evaluator
    fi
    '';
    compressLogs = pkgs.writeScript "compress-logs" ''
    #! /bin/sh -e
    touch -d 'last month' r
    find /nix/var/log/nix/drvs -type f -a ! -newer r -name '*.drv' | xargs bzip2 -v
    '';
    in
    [ "*/5 * * * * root ${checkSpace} &> ${cfg.baseDir}/data/checkspace.log"
    "15 5 * * * root ${compressLogs} &> ${cfg.baseDir}/data/compress.log"
    "15 02 * * * ${cfg.user} ${env} ${cfg.hydra}/bin/hydra-update-gc-roots &> ${cfg.baseDir}/data/gc-roots.log"
    ];
    [4.5127]
    [4.6304]
    let
    # If there is less than ... GiB of free disk space, stop the queue
    # to prevent builds from failing or aborting.
    checkSpace = pkgs.writeScript "hydra-check-space"
    ''
    #! /bin/sh
    if [ $(($(stat -f -c '%a' /nix/store) * $(stat -f -c '%S' /nix/store))) -lt $((${toString cfg.minimumDiskFree} * 1024**3)) ]; then
    stop hydra_queue_runner
    fi
    if [ $(($(stat -f -c '%a' /nix/store) * $(stat -f -c '%S' /nix/store))) -lt $((${toString cfg.minimumDiskFreeEvaluator} * 1024**3)) ]; then
    stop hydra_evaluator
    fi
    '';
  • replacement in hydra-module.nix at line 216
    [4.6305][4.6305:6314]()
    };
    }
    [4.6305]
    [4.6314]
    collect = pkgs.writeScript "collect-some-garbage"
    # Arrange to always have at least 100 GiB free.
    '' #!/bin/sh -e
    available="$(df -B1 /nix/store | tail -n 1 | awk '{ print $4 }')"
    target="$((100 * 1024**3))"
    to_free="$(($available > $target ? 200 * 1024**2 : $target - $available))"
    echo "$available B available, and targeting $target B available"
    echo "thus, freeing $to_free B"
    exec "${pkgs.nix}/bin/nix-collect-garbage" --max-freed "$to_free"
    '';
    compressLogs = pkgs.writeScript "compress-logs" ''
    #! /bin/sh -e
    touch -d 'last month' r
    find /nix/var/log/nix/drvs -type f -a ! -newer r -name '*.drv' | xargs bzip2 -v
    '';
    in
    [ "15 03 * * * root ${collect} &> ${cfg.baseDir}/data/gc.log"
    "15 13 * * * root ${collect} &> ${cfg.baseDir}/data/gc.log"
  • edit in hydra-module.nix at line 237
    [4.6315]
    "*/5 * * * * root ${checkSpace} &> ${cfg.baseDir}/data/checkspace.log"
    "15 5 * * * root ${compressLogs} &> ${cfg.baseDir}/data/compress.log"
    "15 02 * * * ${cfg.user} ${env} ${cfg.hydra}/bin/hydra-update-gc-roots &> ${cfg.baseDir}/data/gc-roots.log"
    ];
    };
    }