Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose salt event publisher for Saline #9380

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions containers/server-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ RUN chmod a+x /usr/bin/healthcheck.sh
# Copy timezone link update service
COPY timezone_alignment.service /usr/lib/systemd/system/

# Copy Salt Event Publisher service used by Saline
COPY salt-event-publisher.service /usr/lib/systemd/system/

COPY remove_unused.sh .
RUN echo "rpm.install.excludedocs = yes" >>/etc/zypp/zypp.conf

Expand Down Expand Up @@ -69,7 +72,8 @@ RUN zypper --gpg-auto-import-keys --non-interactive install --auto-agree-with-li
sssd-ad \
sssd-ipa \
sssd-krb5 \
sssd-tools
sssd-tools \
socat

RUN sed -i 's/sysctl kernel.shmmax/#sysctl kernel.shmmax/g' /usr/bin/uyuni-setup-reportdb

Expand Down Expand Up @@ -104,7 +108,8 @@ RUN echo "cat /etc/motd" >/etc/sh.shrc.local
RUN systemctl enable prometheus-node_exporter; \
systemctl enable uyuni-setup; \
systemctl enable timezone_alignment; \
systemctl enable sssd;
systemctl enable sssd; \
systemctl enable salt-event-publisher;

# Provide tool to synchronize package and configuration files to persistent volumes
COPY uyuni-configfiles-sync /usr/bin
Expand Down
19 changes: 19 additions & 0 deletions containers/server-image/salt-event-publisher.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=Salt Event Publisher
After=network.target salt-master.service
Requires=salt-master.service

[Service]
Type=simple
User=salt
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=salt-event-publisher
ExecStartPre=/bin/bash -c 'until [ -S /run/salt/master/master_event_pub.ipc ]; do sleep 1; done'
ExecStart=/usr/bin/socat TCP4-LISTEN:4512,reuseaddr,fork UNIX-CONNECT:/run/salt/master/master_event_pub.ipc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to expose one more port with this? I'm assuming not, since this port should be for consumption inside the uyuni network and not exposed to the outside world.
Do you think we need to have some kind of authentication mechanism for it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically boils down to sharing the IPC namespace between the saline container and the server one. Did you try https://docs.podman.io/en/latest/markdown/podman-run.1.html#sharing-ipc-between-containers ? In any case this should probably not be the default and only added if saline is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjmateus this port is not intended to be exposed outside, but required just for saline container to connect and it's working in one direction only, but exposes the unencrypted data. Do we need to protect it somehow if we are not going to expose it except to the other containers on the server? In case of detaching salt-master and salt-api we should expose couple more ports the same way to make it possible for salt-api to communicate to salt-master.

@cbosdo feel bit stupid but I didn't get how it could be applicable here, the section you send the link to is describing interprocess communication with shared memory, but in this case it's just a socket. There is a way to enable tcp transport there in the master config, but it's using hardcoded 127.0.0.1 and can't be exposed that way. If I understood the idea wrong, could you please point me to more clear example of using such approach?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbosdo feel bit stupid but I didn't get how it could be applicable here, the section you send the link to is describing interprocess communication with shared memory, but in this case it's just a socket. There is a way to enable tcp transport there in the master config, but it's using hardcoded 127.0.0.1 and can't be exposed that way. If I understood the idea wrong, could you please point me to more clear example of using such approach?

IIRC Unix sockets are also parts of the IPCs and thus sharing the IPC namespace between saline container and the container running salt could do the trick.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a type of IPC, but not using shared memory, basically it's a file and what I found before that in some cases it's shared as a file volume, I've read the section by the link you pointed, but still didn't get the idea how to make it working. And I can't find any example for such use case.

Restart=always
SuccessExitStatus=0 143
RestartForceExitStatus=143

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Expose salt event bus with salt-event-publisher.service
Loading