Skip to content

tedge-mapper-c8y panics on startup if an invalid operations file exists #3234

@reubenmiller

Description

@reubenmiller

Describe the bug

thin-edge.io tedge-mapper-c8y panics on startup if there is an invalid toml file defined under the operations/c8y/ folder. If the invalid operations file is added whilst the tedge-mapper-c8y is running then an error is printed but the mapper keeps on functioning, but if the mapper is restarted, then it goes into an infinite start -> panic -> shutdown loop.

Below shows the panic during the tedge-mapper-c8y service startup:

Nov 07 13:58:18 tedge tedge-mapper[4922]: 2024-11-07T13:58:18.68308912Z  INFO C8Y-REST: start initialisation
Nov 07 13:58:18 tedge tedge-mapper[4922]: thread 'main' panicked at /home/runner/work/thin-edge.io/thin-edge.io/crates/core/tedge_actors/src/builders.rs:87:26:
Nov 07 13:58:18 tedge tedge-mapper[4922]: called `Result::unwrap()` on an `Err` value: ActorError(OperationsError(TomlError("/etc/tedge/operations/c8y/invalidfile", Error { inner: Error { inner: TomlError { message: "expected `.`, `=`", original: Some("sleep 10\n"), keys: [], span: Some(6..7) } } })))
Nov 07 13:58:18 tedge tedge-mapper[4922]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Nov 07 13:58:18 tedge tedge-mapper[4922]: 2024-11-07T13:58:18.683160412Z  INFO mqtt_channel::connection: MQTT connecting to broker: host=127.0.0.1:8883, session_name=None
Nov 07 13:58:18 tedge tedge-mapper[4922]: 2024-11-07T13:58:18.683445496Z  INFO mqtt_channel::connection: MQTT connecting to broker: host=127.0.0.1:8883, session_name=Some("tedge-mapper-c8y")
Nov 07 13:58:18 tedge tedge-mapper[4922]: 2024-11-07T13:58:18.683461704Z  INFO HTTP Server: Cumulocity proxy has HTTPS enabled (configured in `c8y.proxy.cert_path`/`c8y.proxy.key_path`) and certificate authentication enabled (2 certificates found) (configured in `c8y.proxy.ca_path`)
Nov 07 13:58:18 tedge tedge-mapper[4922]: 2024-11-07T13:58:18.683543954Z  INFO c8y_auth_proxy::server: Launching on port 8001 with HTTPS
Nov 07 13:58:18 tedge systemd[1]: tedge-mapper-c8y.service: Main process exited, code=exited, status=101/n/a
Nov 07 13:58:18 tedge systemd[1]: tedge-mapper-c8y.service: Failed with result 'exit-code'.

To Reproduce

Assuming you have a functional thin-edge.io installation connected to Cumulocity, then run:

  1. Create an invalid operations file (with invalid toml syntax)

    echo "sleep 10" > /etc/tedge/operations/c8y/invalidfile
  2. Restart the tedge-mapper-c8y

    systemctl restart tedge-mapper-c8y

    If the bug is present, then the tedge-mapper-c8y will continuously start then crash. You can monitor via journald:

    journalctl -fu tedge-mapper-c8y -n 20

Expected behavior

The tedge-mapper-c8y should be resistent to invalid user configuration and not crash/panic. Instead it should:

  • log a warning that an invalid operations file has been detected. The message should include the file path and the error
  • ignore the invalid operation file

Screenshots

Environment (please complete the following information):

Property Value
OS [incl. version] Debian GNU/Linux 12 (bookworm)
Hardware [incl. revision] unknown
System-Architecture Linux tedge 6.8.0-39-generic #39-Ubuntu SMP PREEMPT_DYNAMIC Sat Jul 6 02:50:39 UTC 2024 aarch64 GNU/Linux
thin-edge.io version tedge 1.3.1

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtheme:configurationTheme: Configuration management

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions