mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
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
This commit is contained in:
parent
718666204a
commit
c47cefd05e
2 changed files with 43 additions and 18 deletions
|
@ -5,6 +5,13 @@ with lib;
|
||||||
let
|
let
|
||||||
cfg = config.services.mesos.slave;
|
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 {
|
in {
|
||||||
|
|
||||||
options.services.mesos = {
|
options.services.mesos = {
|
||||||
|
@ -31,9 +38,9 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
withHadoop = mkOption {
|
withHadoop = mkOption {
|
||||||
description = "Add the HADOOP_HOME to the slave.";
|
description = "Add the HADOOP_HOME to the slave.";
|
||||||
default = false;
|
default = false;
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
workDir = mkOption {
|
workDir = mkOption {
|
||||||
|
@ -44,10 +51,10 @@ in {
|
||||||
|
|
||||||
extraCmdLineOptions = mkOption {
|
extraCmdLineOptions = mkOption {
|
||||||
description = ''
|
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 = [ "" ];
|
default = [ "" ];
|
||||||
type = types.listOf types.string;
|
type = types.listOf types.string;
|
||||||
example = [ "--gc_delay=3days" ];
|
example = [ "--gc_delay=3days" ];
|
||||||
|
@ -62,6 +69,19 @@ in {
|
||||||
type = types.str;
|
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" ];
|
after = [ "network-interfaces.target" ];
|
||||||
environment.MESOS_CONTAINERIZERS = "docker,mesos";
|
environment.MESOS_CONTAINERIZERS = "docker,mesos";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.mesos}/bin/mesos-slave \
|
${pkgs.mesos}/bin/mesos-slave \
|
||||||
--port=${toString cfg.port} \
|
--port=${toString cfg.port} \
|
||||||
--master=${cfg.master} \
|
--master=${cfg.master} \
|
||||||
${optionalString cfg.withHadoop "--hadoop-home=${pkgs.hadoop}"} \
|
${optionalString cfg.withHadoop "--hadoop-home=${pkgs.hadoop}"} \
|
||||||
--work_dir=${cfg.workDir} \
|
${attribsArg} \
|
||||||
--logging_level=${cfg.logLevel} \
|
--work_dir=${cfg.workDir} \
|
||||||
--docker=${pkgs.docker}/libexec/docker/docker \
|
--logging_level=${cfg.logLevel} \
|
||||||
${toString cfg.extraCmdLineOptions}
|
--docker=${pkgs.docker}/libexec/docker/docker \
|
||||||
'';
|
${toString cfg.extraCmdLineOptions}
|
||||||
PermissionsStartOnly = true;
|
'';
|
||||||
|
PermissionsStartOnly = true;
|
||||||
};
|
};
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -m 0700 -p ${cfg.workDir}
|
mkdir -m 0700 -p ${cfg.workDir}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,10 @@ import ./make-test.nix {
|
||||||
slave = {
|
slave = {
|
||||||
enable = true;
|
enable = true;
|
||||||
master = "zk://localhost:2181/mesos";
|
master = "zk://localhost:2181/mesos";
|
||||||
|
attributes = {
|
||||||
|
tag1 = "foo";
|
||||||
|
tag2 = "bar";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
master = {
|
master = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue