Skip to content

Commit 764bdca

Browse files
committed
Clean up runtime-created directories in the package scripts
1 parent 6fe006e commit 764bdca

File tree

8 files changed

+22
-5
lines changed

8 files changed

+22
-5
lines changed

comp/api/api/apiimpl/listener/listener_nix_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ func TestLinuxGetIPCServerPath(t *testing.T) {
2323

2424
path, enabled := GetIPCServerPath()
2525
require.True(t, enabled)
26-
// Default run path is {InstallPath}/run for container compatibility
27-
// (containers mount volumes at /opt/datadog-agent/run, not /var/run/datadog)
26+
// Default run path is {InstallPath}/run for consistency with other runtime files
2827
require.Equal(t, "/opt/datadog-agent/run/agent_ipc.socket", path)
2928
})
3029
}

omnibus/package-scripts/agent-deb/postrm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ case "$1" in
2121
rm -rf $LOG_DIR
2222
rm -rf $CONFIG_DIR
2323
;;
24+
remove)
25+
# Clean up runtime-created directories (sockets, pid files, etc.)
26+
rm -rf "$INSTALL_DIR/run" || true
27+
;;
2428
*)
2529
;;
2630
esac

omnibus/package-scripts/dogstatsd-deb/postrm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ case "$1" in
2424
rm -rf $LOG_DIR
2525
rm -rf $CONFIG_DIR
2626
;;
27+
remove)
28+
# Clean up runtime-created directories (sockets, pid files, etc.)
29+
rm -rf "$INSTALL_DIR/run" || true
30+
;;
2731
*)
2832
;;
2933
esac

omnibus/package-scripts/dogstatsd-rpm/postrm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
# Remove the symlink to the binary.
88
rm -f "/usr/bin/datadog-dogstatsd"
99

10+
INSTALL_DIR=/opt/datadog-dogstatsd
11+
1012
case "$*" in
1113
0)
1214
# We're uninstalling.
1315
# We don't delete the dd-agent user/group (see https://fedoraproject.org/wiki/Packaging:UsersAndGroups#Allocation_Strategies)
16+
# Clean up runtime-created directories (sockets, pid files, etc.)
17+
rm -rf "$INSTALL_DIR/run" || true
1418
;;
1519
1)
1620
# We're upgrading.

omnibus/package-scripts/iot-agent-deb/postrm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ case "$1" in
2626
;;
2727
remove)
2828
rm "$CONFIG_DIR/install_info" || true
29+
# Clean up runtime-created directories (sockets, pid files, etc.)
30+
rm -rf "$INSTALL_DIR/run" || true
2931
;;
3032
*)
3133
;;

omnibus/package-scripts/iot-agent-rpm/postrm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ CONFIG_DIR=/etc/datadog-agent
99
# Remove the symlink to the binary.
1010
rm -f "/usr/bin/datadog-agent"
1111

12+
INSTALL_DIR=/opt/datadog-agent
13+
1214
case "$*" in
1315
0)
1416
# We're uninstalling.
1517
# We don't delete the dd-agent user/group (see https://fedoraproject.org/wiki/Packaging:UsersAndGroups#Allocation_Strategies)
1618
rm "$CONFIG_DIR/install_info" || true
19+
# Clean up runtime-created directories (sockets, pid files, etc.)
20+
rm -rf "$INSTALL_DIR/run" || true
1721
;;
1822
1)
1923
# We're upgrading.

pkg/util/defaultpaths/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ require (
1414
github.com/DataDog/datadog-agent/pkg/template v0.64.1 // indirect
1515
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.64.1 // indirect
1616
github.com/DataDog/datadog-agent/pkg/version v0.62.3 // indirect
17+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
18+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
1719
go.uber.org/atomic v1.11.0 // indirect
1820
golang.org/x/time v0.14.0 // indirect
1921
gopkg.in/yaml.v3 v3.0.1 // indirect

pkg/util/defaultpaths/path_nix.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ const (
4343
checkFlareDirectory = "/var/log/datadog/checks/"
4444
jmxFlareDirectory = "/var/log/datadog/jmxinfo/"
4545

46-
// Socket paths - these constants are used for config registration defaults.
47-
// The actual runtime paths derive from GetRunPath() which uses {InstallPath}/run.
48-
// Containers mount volumes at /opt/datadog-agent/run, not /var/run/datadog.
46+
// Socket paths - use {InstallPath}/run for consistency with other runtime files
4947
defaultStatsdSocket = "/opt/datadog-agent/run/dsd.socket"
5048
defaultReceiverSocket = "/opt/datadog-agent/run/apm.socket"
5149

0 commit comments

Comments
 (0)