eclipse-ankaios / ankaios

Eclipse Ankaios provides workload and container orchestration for automotive High Performance Computing (HPC) software.
https://eclipse-ankaios.github.io/ankaios/
Apache License 2.0
60 stars 22 forks source link

Set log level during Ankaios installation #163

Closed sboett-dev closed 7 months ago

sboett-dev commented 9 months ago

Description

Add the possibility to set the log level during the Ankaios installation. This could happen with parameters such as -v, -vv and -vvv or keywords like info, trace, warn, error and debug.

Ankaios is currently installed with the following command:

curl -sfL https://github.com/eclipse-ankaios/ankaios/releases/download/v0.2.0/install.sh | bash -s -- -v v0.2.0 -t both -a "--name agent_A --server-url http://{{ SERVER_IP_ADDR }}:25551/" -s "--startup-config /home/ubuntu/state.yaml --address 0.0.0.0:25551"

An Ankaios server systemd service file then looks like this:

[Unit]
Description=Ankaios server

[Service]
ExecStart=/usr/local/bin/ank-server --startup-config /home/ubuntu/state.yaml --address 0.0.0.0:25551

[Install]
WantedBy=default.target

The log level is set with the RUST_LOG environment variable and is per default RUST_LOG=info.

If the setting of environment variables might be necessary in the future of Ankaios, you could even let users define all kinds of variables environment variables (here for this enhancement just RUST_LOG=debug) during installation.

Goals

Ankaios could be installed with (-vvv)

curl -sfL https://github.com/eclipse-ankaios/ankaios/releases/download/v0.2.0/install.sh | bash -s -- -v v0.2.0 -t both -a "--name agent_A --server-url http://{{ SERVER_IP_ADDR }}:25551/ -vvv" -s "--startup-config /home/ubuntu/state.yaml -vvv" --address 0.0.0.0:25551

or (--loglevel debug)

curl -sfL https://github.com/eclipse-ankaios/ankaios/releases/download/v0.2.0/install.sh | bash -s -- -v v0.2.0 -t both -a "--name agent_A --server-url http://{{ SERVER_IP_ADDR }}:25551/ --loglevel debug" -s "--startup-config /home/ubuntu/state.yaml --loglevel debug" --address 0.0.0.0:25551

or (-e RUST_LOG=debug)

curl -sfL https://github.com/eclipse-ankaios/ankaios/releases/download/v0.2.0/install.sh | bash -s -- -v v0.2.0 -t both -a "--name agent_A --server-url http://{{ SERVER_IP_ADDR }}:25551/ -e RUST_LOG=debug" -s "--startup-config /home/ubuntu/state.yaml -e RUST_LOG=debug" --address 0.0.0.0:25551

Final result

The systemd service file would look like this:

[Unit]
Description=Ankaios server

[Service]
Environment="RUST_LOG=debug"
ExecStart=/usr/local/bin/ank-server --startup-config /home/ubuntu/state.yaml --address 0.0.0.0:25551

[Install]
WantedBy=default.target

Summary

We implemented the solution suggested in https://github.com/eclipse-ankaios/ankaios/issues/163#issuecomment-1903967502. Here we introduced the new environment variables INSTALL_ANK_SERVER_RUST_LOG and INSTALL_ANK_AGENT_RUST_LOG used to individually configure the log level of ank-server and ank-agent during installation.

Tasks

windsource commented 9 months ago

@sboett-dev thanks for the proposal. I think settings log levels for Ankaios during installation make sense but we should have the possibility to set them separately for server and agents. Maybe we can use environment variables which are then passed to the installation script like:

curl -sfL https://github.com/eclipse-ankaios/ankaios/releases/latest/download/install.sh | INSTALL_ANK_SERVER_RUST_LOG="debug" INSTALL_ANK_AGENT_RUST_LOG="warn" bash -

and then RUST_LOG can be written to the server and agent's systemd unit file accordingly.