Bug 56131 - Appcenter should set labels when starting Docker container
Appcenter should set labels when starting Docker container
Status: NEW
Product: UCS
Classification: Unclassified
Component: App Center
UCS 5.2
Other Linux
: P5 normal (vote)
: UCS 5.2
Assigned To: App Center maintainers
App Center maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2023-06-09 08:24 CEST by Daniel Tröder
Modified: 2024-03-28 09:08 CET (History)
0 users

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2023-06-09 08:24:13 CEST
If the Appcenter would set labels when starting a Docker apps Docker container, those labels can be used by the logging driver.
The values can be added to the log entries and can later be used for log routing.

I suggest to set the following labels:

* APP_NAME: the app_id of the app for which the container is being started. For docker-compose apps that label would be the same for all containers.
* APP_VERSION: The apps version string.
* UCS: The UCS version as printed by "univention-app info".

The UCS version should be stripped from the apps name. E.g. instead of "4.4/ucsschool-kelvin-rest-api" it should be only "ucsschool-kelvin-rest-api". That will make matching in long-term log-storage easier.

Example 'docker create' call:

docker create --label APP_NAME="ucsschool-kelvin-rest-api" --label APP_VERSION=1.8.8 --label UCS="5.0-3 errata677" ...

With a proper Docker logging driver configuration, those labels can be used to search in logs. See Bug #56130.
Comment 1 Daniel Tröder univentionstaff 2023-06-09 08:39:58 CEST
The "univention-fluentbit" package has been adapted, so it can receive Docker logs directly from the Docker daemon and route them to separate log files per app: https://git.knut.univention.de/univention/internal/hackathon/univention-fluent-bit/-/commit/ff39d66d11d98b22415e64a9f91d3b582ebbfbf9

The routing depends on the app_id being stored in the log records.
Comment 2 Daniel Tröder univentionstaff 2023-06-09 08:43:15 CEST
root@ucs:~# ucr set docker/daemon/default/opts/log-driver=journald

root@ucs:~# docker run -it --rm --label APP_NAME="TheAppId" --label APP_VERSION=1.23 -e DOCKER_HOST_NAME=$(hostname -f) alpine ping -c 3 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.078 ms
64 bytes from 127.0.0.1: seq=1 ttl=64 time=0.105 ms
64 bytes from 127.0.0.1: seq=2 ttl=64 time=0.121 ms

--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.078/0.101/0.121 ms

# Use "--all" to make journals convert byte arrays to strings.

root@ucs:~# journalctl APP_NAME="TheAppId" --all
-- Logs begin at Thu 2023-06-08 09:24:53 CEST, end at Fri 2023-06-09 08:41:26 CEST. --
Jun 09 08:41:21 ucs alpine/vigorous_bassi/a5a3b6206595[1794]: PING 127.0.0.1 (127.0.0.1): 56 data bytes
Jun 09 08:41:21 ucs alpine/vigorous_bassi/a5a3b6206595[1794]: 64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.078 ms
Jun 09 08:41:22 ucs alpine/vigorous_bassi/a5a3b6206595[1794]: 64 bytes from 127.0.0.1: seq=1 ttl=64 time=0.105 ms
Jun 09 08:41:23 ucs alpine/vigorous_bassi/a5a3b6206595[1794]: 64 bytes from 127.0.0.1: seq=2 ttl=64 time=0.121 ms
Jun 09 08:41:23 ucs alpine/vigorous_bassi/a5a3b6206595[1794]: 
Jun 09 08:41:23 ucs alpine/vigorous_bassi/a5a3b6206595[1794]: --- 127.0.0.1 ping statistics ---
Jun 09 08:41:23 ucs alpine/vigorous_bassi/a5a3b6206595[1794]: 3 packets transmitted, 3 packets received, 0% packet loss
Jun 09 08:41:23 ucs alpine/vigorous_bassi/a5a3b6206595[1794]: round-trip min/avg/max = 0.078/0.101/0.121 ms
Comment 4 Daniel Tröder univentionstaff 2024-03-28 09:08:19 CET
IMHO, this should be implemented for the 5.2-0 release, because the change requires a "reinitialize" of Docker Apps to take effect. Something we cannot do in an errata release.