Skip to content

Commit f5669fe

Browse files
committed
[PLAT-18888] Otel process is not disabled after stopping metrics/logs export
Summary: Otel process is not disabled after stopping metrics/logs export. This diff fixes the otel install, start and enable process via node agent. Before this diff, the otel collector was not being stopped and disabled correctly. Noticed it also needs a fix to start and enable node agent. Before this diff (Notice it is active but disabled): ``` #After enabling audit logs, metric export, or both [yugabyte@yb-admin-sahith-uni-2-n1 ~]$ systemctl --user status otel-collector ● otel-collector.service - OpenTelemetry Collector Loaded: loaded (/home/yugabyte/.config/systemd/user/otel-collector.service; disabled; preset: disabled) Active: active (running) since Wed 2025-11-05 05:09:11 UTC; 17s ago Main PID: 820726 (otelcol-contrib) Tasks: 6 (limit: 21916) Memory: 57.3M (max: 2.0G available: 1.9G) CPU: 359ms CGroup: /user.slice/user-1994.slice/[email protected]/app.slice/otel-collector.service └─820726 /home/yugabyte/otel-collector/otelcol-contrib --config=file:/home/yugabyte/otel-collector/config.yml ``` After this diff (active + enabled or inactive + disabled, which is correct and expected): ``` #After enabling audit logs, metric export, or both [yugabyte@yb-admin-sahith-uni-2-n1 ~]$ systemctl --user status otel-collector ● otel-collector.service - OpenTelemetry Collector Loaded: loaded (/home/yugabyte/.config/systemd/user/otel-collector.service; enabled; preset: disabled) Active: active (running) since Wed 2025-11-05 05:18:52 UTC; 10s ago Main PID: 826541 (otelcol-contrib) Tasks: 6 (limit: 21916) Memory: 66.4M (max: 2.0G available: 1.9G) CPU: 381ms CGroup: /user.slice/user-1994.slice/[email protected]/app.slice/otel-collector.service └─826541 /home/yugabyte/otel-collector/otelcol-contrib --config=file:/home/yugabyte/otel-collector/config.yml # After disabling both audit logs and metrics export [yugabyte@yb-admin-sahith-uni-2-n1 ~]$ systemctl --user status otel-collector ○ otel-collector.service - OpenTelemetry Collector Loaded: loaded (/home/yugabyte/.config/systemd/user/otel-collector.service; disabled; preset: disabled) Active: inactive (dead) ``` Test Plan: Manually tested by clean compiling, then reinstalling node agent on the universe. Enabled metric export, disabled metric export. Enabled audit log export, disabled audit log export. Enabled DBME and DBAL, disabled only metric export - noticed otel is still running as expected. Also: Run UTs. Run itests. Reviewers: nsingh Reviewed By: nsingh Subscribers: yugaware Differential Revision: https://phorge.dev.yugabyte.com/D48039
1 parent 1e1e6d5 commit f5669fe

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

managed/node-agent/app/task/install_otel_collector.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,13 @@ func (h *InstallOtelCollector) Handle(ctx context.Context) (*pb.DescribeTaskResp
8787
return nil, err
8888
}
8989

90-
// 4) stop the systemd-unit if it's running.
91-
if err := module.StopSystemdService(ctx, h.username, OtelCollectorService, h.logOut); err != nil {
90+
// 4) Stop and disable the systemd service
91+
if err := module.DisableSystemdService(
92+
ctx,
93+
h.username,
94+
OtelCollectorService,
95+
"", // Don't remove the unit file - we need it for re-enabling later
96+
h.logOut); err != nil {
9297
return nil, err
9398
}
9499

@@ -99,9 +104,14 @@ func (h *InstallOtelCollector) Handle(ctx context.Context) (*pb.DescribeTaskResp
99104
return nil, err
100105
}
101106

102-
// 6) Start and enable the otel-collector service.
103-
if err = module.StartSystemdService(ctx, h.username, OtelCollectorService, h.logOut); err != nil {
104-
return nil, err
107+
// 6) Start and enable the service only if config file exists
108+
if h.param.GetOtelColConfigFile() != "" {
109+
if err = module.StartSystemdService(ctx, h.username, OtelCollectorService, h.logOut); err != nil {
110+
return nil, err
111+
}
112+
if err = module.EnableSystemdService(ctx, h.username, OtelCollectorService, h.logOut); err != nil {
113+
return nil, err
114+
}
105115
}
106116
return nil, nil
107117
}

0 commit comments

Comments
 (0)