Skip to content

Commit 5c259d5

Browse files
Merge pull request #3762 from albinsuresh/feat/extensible-config-management
feat: extensible log management
2 parents 9fbca1c + 6425dcf commit 5c259d5

File tree

37 files changed

+1857
-266
lines changed

37 files changed

+1857
-266
lines changed

Cargo.lock

Lines changed: 28 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"plugins/c8y_firmware_plugin",
88
"plugins/c8y_remote_access_plugin",
99
"plugins/tedge_apt_plugin",
10+
"plugins/tedge_file_log_plugin",
1011
]
1112
resolver = "2"
1213

@@ -43,6 +44,7 @@ mqtt_tests = { path = "crates/tests/mqtt_tests" }
4344
plugin_sm = { path = "crates/core/plugin_sm" }
4445
tedge-agent = { path = "crates/core/tedge_agent" }
4546
tedge-apt-plugin = { path = "plugins/tedge_apt_plugin" }
47+
tedge-file-log-plugin = { path = "plugins/tedge_file_log_plugin" }
4648
tedge-mapper = { path = "crates/core/tedge_mapper", default-features = false }
4749
tedge-p11-server = { path = "crates/extensions/tedge-p11-server" }
4850
tedge-watchdog = { path = "crates/core/tedge_watchdog" }

configuration/package_scripts/_generated/tedge/apk/preinst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fi
5656
if [ -d /etc/sudoers.d ]; then
5757
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/bin/tedge, /etc/tedge/sm-plugins/[a-zA-Z0-9]*, /bin/sync, /sbin/init" > /etc/sudoers.d/tedge
5858
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/bin/tedge-write /etc/*" >> /etc/sudoers.d/tedge
59+
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/share/tedge/log-plugins/[a-zA-Z0-9]*" >> /etc/sudoers.d/tedge
5960
fi
6061

6162

configuration/package_scripts/_generated/tedge/deb/preinst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fi
5656
if [ -d /etc/sudoers.d ]; then
5757
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/bin/tedge, /etc/tedge/sm-plugins/[a-zA-Z0-9]*, /bin/sync, /sbin/init" > /etc/sudoers.d/tedge
5858
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/bin/tedge-write /etc/*" >> /etc/sudoers.d/tedge
59+
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/share/tedge/log-plugins/[a-zA-Z0-9]*" >> /etc/sudoers.d/tedge
5960
fi
6061

6162

configuration/package_scripts/_generated/tedge/rpm/preinst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fi
5656
if [ -d /etc/sudoers.d ]; then
5757
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/bin/tedge, /etc/tedge/sm-plugins/[a-zA-Z0-9]*, /bin/sync, /sbin/init" > /etc/sudoers.d/tedge
5858
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/bin/tedge-write /etc/*" >> /etc/sudoers.d/tedge
59+
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/share/tedge/log-plugins/[a-zA-Z0-9]*" >> /etc/sudoers.d/tedge
5960
fi
6061

6162

configuration/package_scripts/tedge/preinst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fi
5656
if [ -d /etc/sudoers.d ]; then
5757
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/bin/tedge, /etc/tedge/sm-plugins/[a-zA-Z0-9]*, /bin/sync, /sbin/init" > /etc/sudoers.d/tedge
5858
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/bin/tedge-write /etc/*" >> /etc/sudoers.d/tedge
59+
echo "tedge ALL = (ALL) NOPASSWD:SETENV: /usr/share/tedge/log-plugins/[a-zA-Z0-9]*" >> /etc/sudoers.d/tedge
5960
fi
6061

6162

crates/common/tedge_config/src/tedge_toml/tedge_config.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,13 @@ define_tedge_config! {
936936
/// The directories where diagnostic plugins are stored
937937
#[tedge_config(example = "/usr/share/diag-plugins,/etc/tedge/diag-plugins", default(value = "/usr/share/tedge/diag-plugins"))]
938938
plugin_paths: TemplatesSet,
939-
}
939+
},
940+
941+
log: {
942+
/// The directories where log plugins are stored
943+
#[tedge_config(example = "/usr/share/log-plugins,/etc/tedge/log-plugins", default(value = "/usr/share/tedge/log-plugins"))]
944+
plugin_paths: TemplatesSet,
945+
},
940946
}
941947

942948
static CLOUD_ROOT_CERTIFICATES: OnceLock<Arc<[Certificate]>> = OnceLock::new();

crates/core/tedge/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ strum_macros = { workspace = true }
4949
tar = { workspace = true }
5050
tedge-agent = { workspace = true }
5151
tedge-apt-plugin = { workspace = true }
52+
tedge-file-log-plugin = { workspace = true }
5253
tedge-mapper = { workspace = true, default-features = false }
5354
tedge-watchdog = { workspace = true }
5455
tedge-write = { workspace = true }

crates/core/tedge/src/cli/init.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ impl TEdgeInitCmd {
9595
create_directory(&config.logs.path, &permissions).await?;
9696
create_directory(&config.data.path, &permissions).await?;
9797

98+
for log_plugins_dir in &config.log.plugin_paths.0 {
99+
create_directory(&log_plugins_dir, &permissions).await?;
100+
}
101+
// The last directory of the log plugin path list is the location for thin-edge provided plugins
102+
if let Some(main_log_plugins_dir) = config.log.plugin_paths.0.last() {
103+
create_symlinks_for("file", target, Path::new(main_log_plugins_dir), &RealEnv).await?;
104+
}
105+
98106
let entity_store_file = config_dir.join(".agent").join("entity_store.jsonl");
99107

100108
if entity_store_file.exists() {

crates/core/tedge/src/cli/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use tedge_agent::AgentOpt;
1010
use tedge_apt_plugin::AptCli;
1111
use tedge_config::cli::CommonArgs;
1212
use tedge_config::TEdgeConfig;
13+
use tedge_file_log_plugin::bin::FileLogCli;
1314
use tedge_mapper::MapperOpt;
1415
use tedge_watchdog::WatchdogOpt;
1516
use tedge_write::bin::Args as TedgeWriteOpt;
@@ -70,6 +71,8 @@ pub enum Component {
7071
#[clap(alias = "apt")]
7172
TedgeAptPlugin(AptCli),
7273

74+
TedgeFileLogPlugin(FileLogCli),
75+
7376
TedgeMapper(MapperOpt),
7477

7578
TedgeWatchdog(WatchdogOpt),

0 commit comments

Comments
 (0)