Compare commits
24 commits
3602c50ae0
...
4f935baa37
Author | SHA1 | Date | |
---|---|---|---|
4f935baa37 | |||
3fc6f6e95c | |||
746a5b73dc | |||
e081f62022 | |||
c868f710f6 | |||
a6615b60ba | |||
812cbe111b | |||
85a76193d8 | |||
e86d51437e | |||
e546191f3f | |||
967c31fe42 | |||
2d371d3815 | |||
c74939424e | |||
ee161721ca | |||
45f78f8cf1 | |||
a175d32b27 | |||
fa2ed3df7b | |||
32475201c8 | |||
dc12fa8d8f | |||
6623300408 | |||
0a4ad3c94d | |||
233c92d62e | |||
340383f160 | |||
76f08600af |
1 changed files with 5 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
{ cluster, config, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) concatStringsSep escapeShellArg flatten filter filterAttrs length mapAttrs mapAttrs' mapAttrsToList mkIf mkMerge pipe stringToCharacters;
|
||||
inherit (lib) concatStringsSep escapeShellArg flatten filter filterAttrs length mapAttrs mapAttrs' mapAttrsToList mkIf mkMerge optionalString pipe stringToCharacters;
|
||||
|
||||
cfg = config.services.incandescence;
|
||||
clusterCfg = cluster.config.incandescence;
|
||||
|
@ -70,8 +70,7 @@ in
|
|||
description = "Ignite Destruction: ${provider} - ${formula}";
|
||||
wantedBy = [ "incandescence-${provider}.target" ] ++ map (dep: "ignite-${provider}-${dep}-destroy.service") formulaConfig.deps;
|
||||
before = [ "incandescence-${provider}.target" ] ++ map (dep: "ignite-${provider}-${dep}-destroy.service") formulaConfig.deps;
|
||||
wants = providerConfig.wants ++ [ "ignite-${provider}-${formula}-change.service" ];
|
||||
after = providerConfig.after ++ [ "ignite-${provider}-${formula}-change.service" ];
|
||||
inherit (providerConfig) wants after;
|
||||
serviceConfig.Type = "oneshot";
|
||||
distributed.enable = true;
|
||||
path = [ config.services.consul.package ] ++ providerConfig.packages;
|
||||
|
@ -83,13 +82,15 @@ in
|
|||
(builtins.add 2)
|
||||
toString
|
||||
];
|
||||
needsFilter = clusterCfg.providers.${provider}.objects.${formula} != [];
|
||||
keyFilter = pipe clusterCfg.providers.${provider}.objects.${formula} [
|
||||
(map (x: escapeShellArg "^${x}$"))
|
||||
(concatStringsSep " \\\n -e ")
|
||||
];
|
||||
destroyAfterDays = toString formulaConfig.destroyAfterDays;
|
||||
grep = optionalString needsFilter "grep -v -e ${keyFilter} |";
|
||||
in ''
|
||||
consul kv get --keys ${kvRoot}/ | cut -d/ -f${fieldNum} | grep -v -e ${keyFilter} | while read object; do
|
||||
consul kv get --keys ${kvRoot}/ | cut -d/ -f${fieldNum} | ${grep} while read object; do
|
||||
if consul kv get ${kvRoot}/$object/alive >/dev/null; then
|
||||
destroyOn="$(consul kv get ${kvRoot}/$object/destroyOn || true)"
|
||||
if [[ -z "$destroyOn" && "${destroyAfterDays}" -ne 0 ]]; then
|
||||
|
|
Loading…
Add table
Reference in a new issue