Skip to content

Commit a306ea1

Browse files
committed
Update qm /etc/agent/agent.conf that when the qm.service is started
This pull request will cause the /usr/lib/qm/rootfs/etc/hirte/agent.conf to be created on every qm.service start. This way if the admin changes the /etc/hirte/agent.conf on the host, the equivalent inside of the qm will match with the exception that the nodename is prefixed with qm. If the nodename in the hosts /etc/hirte/agent.conf is changed to foobar, then the qm's /etc/hirte/agent.conf will have the same settings except the node name will be qm.foobar. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
1 parent 753fb5c commit a306ea1

File tree

5 files changed

+57
-19
lines changed

5 files changed

+57
-19
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
The main purpose of this package is allow users to setup an environment which
44
prevents applications and container tools from interfering with other all
5-
other processes on the system.
5+
other processes on the system. For example ASIL (Automotive Safety Integrity Level)
6+
environments.
67

78
The QM environment uses containerization tools like cgoups, namespaces, and
89
security isolation to prevent accidental interference by processes in the qm.
@@ -31,3 +32,20 @@ each other.
3132

3233
For now all of the control processes in the qm other then containers will run
3334
with the same qm_t type.
35+
36+
* [Hirte](https://github.com/containers/qm/pull/57)
37+
38+
The package configures the hirte agent within the QM.
39+
40+
Hirte is a systemd service controller intended for multi-node environments with
41+
a predefined number of nodes and with a focus on highly regulated ecosystems such
42+
as those requiring functional safety. Potential use cases can be found in domains
43+
such as transportation, where services need to be controlled across different
44+
edge devices and where traditional orchestration tools are not compliant with
45+
regulatory requirements.
46+
47+
Systems with QM installed will have two systemd's running on them. The QM hirte-agent
48+
is based on the hosts /etc/hirte/agent.conf file. By default any changes to the
49+
systems agent.conf file are reflected into the QM /etc/hirte/agent.conf. You can
50+
further customize the QM hirte agent by adding content to the
51+
/usr/lib/qm/rootfs/etc/hirte/agent.conf.d/ directory.

qm.8.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,16 @@ applications within the QM. All applications within the QM environment are
115115
prevented from interfering with applications running outside of the QM
116116
environment.
117117

118+
## Configuring hirte agent in the QM
119+
120+
The configuration of the hosts /etc/hirte/agent.conf file is copied into the QM every time the
121+
qm.service is started, with the nodename of the hosts agent.conf modified by prepending `qm.`
122+
on the front of the nodename. If the hosts /etc/hirte/agent.conf does not exists, then the
123+
QM hirte agent will default to `qm.`$(hostname).
124+
125+
If you want permanently modify the hirte agent within the QM you can add config to
126+
/usr/lib/qm/rootfs/etc/hirte/agent.conf.d/ directory or modify the /etc/containers/systemd/qm.container
127+
quadlet file to not execute the hirte-agent setup script.
128+
118129
## SEE ALSO
119-
**[podman(1)](https://github.com/containers/podman/blob/main/docs/source/markdown/podman.1.md)**, **[quadlet(5)](https://github.com/containers/podman/blob/main/docs/source/markdown/podman-systemd.unit.5.md)**, systemctl(1), systemd(1), dnf(8)
130+
**[podman(1)](https://github.com/containers/podman/blob/main/docs/source/markdown/podman.1.md)**,**[quadlet(5)](https://github.com/containers/podman/blob/main/docs/source/markdown/podman-systemd.unit.5.md)**, systemctl(1), systemd(1), dnf(8), [hirte-agent(1)](https://github.com/containers/hirte/blob/main/doc/man/hirte-agent.1.md),[hirte-agent.conf.5](https://github.com/containers/hirte/blob/main/doc/man/hirte-agent.conf.5.md)

qm.container

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ MemorySwapMax=0
99
OOMScoreAdjust=500
1010
Restart=always
1111
Slice=QM.slice
12+
ExecPreStart=/usr/share/qm/setup hirte-agent
1213

1314
[Container]
1415
AddCapability=all

setup

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ replaceIDs() {
1616
grep -q "^$2:" $1 || echo $2:$3 >> $1
1717
}
1818

19+
AGENTCONF=/etc/hirte/agent.conf
1920
INSTALLDIR="$1"
2021
[ ! -z "${INSTALLDIR}" ] || INSTALLDIR=/usr/share/qm
2122

@@ -26,23 +27,22 @@ systemctl stop qm.service 2>/dev/null || true
2627

2728
hirteSetup() {
2829
rootfs=$1
29-
if test ! -f ${rootfs}/etc/hirte/agent.conf; then
30-
if test -f /etc/hirte/agent.conf; then
31-
sed -e 's,^NodeName=,NodeName=qm.,g' /etc/hirte/agent.conf > ${rootfs}/etc/hirte/agent.conf
30+
if test ! -f ${rootfs}${AGENTCONF}; then
31+
if test -f ${AGENTCONF}; then
32+
sed -e 's,^NodeName=,NodeName=qm.,g' ${AGENTCONF} > ${rootfs}${AGENTCONF}
3233
fi
3334
fi
3435
hostname=$(hostname)
35-
if test -f ${rootfs}/etc/hirte/agent.conf; then
36+
if test -f ${rootfs}${AGENTCONF}; then
3637
sed -e "s,^NodeName=qm.$,NodeName=qm.${hostname},g" \
3738
-e "s,^NodeName=$,NodeName=qm.${hostname},g" \
38-
-i ${rootfs}/etc/hirte/agent.conf
39+
-i ${rootfs}${AGENTCONF}
3940
else
40-
cat > ${rootfs}/etc/hirte/agent.conf <<EOF
41+
cat > ${rootfs}${AGENTCONF} <<EOF
4142
[hirte-agent]
4243
NodeName=qm.${hostname}
4344
EOF
4445
fi
45-
unshare --mount-proc -R /usr/lib/qm/rootfs -m systemctl enable hirte-agent.service
4646
}
4747

4848
storage() {
@@ -73,15 +73,23 @@ install() {
7373
replaceIDs ${rootfs}/etc/subuid containers ${qmContainerIDs}
7474
replaceIDs ${rootfs}/etc/subgid containers ${qmContainerIDs}
7575
hirteSetup ${rootfs}
76+
unshare --mount-proc -R /usr/lib/qm/rootfs -m systemctl enable hirte-agent.service
7677
storage ${rootfs}
7778
restorecon -R ${rootfs}
7879
}
7980

80-
install ${ROOTFS}
81-
replaceIDs /etc/subuid qmcontainers ${qmContainerIDs}
82-
replaceIDs /etc/subgid qmcontainers ${qmContainerIDs}
83-
replaceIDs /etc/subuid containers ${containerIDs}
84-
replaceIDs /etc/subgid containers ${containerIDs}
85-
86-
systemctl daemon-reload
87-
systemctl start qm.service
81+
case "$1" in
82+
hirte-agent)
83+
rm -f ${ROOTFS}${AGENTCONF}
84+
hirteSetup ${ROOTFS}
85+
;;
86+
*)
87+
install ${ROOTFS}
88+
replaceIDs /etc/subuid qmcontainers ${qmContainerIDs}
89+
replaceIDs /etc/subgid qmcontainers ${qmContainerIDs}
90+
replaceIDs /etc/subuid containers ${containerIDs}
91+
replaceIDs /etc/subgid containers ${containerIDs}
92+
systemctl daemon-reload
93+
systemctl start qm.service
94+
;;
95+
esac

tests/e2e/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ Just call `export VARNAME=foobar` before executing the script.
3636
| ----------- | ----------- |
3737
| NUMBER_OF_NODES | Increase the number of agent nodes. Useful for scale tests. |
3838
| NET_INTERFACE_IP_CONTROL | By default is eth0. Used to collect ip address of controller node |
39-
| TAG_CONTROL_MACHINE | The control machine tag. Default is contro:latest
39+
| TAG_CONTROL_MACHINE | The control machine tag. Default is control:latest
4040

4141
## Demo
42-
If your brower doesn't support asciinema, here the demo in text:
42+
If your browser doesn't support asciinema, here the demo in text:
4343
```
4444
[root@dell730 e2e]# #host
4545
[root@dell730 e2e]# cat /etc/fedora-release

0 commit comments

Comments
 (0)