diff options
author | Benjamin Staffin <ben@folsomlabs.com> | 2014-12-17 14:46:01 -0800 |
---|---|---|
committer | Benjamin Staffin <ben@folsomlabs.com> | 2014-12-18 14:47:24 -0800 |
commit | c47cefd05e8ed64b63e589eb8f572eb0a7a0e8f2 (patch) | |
tree | a4e67942adc8e0725a5f12f96e04f6c7988236f0 /nixos | |
parent | 718666204a10ae5f002598b13a487b2ca9eeefa4 (diff) | |
download | nixlib-c47cefd05e8ed64b63e589eb8f572eb0a7a0e8f2.tar nixlib-c47cefd05e8ed64b63e589eb8f572eb0a7a0e8f2.tar.gz nixlib-c47cefd05e8ed64b63e589eb8f572eb0a7a0e8f2.tar.bz2 nixlib-c47cefd05e8ed64b63e589eb8f572eb0a7a0e8f2.tar.lz nixlib-c47cefd05e8ed64b63e589eb8f572eb0a7a0e8f2.tar.xz nixlib-c47cefd05e8ed64b63e589eb8f572eb0a7a0e8f2.tar.zst nixlib-c47cefd05e8ed64b63e589eb8f572eb0a7a0e8f2.zip |
nixos/mesos: Parameterize mesos slave attributes
Added attributes to nixos/tests/mesos.nix to verify that mesos-slave attributes work. If the generated attributes are invalid, the daemon should fail to start. Change-Id: I5511245add30aba658b1af22cd7355b0bbf5d15c
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/misc/mesos-slave.nix | 57 | ||||
-rw-r--r-- | nixos/tests/mesos.nix | 4 |
2 files changed, 43 insertions, 18 deletions
diff --git a/nixos/modules/services/misc/mesos-slave.nix b/nixos/modules/services/misc/mesos-slave.nix index d89531f7e909..26fb3fdb00c9 100644 --- a/nixos/modules/services/misc/mesos-slave.nix +++ b/nixos/modules/services/misc/mesos-slave.nix @@ -5,6 +5,13 @@ with lib; let cfg = config.services.mesos.slave; + mkAttributes = + attrs: concatStringsSep ";" (mapAttrsToList + (k: v: "${k}:${v}") + (filterAttrs (k: v: v != null) attrs)); + attribsArg = optionalString (cfg.attributes != {}) + "--attributes=${mkAttributes cfg.attributes}"; + in { options.services.mesos = { @@ -31,9 +38,9 @@ in { }; withHadoop = mkOption { - description = "Add the HADOOP_HOME to the slave."; - default = false; - type = types.bool; + description = "Add the HADOOP_HOME to the slave."; + default = false; + type = types.bool; }; workDir = mkOption { @@ -44,10 +51,10 @@ in { extraCmdLineOptions = mkOption { description = '' - Extra command line options for Mesos Slave. + Extra command line options for Mesos Slave. - See https://mesos.apache.org/documentation/latest/configuration/ - ''; + See https://mesos.apache.org/documentation/latest/configuration/ + ''; default = [ "" ]; type = types.listOf types.string; example = [ "--gc_delay=3days" ]; @@ -62,6 +69,19 @@ in { type = types.str; }; + attributes = mkOption { + description = '' + Machine attributes for the slave instance. + + Use caution when changing this; you may need to manually reset slave + metadata before the slave can re-register. + ''; + default = {}; + type = types.attrsOf types.str; + example = { rack = "aa"; + host = "aabc123"; + os = "nixos"; }; + }; }; }; @@ -74,20 +94,21 @@ in { after = [ "network-interfaces.target" ]; environment.MESOS_CONTAINERIZERS = "docker,mesos"; serviceConfig = { - ExecStart = '' - ${pkgs.mesos}/bin/mesos-slave \ - --port=${toString cfg.port} \ - --master=${cfg.master} \ - ${optionalString cfg.withHadoop "--hadoop-home=${pkgs.hadoop}"} \ - --work_dir=${cfg.workDir} \ - --logging_level=${cfg.logLevel} \ - --docker=${pkgs.docker}/libexec/docker/docker \ - ${toString cfg.extraCmdLineOptions} - ''; - PermissionsStartOnly = true; + ExecStart = '' + ${pkgs.mesos}/bin/mesos-slave \ + --port=${toString cfg.port} \ + --master=${cfg.master} \ + ${optionalString cfg.withHadoop "--hadoop-home=${pkgs.hadoop}"} \ + ${attribsArg} \ + --work_dir=${cfg.workDir} \ + --logging_level=${cfg.logLevel} \ + --docker=${pkgs.docker}/libexec/docker/docker \ + ${toString cfg.extraCmdLineOptions} + ''; + PermissionsStartOnly = true; }; preStart = '' - mkdir -m 0700 -p ${cfg.workDir} + mkdir -m 0700 -p ${cfg.workDir} ''; }; }; diff --git a/nixos/tests/mesos.nix b/nixos/tests/mesos.nix index 4fc02d1cd3ff..040f613c5966 100644 --- a/nixos/tests/mesos.nix +++ b/nixos/tests/mesos.nix @@ -8,6 +8,10 @@ import ./make-test.nix { slave = { enable = true; master = "zk://localhost:2181/mesos"; + attributes = { + tag1 = "foo"; + tag2 = "bar"; + }; }; master = { enable = true; |