hydra-queue-runner: Get store mode configuration from hydra.conf

[?]
Feb 22, 2016, 4:23 PM
V2UCCYN3B6266BDKGSXQDRSW4HKY673GINM3VI3MORXZ7OYDJBXAC

Dependencies

  • [2] GJV2J5HX Pool local store connections
  • [3] K5G5GZY7 Guard against concurrent invocations of hydra-queue-runner
  • [4] SOB276BA Keep some statistics for the binary cache stores
  • [*] 24BMQDZA Start of single-process hydra-queue-runner
  • [*] 5AIYUMTB Basic remote building
  • [*] HJOEIMLR Refactor
  • [*] OG3Z3QGC Namespace cleanup

Change contents

  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 25
    [7.7840]
    [7.7840]
    /* Read hydra.conf. */
    auto hydraConfigFile = getEnv("HYDRA_CONFIG");
    if (pathExists(hydraConfigFile)) {
    for (auto line : tokenizeString<Strings>(readFile(hydraConfigFile), "\n")) {
    line = trim(string(line, 0, line.find('#')));
    auto eq = line.find('=');
    if (eq == std::string::npos) continue;
    auto key = trim(std::string(line, 0, eq));
    auto value = trim(std::string(line, eq + 1));
    if (key == "") continue;
  • edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 41
    [7.7841]
    [7.7841]
    hydraConfig[key] = value;
    }
    }
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 749
    [3.4400][3.4400:4619]()
    #if 0
    auto store = make_ref<LocalBinaryCacheStore>(getLocalStore(),
    "/home/eelco/Misc/Keys/test.nixos.org/secret",
    "/home/eelco/Misc/Keys/test.nixos.org/public",
    "/tmp/binary-cache");
    #endif
    [3.4400]
    [3.4619]
    auto storeMode = hydraConfig["store_mode"];
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 751
    [3.4620][3.4620:4675](),[3.4675][2.715:866](),[2.866][3.4853:4896](),[3.4853][3.4853:4896]()
    auto store = std::make_shared<S3BinaryCacheStore>(
    [this]() { return this->getLocalStore(); },
    "/home/eelco/hydra/secret",
    "/home/eelco/hydra/public",
    "nix-test-cache");
    store->init();
    _destStore = store;
    [3.4620]
    [3.643]
    if (storeMode == "direct" || storeMode == "") {
    _destStore = openStore();
    }
    else if (storeMode == "local-binary-cache") {
    auto dir = hydraConfig["binary_cache_dir"];
    if (dir == "")
    throw Error("you must set ‘binary_cache_dir’ in hydra.conf");
    auto store = make_ref<LocalBinaryCacheStore>(
    [this]() { return this->getLocalStore(); },
    "/home/eelco/Misc/Keys/test.nixos.org/secret",
    "/home/eelco/Misc/Keys/test.nixos.org/public",
    dir);
    store->init();
    _destStore = std::shared_ptr<LocalBinaryCacheStore>(store);
    }
    else if (storeMode == "s3-binary-cache") {
    auto bucketName = hydraConfig["binary_cache_s3_bucket"];
    if (bucketName == "")
    throw Error("you must set ‘binary_cache_s3_bucket’ in hydra.conf");
    auto store = make_ref<S3BinaryCacheStore>(
    [this]() { return this->getLocalStore(); },
    hydraConfig["binary_cache_secret_key_file"],
    hydraConfig["binary_cache_public_key_file"],
    bucketName);
    store->init();
    _destStore = std::shared_ptr<S3BinaryCacheStore>(store);
    }
  • edit in src/hydra-queue-runner/state.hh at line 264
    [9.437]
    [8.4416]
    std::map<std::string, std::string> hydraConfig;