Repository navigation
Add Phoebus alarm server (+ Kafka) and alarm logger (+ Elastic) roles - #101
ralphlange wants to merge 3 commits into
Conversation
|
@shroffk: Should I add the alarm logger to this role or make it a separate one? |
|
I would do it as a seperate role So basically we would just need a playbook with the appropriate vars |
|
But there is no separate role for the alarm logger in that repo. |
|
good point, I think we should split these roles |
0833e36 to
8ce86cb
Compare
8ce86cb to
1c21937
Compare
|
Redone / reorganized / extended:
|
|
@simon-ess: Are the molecule tests done in a reasonable way? |
jacomago
left a comment
There was a problem hiding this comment.
Other than my docker comments:
- Why are we adding the roles here instead of into the new galaxy namespace?
- If the roles are to be generic rather than just for the training vm, we should probably not default with localhost and separate ports.
| - name: Download Kafka {{ kafka_version }} | ||
| become: true | ||
| ansible.builtin.get_url: | ||
| url: "https://archive.apache.org/dist/kafka/{{ kafka_version }}/kafka_{{ kafka_scala_version }}-{{ kafka_version }}.tgz" |
There was a problem hiding this comment.
Do we really want to maintain a manual deployment of kafka vs using docker? This is significantly more complex.
There was a problem hiding this comment.
For the Training-VM I think the native install is the better choice overall, even though this role is longer than a docker run: one of the explicit goals of the Training-VM is to show installation from sources/downloads, avoiding docker.
For generic / real-world use, the best choice might be different.
(As the Galaxy roles are supposed to work in real-life and on the Training-VM, they need to clearly separate installation from configuration, giving at least from-source/system-packages/e3 as installation options while keeping the configuration parts common.)
| @@ -0,0 +1,25 @@ | |||
| # {{ ansible_managed }} | |||
| [Unit] | |||
| Description=Phoebus Alarm Server ({{ alarm_config_name }}) | |||
There was a problem hiding this comment.
I really am not a fan of maintaining all these systemd files etc over docker. I would rather start with as little to maintain as possible via docker and then move on to more optimized version with systemd sharing a jvm whatever thing.
There was a problem hiding this comment.
I see the point, but for the alarm server and logger in particular, containers would add work rather than remove it here:
- The phoebus role already builds both services from the same source tree and version as the client (Phoebus' Maven build includes services/). So client and services always match, and running them needs nothing beyond a JDK, which the VM already has.
- With containers, we'd have to either build our own images from that build or pull upstream images and keep their versions in step with the client. Both are more to maintain than the unit files.
- The unit files are short, run each service as its own system user, and give students the usual systemctl status / journalctl -u alarm-server to look at, which is also what they'll find at many facilities.
If we later want a shared-JVM or container setup for production use, that seems like a good fit for the ansible-phoebus / Galaxy roles, see my other comment.
Thanks a lot for the review!
ansible-phoebus currently has no alarm logger role (that's what started the split in this PR).
This is partly addressed in 83f980a. The alarm settings are no longer in group_vars/all.yml. The Kafka address the alarm server uses is derived from the kafka role's kafka_listen_host/kafka_port instead of a hard-coded localhost:9092. Binding to loopback is kept as the default on purpose: Kafka and Elasticsearch run without authentication on the Training-VM, so listening on all interfaces would be an unsafe default. Whoever needs a networked setup would set kafka_listen_host / elasticsearch_network_host explicitly. |
83f980a to
fc3bab2
Compare
Installs Apache Kafka (single node, KRaft mode, localhost only) and runs the Phoebus alarm server 9built by the phoebus role) as systemd services. The alarm server (Phoebus >= 6) creates and configures its Kafka topics; automatic topic creation in Kafka is disabled. - Apache Kafka (single node, KRaft mode, localhost only) as a systemd service, with its own kafka switch and tag; in_container role default - alarm_config_name / alarm_kafka_server are defaults of the phoebus_alarm role (Kafka address derived from the kafka role's settings) and of the phoebus role, which now sets the client alarm preferences - same names, so one setting in a setup file configures client and server - enabling phoebus_alarm also runs the phoebus role and installs graphics - /usr/local/bin/alarm-server wrapper for -import/-export, Kafka tools on PATH - after starting the services, wait for Kafka to accept connections and for the alarm server to create its configuration topic, then assert that both systemd services are still active/running - so CI catches an alarm server that starts but crashes (skipped in containers without systemd) - enabled in everything.yml and ci-phoebus-aa.yml A shared Molecule image definition (ansible/molecule/systemd/Dockerfile.j2) runs systemd as PID 1 in a privileged container sharing the host's cgroup namespace, so the roles run with in_container=false - exactly as on a VM. Kafka scenario (in the molecule workflow matrix, x86_64 and aarch64) that verifies the service runs as its own user, listens on loopback, has its tools on the PATH, and can create a topic and deal with messages. The tests are described in the scenario's README. Molecule converges load only the arch variables, as playbook.yml does; everything else comes from the roles' own defaults. Developed with the assistance of generative AI.
Elasticsearch (single node, localhost only, security disabled) as a systemd service - the storage of the Phoebus alarm logger. Follows the phoebus_services_elasticsearch role of ControlSystemStudio/ansible-phoebus: - one service root /opt/epics-tools/services/elasticsearch with release/ (incl. its config/), data/, logs/ and run/, all owned by the service account - elasticsearch.yml template and systemd unit (ES_HOME, DATA_DIR, LOG_DIR, PID_DIR, ES_JAVA_HOME, start limits); runs on the JDK of the java role - version 8.19 (8.x matches the Elasticsearch client of Phoebus 6), 512M heap In addition: the download is verified against Elastic's published sha512 (new arch.elasticsearch token for the archive name), a version change removes the old release first, and after starting, the role waits for a usable cluster - showing the service status, journal and log tail if Elasticsearch does not come up. Own elasticsearch switch and tag; in_container role default. Molecule scenario on the systemd platform (x86_64 and aarch64): service running as its own user, loopback-only listeners, cluster health, indexing and searching a document; described in the scenario's README. The converge loads only the arch variables, as playbook.yml does. Developed with the assistance of generative AI.
Runs the Phoebus alarm logger (built by the phoebus role) under systemd: it stores the alarm system's messages from Kafka in Elasticsearch and serves them to the Phoebus "Alarm Log" table through its REST API. Modelled on the alarm logger part of ControlSystemStudio/ansible-phoebus. - pulls in the elasticsearch and phoebus_alarm (alarm server, Kafka) roles; enabling it also runs the phoebus role and installs graphics - REST API on port 9000 (the Phoebus client default): alarm_logger_url, a default of this role and of the phoebus role; set as Java system property, since the logger rejects unknown CLI options - /usr/local/bin/alarm-logger wrapper - after starting, the role waits for the REST API to report Elasticsearch as connected and asserts the service is running - enabled in everything.yml and ci-phoebus-aa.yml (QEMU role tests) Molecule scenario on the systemd platform (x86_64 and aarch64) that builds Phoebus and tests the whole alarm system end to end: it imports an alarm configuration with a PV that never connects and follows the configuration and the resulting "Disconnected" alarm through Kafka and the alarm logger into Elasticsearch and back out of the REST API; described in the scenario's README. closes epics-training#101 Developed with the assistance of generative AI.
fc3bab2 to
84ae8c3
Compare
Adds the Phoebus alarm system to the Training-VM: the alarm server with Kafka, and the alarm logger with Elasticsearch.
Closes #100
New roles
All four run their service under systemd as its own system user, listen on localhost only, and end with a check that the service actually came up (skipped in containers).
kafka: Apache Kafka 4.3.2, single node in KRaft mode (no ZooKeeper). The download is checked against its SHA-512; automatic topic creation is off, as the Phoebus docs recommend. Has its own switch and tag.phoebus_alarm: the alarm server (alarm-server), pulls inkafka. It creates itsAccelerator,AcceleratorCommandandAcceleratorTalktopics at startup (Phoebus 6 always does;-create_topicsis gone)./usr/local/bin/alarm-serverwraps it for command-line use, e.g.-import/-exportof configurations.elasticsearch: Elasticsearch 8.19, single node, security disabled, followingphoebus_services_elasticsearchof ansible-phoebus (everything under/opt/epics-tools/services/elasticsearch). Stays on 8.x, because Phoebus 6 uses the Elasticsearch 8 Java client. Additionally, the download is checked against its SHA-512, a version change removes the old release, and a failed start prints the status, journal and log. Has its own switch and tag.phoebus_alarm_logger: the alarm logger (alarm-logger), pulls inelasticsearchandphoebus_alarm. Stores the alarm messages from Kafka in Elasticsearch and serves them to the Phoebus "Alarm Log" through its REST API on port 9000 (the client default). The final check waits until the REST API reports Elasticsearch as connected.The alarm server and logger are already built by the
phoebusrole (its Maven build includesservices/), so nothing new gets built.Molecule tests
Functional tests for the service roles on x86_64 and aarch64. A new shared platform image (
ansible/molecule/systemd/Dockerfile.j2) runs systemd as PID 1, so the roles run exactly as on a VM:kafka: produces and consumes a message.elasticsearch: indexes, searches and deletes a document.phoebus_alarm_logger: builds Phoebus and tests the alarm system end to end: imports a configuration with a PV that never connects and follows the configuration and the resulting "Disconnected" alarm through Kafka and the logger into Elasticsearch and back out of the REST API.Each scenario also checks service users and loopback-only listening, and passes the idempotence step. Details are in each scenario's
molecule/README.md.Other changes
playbook.yml: enablingphoebus_alarmorphoebus_alarm_loggeralso runs thephoebusrole and installs the graphical desktop.alarm_config_name(Accelerator),alarm_kafka_server(from thekafkarole,localhost:9092) andalarm_logger_url(http://localhost:9000). Thephoebusrole uses the same names for its client preferences, so one setting in e.g.vars/local.ymlconfigures client and services consistently.phoebusrole:preferences.inipoints the client at the alarm server and configuration, and the Alarm Log at the alarm logger.group_vars/all.yml, only thevars/arch(and where neededvars/os) files, asplaybook.ymldoes.arch.elasticsearchtoken invars/arch/*.yml; roles enabled ineverything.ymlandci-phoebus-aa.yml, listed inlocal.yml.sample, documented inroles/README.md; CI workflows trigger on and run the new roles.Notes
Acceleratortree starts empty (fill it with the Alarm Tree GUI oralarm-server -import).Testing
All CI checks pass: Molecule on x86_64 and aarch64; "Roles: Phoebus & AA" (with all role checks passing), "Roles: EPICS Modules", "Roles: oac-tree" and the VM image builds on Fedora, Ubuntu, Debian and Rocky (x86_64). Not tested: aarch64 in the QEMU role tests (manual-only); Molecule covers aarch64.
Developed with the assistance of generative AI.