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

feat: enable mosquitto persistence by default #3232

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/core/tedge/src/bridge/common_mosquitto_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ impl Default for CommonMosquittoConfig {

impl CommonMosquittoConfig {
pub fn serialize<W: std::io::Write>(&self, writer: &mut W) -> std::io::Result<()> {
// Enable persistence as thin-edge.io heavily relies on retained messages and
// if mosquitto persistence is not configured, then it can lead to unexpected behavior
writeln!(writer, "persistence true")?;
Comment on lines +113 to +115
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beware that the file /etc/tedge/mosquitto-conf/tedge-mosquitto.conf is populated only if there is at least one cloud connected.

I would consider to improve the tedge refresh-bridges command to populate this file even if there is no bridge configured. I.e. moving these 2 lines before that one


writeln!(writer, "per_listener_settings true")?;

writeln!(writer, "connection_messages true")?;
Expand Down Expand Up @@ -237,6 +241,7 @@ mod tests {
.collect();
let mut expected = std::collections::HashSet::new();

expected.insert("persistence true");
expected.insert("listener 1883 127.0.0.1");
expected.insert("allow_anonymous true");
expected.insert("connection_messages true");
Expand Down Expand Up @@ -280,6 +285,7 @@ mod tests {

let contents = String::from_utf8(buffer).unwrap();
let expected = concat!(
"persistence true\n",
"per_listener_settings true\n",
"connection_messages true\n",
"log_type error\n",
Expand Down