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

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

Open
reubenmiller opened this issue Nov 7, 2024 · 0 comments
Labels
bug Something isn't working theme:configuration Theme: Configuration management

Comments

@reubenmiller
Copy link
Contributor

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

@reubenmiller reubenmiller added bug Something isn't working theme:configuration Theme: Configuration management labels Nov 7, 2024
@Bravo555 Bravo555 self-assigned this Nov 7, 2024
@Bravo555 Bravo555 removed their assignment Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working theme:configuration Theme: Configuration management
Projects
None yet
Development

No branches or pull requests

2 participants