Skip to content

Commit a2ce32e

Browse files
authored
Add support for debian 13 (#2140)
1 parent a2f3120 commit a2ce32e

File tree

8 files changed

+117
-23
lines changed

8 files changed

+117
-23
lines changed

.github/workflows/component_molecule_packaging.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
repo_base_url: ${{ inputs.REPO_ENDPOINT }}
2929
package_name: 'newrelic-infra'
3030
package_version: ${{ inputs.TAG }}
31-
platforms: "al2,al2023,debian-bullseye,debian-bookworm,redhat8,redhat9,suse15.3,suse15.4,suse15.5,suse15.6,suse15.7,ubuntu1604,ubuntu1804,ubuntu2004,ubuntu2204,ubuntu2404"
31+
platforms: "al2,al2023,debian-bullseye,debian-bookworm,debian-trixie,redhat8,redhat9,suse15.3,suse15.4,suse15.5,suse15.6,suse15.7,ubuntu1604,ubuntu1804,ubuntu2004,ubuntu2204,ubuntu2404"
3232
- name: Test FIPS package installation
3333
uses: newrelic/pkg-installation-testing-action@v1
3434
with:
@@ -37,4 +37,4 @@ jobs:
3737
package_name: 'newrelic-infra-fips'
3838
exec_name: 'newrelic-infra'
3939
package_version: ${{ inputs.TAG }}
40-
platforms: "al2,al2023,debian-bullseye,debian-bookworm,redhat8,redhat9,suse15.3,suse15.4,suse15.5,suse15.6,suse15.7,ubuntu1604,ubuntu1804,ubuntu2004,ubuntu2204,ubuntu2404"
40+
platforms: "al2,al2023,debian-bullseye,debian-bookworm,debian-trixie,redhat8,redhat9,suse15.3,suse15.4,suse15.5,suse15.6,suse15.7,ubuntu1604,ubuntu1804,ubuntu2004,ubuntu2204,ubuntu2404"

THIRD_PARTY_NOTICES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ Distributed under the following license(s):
134134

135135

136136

137+
## [github.com/godbus/dbus/v5](https://github.com/godbus/dbus)
138+
139+
Distributed under the following license(s):
140+
141+
* BSD-2-Clause
142+
143+
144+
137145
## [github.com/golang/groupcache](https://github.com/golang/groupcache)
138146

139147
Distributed under the following license(s):

build/upload-schema-linux-deb-fips.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- hirsute
2121
- bullseye
2222
- bookworm
23+
- trixie
2324

2425
- src: "newrelic-infra-fips_upstart_{version}_{arch}.deb"
2526
arch:

build/upload-schema-linux-deb.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- hirsute
2222
- bullseye
2323
- bookworm
24+
- trixie
2425

2526
- src: "newrelic-infra_upstart_{version}_{arch}.deb"
2627
arch:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ require (
1818
github.com/evanphx/json-patch v4.9.0+incompatible
1919
github.com/fortytw2/leaktest v1.3.1-0.20190606143808-d73c753520d9
2020
github.com/fsnotify/fsnotify v1.6.0
21+
github.com/godbus/dbus/v5 v5.1.0
2122
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
2223
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
2324
github.com/google/uuid v1.6.0
@@ -77,7 +78,6 @@ require (
7778
github.com/go-logr/logr v1.4.3 // indirect
7879
github.com/go-logr/stdr v1.2.2 // indirect
7980
github.com/go-ole/go-ole v1.2.6 // indirect
80-
github.com/godbus/dbus/v5 v5.1.0 // indirect
8181
github.com/gogo/protobuf v1.3.2 // indirect
8282
github.com/google/go-cmp v0.7.0 // indirect
8383
github.com/klauspost/compress v1.16.7 // indirect

internal/plugins/linux/users.go

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ package linux
77

88
import (
99
"bufio"
10+
"os"
11+
"strings"
12+
"time"
13+
1014
"github.com/fsnotify/fsnotify"
15+
"github.com/godbus/dbus/v5"
1116
"github.com/newrelic/infrastructure-agent/internal/agent/types"
1217
"github.com/newrelic/infrastructure-agent/pkg/entity"
1318
"github.com/newrelic/infrastructure-agent/pkg/log"
14-
"strings"
15-
"time"
1619

1720
"github.com/newrelic/infrastructure-agent/pkg/plugins/ids"
1821

@@ -23,6 +26,8 @@ import (
2326

2427
var usrlog = log.WithPlugin("Users")
2528

29+
const utmpPath = "/var/run/utmp"
30+
2631
type UsersPlugin struct {
2732
agent.PluginCommon
2833
frequency time.Duration
@@ -93,14 +98,29 @@ func (self *UsersPlugin) Run() {
9398
return
9499
}
95100

101+
// Strategy 1: Attempt to use the legacy utmp file watcher.
102+
// We check if the file exists first.
103+
if _, err := os.Stat(utmpPath); err == nil {
104+
usrlog.Debug("utmp file found, using legacy file watcher. path " + utmpPath)
105+
self.runUtmpWatcher()
106+
} else {
107+
// Strategy 2: Fallback to the modern D-Bus watcher for systemd-logind.
108+
usrlog.Debug("utmp file not found, falling back to modern D-Bus watcher for systemd-logind.")
109+
self.runDbusWatcher()
110+
}
111+
}
112+
113+
// This function contains the original logic for watching /var/run/utmp.
114+
func (self *UsersPlugin) runUtmpWatcher() {
96115
watcher, err := fsnotify.NewWatcher()
97116
if err != nil {
98-
usrlog.WithError(err).Error("can't instantiate users watcher")
117+
usrlog.WithError(err).Error("can't instantiate legacy users watcher (fsnotify)")
99118
self.Unregister()
100119
return
101120
}
121+
defer watcher.Close()
102122

103-
err = watcher.Add("/var/run/utmp")
123+
err = watcher.Add(utmpPath)
104124
if err != nil {
105125
usrlog.WithError(err).Error("can't setup trigger file watcher for users")
106126
self.Unregister()
@@ -128,3 +148,53 @@ func (self *UsersPlugin) Run() {
128148
}
129149
}
130150
}
151+
152+
// This function contains the logic for listening to systemd-logind signals via D-Bus.
153+
func (self *UsersPlugin) runDbusWatcher() {
154+
conn, err := dbus.SystemBus()
155+
if err != nil {
156+
usrlog.WithError(err).Error("can't connect to system D-Bus, cannot monitor user sessions")
157+
self.Unregister()
158+
return
159+
}
160+
defer conn.Close()
161+
162+
// D-Bus "match rules" for login and logout signals.
163+
rules := []string{
164+
"type='signal',interface='org.freedesktop.login1.Manager',member='SessionNew'",
165+
"type='signal',interface='org.freedesktop.login1.Manager',member='SessionRemoved'",
166+
}
167+
for _, rule := range rules {
168+
if err = conn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, rule).Err; err != nil {
169+
usrlog.WithError(err).Errorf("failed to add D-Bus match rule '%s'", rule)
170+
self.Unregister()
171+
return
172+
}
173+
}
174+
175+
signals := make(chan *dbus.Signal, 10)
176+
conn.Signal(signals)
177+
178+
refreshTimer := time.NewTimer(1)
179+
needsFlush := true
180+
181+
for {
182+
select {
183+
case signal, ok := <-signals:
184+
if ok {
185+
if signal != nil {
186+
// Any signal (SessionNew or SessionRemoved) triggers a refresh.
187+
needsFlush = true
188+
}
189+
}
190+
case <-refreshTimer.C:
191+
{
192+
refreshTimer.Reset(self.frequency)
193+
if needsFlush {
194+
self.EmitInventory(self.getUserDetails(), entity.NewFromNameWithoutID(self.Context.EntityKey()))
195+
needsFlush = false
196+
}
197+
}
198+
}
199+
}
200+
}

test/automated/ansible/group_vars/localhost/main.yml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,23 +231,37 @@ instances:
231231
platform: "linux"
232232
python_interpreter: "/usr/bin/python3"
233233
launch_template: "LaunchTemplateId=lt-0b00afb3f5110a0e6,Version=3"
234+
- ami: "ami-0bb7d855677353076"
235+
type: "t3a.small"
236+
name: "amd64:debian-trixie"
237+
username: "admin"
238+
platform: "linux"
239+
python_interpreter: "/usr/bin/python3"
240+
launch_template: "LaunchTemplateId=lt-0b00afb3f5110a0e6,Version=3"
234241
############################
235242
# debian arm64
236243
############################
237-
# - ami: "ami-03cabbbc935f5826f"
238-
# type: "t4g.small"
239-
# name: "arm64:debian-bullseye"
240-
# username: "admin"
241-
# platform: "linux"
242-
# python_interpreter: "/usr/bin/python3"
243-
# launch_template: "LaunchTemplateId=lt-0b00afb3f5110a0e6,Version=3"
244-
# - ami: "ami-05f312273b2ebaf0b"
245-
# type: "t4g.small"
246-
# name: "arm64:debian-bookworm"
247-
# username: "admin"
248-
# platform: "linux"
249-
# python_interpreter: "/usr/bin/python3"
250-
# launch_template: "LaunchTemplateId=lt-0b00afb3f5110a0e6,Version=3"
244+
- ami: "ami-03cabbbc935f5826f"
245+
type: "t4g.small"
246+
name: "arm64:debian-bullseye"
247+
username: "admin"
248+
platform: "linux"
249+
python_interpreter: "/usr/bin/python3"
250+
launch_template: "LaunchTemplateId=lt-0b00afb3f5110a0e6,Version=3"
251+
- ami: "ami-05f312273b2ebaf0b"
252+
type: "t4g.small"
253+
name: "arm64:debian-bookworm"
254+
username: "admin"
255+
platform: "linux"
256+
python_interpreter: "/usr/bin/python3"
257+
launch_template: "LaunchTemplateId=lt-0b00afb3f5110a0e6,Version=3"
258+
- ami: "ami-06329a2d246a44575"
259+
type: "t4g.small"
260+
name: "arm64:debian-trixie"
261+
username: "admin"
262+
platform: "linux"
263+
python_interpreter: "/usr/bin/python3"
264+
launch_template: "LaunchTemplateId=lt-0b00afb3f5110a0e6,Version=3"
251265
############################
252266
# amazon linux 2 amd64
253267
############################

test/provision/terraform/caos.auto.tfvars.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ ec2_prefix = "PREFIX:TAG_OR_UNIQUE_NAME"
22

33
windows_ec2 = ["windows_2016", "windows_2019", "windows_2022", "windows_2025"]
44

5-
linux_ec2_amd = ["amd64:ubuntu24.04", "amd64:ubuntu22.04", "amd64:ubuntu20.04", "amd64:ubuntu18.04", "amd64:ubuntu16.04", "amd64:centos-stream", "amd64:sles-12.5", "amd64:sles-15.3", "amd64:sles-15.4", "amd64:sles-15.5", "amd64:sles-15.6", "amd64:sles-15.7", "amd64:redhat-8.4", "amd64:redhat-9.0", "amd64:debian-bookworm", "amd64:al-2", "amd64:al-2023", "amd64:al-2023-fips"]
5+
linux_ec2_amd = ["amd64:ubuntu24.04", "amd64:ubuntu22.04", "amd64:ubuntu20.04", "amd64:ubuntu18.04", "amd64:ubuntu16.04", "amd64:centos-stream", "amd64:sles-12.5", "amd64:sles-15.3", "amd64:sles-15.4", "amd64:sles-15.5", "amd64:sles-15.6", "amd64:sles-15.7", "amd64:redhat-8.4", "amd64:redhat-9.0", "amd64:debian-bookworm", "amd64:debian-trixie", "amd64:al-2", "amd64:al-2023", "amd64:al-2023-fips"]
66

7-
linux_ec2_arm = ["arm64:ubuntu24.04", "arm64:ubuntu22.04", "arm64:ubuntu20.04", "arm64:ubuntu18.04", "arm64:ubuntu16.04", "arm64:centos-stream", "arm64:sles-15.4", "arm64:sles-15.5", "arm64:sles-15.6", "arm64:sles-15.7", "arm64:redhat-9.0", "arm64:debian-bookworm", "arm64:al-2", "arm64:al-2023", "arm64:al-2023-fips"]
7+
linux_ec2_arm = ["arm64:ubuntu24.04", "arm64:ubuntu22.04", "arm64:ubuntu20.04", "arm64:ubuntu18.04", "arm64:ubuntu16.04", "arm64:centos-stream", "arm64:sles-15.4", "arm64:sles-15.5", "arm64:sles-15.6", "arm64:sles-15.7", "arm64:redhat-9.0", "arm64:debian-bookworm", "arm64:debian-trixie", "arm64:al-2", "arm64:al-2023", "arm64:al-2023-fips"]
88

99
ssh_pub_key = "AAAAB3NzaC1yc2EAAAADAQABAAABAQDH9C7BS2XrtXGXFFyL0pNku/Hfy84RliqvYKpuslJFeUivf5QY6Ipi8yXfXn6TsRDbdxfGPi6oOR60Fa+4cJmCo6N5g57hBS6f2IdzQBNrZr7i1I/a3cFeK6XOc1G1tQaurx7Pu+qvACfJjLXKG66tHlaVhAHd/1l2FocgFNUDFFuKS3mnzt9hKys7sB4aO3O0OdohN/0NJC4ldV8/OmeXqqfkiPWcgPx3C8bYyXCX7QJNBHKrzbX1jW51Px7SIDWFDV6kxGwpQGGBMJg/k79gjjM+jhn4fg1/VP/Fx37mAnfLqpcTfiOkzSE80ORGefQ1XfGK/Dpa3ITrzRYW8xlR caos-dev-arm"
1010
pvt_key = "~/.ssh/caos-dev-arm.cer"

0 commit comments

Comments
 (0)