Skip to content

Commit

Permalink
nixos/phoebus/alarm: don't set kafka address by default
Browse files Browse the repository at this point in the history
  • Loading branch information
minijackson committed Mar 8, 2024
1 parent 451f760 commit dcab862
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 80 deletions.
1 change: 0 additions & 1 deletion nixos/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
./modules/ca-gateway.nix
./modules/phoebus/alarm-logger.nix
./modules/phoebus/alarm-server.nix
./modules/phoebus/local-kafka.nix
./modules/phoebus/olog.nix
./modules/phoebus/save-and-restore.nix
]
32 changes: 2 additions & 30 deletions nixos/modules/phoebus/alarm-logger.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
lib,
pkgs,
...
} @ moduleAttrs: let
}: let
cfg = config.services.phoebus-alarm-logger;
settingsFormat = pkgs.formats.javaProperties {};
configFile = settingsFormat.generate "phoebus-alarm-logger.properties" cfg.settings;

localKafka = lib.hasPrefix "localhost:" cfg.settings."bootstrap.servers";
localElasticsearch = cfg.settings.es_host == "localhost";
in {
options.services.phoebus-alarm-logger = {
enable = lib.mkEnableOption ''
Expand Down Expand Up @@ -90,8 +87,6 @@ in {
"bootstrap.servers" = lib.mkOption {
description = "Location of the Kafka server";
type = lib.types.str;
default = "localhost:${toString config.services.apache-kafka.port}";
defaultText = lib.literalExpression ''"localhost:''${toString config.services.apache-kafka.port}"'';
};

date_span_units = lib.mkOption {
Expand Down Expand Up @@ -141,10 +136,6 @@ in {
description = "Phoebus Alarm Logger";

wantedBy = ["multi-user.target"];
after = lib.mkMerge [
(lib.mkIf localKafka ["apache-kafka.service"])
(lib.mkIf localElasticsearch ["elasticsearch.service"])
];

# Weirdly not "phoebus.user"
environment.JAVA_OPTS = "-Djava.util.prefs.userRoot=/var/lib/phoebus-alarm-logger";
Expand All @@ -162,29 +153,10 @@ in {
};
};

services.apache-kafka = lib.mkIf localKafka {
enable = true;
localSetup.enable = true;
};
# Port conflicts by default with phoebus-alarm-logger's port
services.zookeeper.extraConf = lib.mkIf localKafka ''
admin.enableServer=false
'';

services.elasticsearch = lib.mkIf localElasticsearch {
enable = true;
# Should be kept in sync with the phoebus-olog and phoebus-save-and-restore services
package = pkgs.elasticsearch7;
};

networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [
(lib.toInt cfg.settings."server.port")
];
};

meta = {
maintainers = with epnixLib.maintainers; [minijackson];
# TODO:
# doc = ./alarm-logger.md;
};
meta.maintainers = with epnixLib.maintainers; [minijackson];
}
23 changes: 2 additions & 21 deletions nixos/modules/phoebus/alarm-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
lib,
pkgs,
...
} @ moduleAttrs: let
}: let
cfg = config.services.phoebus-alarm-server;
settingsFormat = pkgs.formats.javaProperties {};
configFile = settingsFormat.generate "phoebus-alarm-server.properties" cfg.settings;

localKafka = lib.hasPrefix "localhost:" cfg.settings."org.phoebus.applications.alarm/server";
in {
options.services.phoebus-alarm-server = {
enable = lib.mkEnableOption ''
Expand All @@ -34,7 +32,6 @@ in {
Includes services:
- Apache Kafka (if configured locally)
- Phoebus Alarm Logger (if not disabled)
Warning: this opens the firewall on all network interfaces.
Expand Down Expand Up @@ -72,8 +69,6 @@ in {
"org.phoebus.applications.alarm/server" = lib.mkOption {
description = "Kafka server host:port";
type = lib.types.str;
default = "localhost:${toString config.services.apache-kafka.port}";
defaultText = lib.literalExpression ''"localhost:''${toString config.services.apache-kafka.port}"'';
};

# Waiting for: https://github.com/ControlSystemStudio/phoebus/issues/2843
Expand Down Expand Up @@ -168,7 +163,6 @@ in {
description = "Phoebus Alarm Server";

wantedBy = ["multi-user.target"];
after = lib.mkIf localKafka ["apache-kafka.service"];

environment.JAVA_OPTS = "-Dphoebus.user=/var/lib/phoebus-alarm-server";

Expand All @@ -191,20 +185,7 @@ in {
enable = lib.mkDefault true;
openFirewall = lib.mkIf cfg.openFirewall (lib.mkDefault true);
};

services.apache-kafka = lib.mkIf localKafka {
enable = true;
localSetup.enable = true;
};

networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [
config.services.apache-kafka.port
];
};

meta = {
maintainers = with epnixLib.maintainers; [minijackson];
# TODO:
# doc = ./alarm-server.md;
};
meta.maintainers = with epnixLib.maintainers; [minijackson];
}
28 changes: 0 additions & 28 deletions nixos/modules/phoebus/local-kafka.nix

This file was deleted.

0 comments on commit dcab862

Please sign in to comment.