From 8d2c7237ef366968cd2a41aec5111233950e0fc8 Mon Sep 17 00:00:00 2001 From: Michal Pristas Date: Fri, 15 Jan 2021 10:48:46 +0100 Subject: [PATCH] [Ingest Manager] Agent fetching DBus service PID fix (#23496) [Ingest Manager] Agent fetching DBus service PID fix (#23496) --- x-pack/elastic-agent/CHANGELOG.next.asciidoc | 1 + .../elastic-agent/pkg/agent/application/upgrade/service.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/x-pack/elastic-agent/CHANGELOG.next.asciidoc b/x-pack/elastic-agent/CHANGELOG.next.asciidoc index 7772d47f019..00983d96c15 100644 --- a/x-pack/elastic-agent/CHANGELOG.next.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.next.asciidoc @@ -33,6 +33,7 @@ - Support for linux/arm64 {pull}23479[23479] - Skip top level files when unziping archive during upgrade {pull}23456[23456] - Do not take ownership of Endpoint log path {pull}23444[23444] +- Fixed fetching DBus service PID {pull}23496[23496] - Fix issue of missing log messages from filebeat monitor {pull}23514[23514] ==== New features diff --git a/x-pack/elastic-agent/pkg/agent/application/upgrade/service.go b/x-pack/elastic-agent/pkg/agent/application/upgrade/service.go index 2c21d020f8b..097fabb6855 100644 --- a/x-pack/elastic-agent/pkg/agent/application/upgrade/service.go +++ b/x-pack/elastic-agent/pkg/agent/application/upgrade/service.go @@ -171,7 +171,12 @@ func (p *dbusPidProvider) Close() { } func (p *dbusPidProvider) PID(ctx context.Context) (int, error) { - prop, err := p.dbusConn.GetServiceProperty(install.ServiceName, "MainPID") + sn := install.ServiceName + if !strings.HasSuffix(sn, ".service") { + sn += ".service" + } + + prop, err := p.dbusConn.GetServiceProperty(sn, "MainPID") if err != nil { return 0, errors.New("failed to read service", err) }