Commit 2b6687a
authored
Fix installer to gracefully handle systemd not running in containers (#46068)
## What does this PR do?
Fixes the datadog-installer to gracefully handle environments where systemd is not running (e.g., containers, non-systemd init systems).
## Motivation
The installer was failing when attempting to execute `systemctl` commands on systems where systemd is installed but not running, which is common in containers.
## Changes
Added `IsRunning()` checks to systemd operations:
- `StartUnit()` - skips start if systemd not running
- `RestartUnit()` - skips restart if systemd not running
- `EnableUnit()` - skips enable if systemd not running
- `Reload()` - skips daemon-reload if systemd not running
These functions now log at INFO level and return success (nil) when systemd is not running, allowing installation to continue normally.
## Testing
- Compilation verified
- Linters passed (0 issues)
Co-authored-by: baptiste.foy <baptiste.foy@datadoghq.com>1 parent bfbafe1 commit 2b6687a
1 file changed
+34
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | | - | |
| 82 | + | |
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
79 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
80 | 96 | | |
81 | | - | |
| 97 | + | |
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
85 | 101 | | |
86 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
87 | 111 | | |
88 | 112 | | |
89 | 113 | | |
| |||
133 | 157 | | |
134 | 158 | | |
135 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
136 | 168 | | |
137 | 169 | | |
138 | 170 | | |
| |||
0 commit comments