Skip to content

Commit

Permalink
(fleet) move /opt/datadog-installer/tmp to /opt/datadog-packages/tmp (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
arbll authored Nov 28, 2024
1 parent 79b975d commit b1170d5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/fleet/installer/repository/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func (r *Repositories) loadRepositories() (map[string]*Repository, error) {
// Temporary dir created by Repositories.MkdirTemp, ignore
continue
}
if d.Name() == "run" {
// run dir, ignore
if d.Name() == "run" || d.Name() == "tmp" {
// run/tmp dir, ignore
continue
}
repo := r.newRepository(d.Name())
Expand Down
4 changes: 4 additions & 0 deletions pkg/fleet/installer/repository/repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ func TestLoadRepositories(t *testing.T) {

os.Mkdir(path.Join(rootDir, "datadog-agent"), 0755)
os.Mkdir(path.Join(rootDir, tempDirPrefix+"2394812349"), 0755)
os.Mkdir(path.Join(rootDir, "run"), 0755)
os.Mkdir(path.Join(rootDir, "tmp"), 0755)

repositories, err := NewRepositories(rootDir, runDir).loadRepositories()
assert.NoError(t, err)
assert.Len(t, repositories, 1)
assert.Contains(t, repositories, "datadog-agent")
assert.NotContains(t, repositories, tempDirPrefix+"2394812349")
assert.NotContains(t, repositories, "run")
assert.NotContains(t, repositories, "tmp")
}
8 changes: 4 additions & 4 deletions pkg/fleet/installer/service/datadog_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ func SetupInstaller(ctx context.Context) (err error) {
}
// Enforce that the directory exists. It should be created by the bootstrapper but
// older versions don't do it
err = os.MkdirAll("/opt/datadog-installer/tmp", 0755)
err = os.MkdirAll("/opt/datadog-packages/tmp", 0755)
if err != nil {
return fmt.Errorf("error creating /opt/datadog-installer/tmp: %w", err)
return fmt.Errorf("error creating /opt/datadog-packages/tmp: %w", err)
}
err = os.Chown("/opt/datadog-installer/tmp", ddAgentUID, ddAgentGID)
err = os.Chown("/opt/datadog-packages/tmp", ddAgentUID, ddAgentGID)
if err != nil {
return fmt.Errorf("error changing owner of /opt/datadog-installer/tmp: %w", err)
return fmt.Errorf("error changing owner of /opt/datadog-packages/tmp: %w", err)
}
// Create installer path symlink
err = os.Symlink("/opt/datadog-packages/datadog-installer/stable/bin/installer/installer", "/usr/bin/datadog-installer")
Expand Down
2 changes: 1 addition & 1 deletion pkg/fleet/internal/paths/installer_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
// LocksPath is the path to the packages locks directory.
LocksPath = "/opt/datadog-packages/run/locks"
// RootTmpDir is the temporary path where the bootstrapper will be extracted to.
RootTmpDir = "/opt/datadog-installer/tmp"
RootTmpDir = "/opt/datadog-packages/tmp"
// DefaultUserConfigsDir is the default Agent configuration directory.
DefaultUserConfigsDir = "/etc"
// StableInstallerPath is the path to the stable installer binary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (s *packageInstallerSuite) TestInstall() {
state.AssertDirExists("/opt/datadog-packages/run/locks", 0777, "root", "root")

state.AssertDirExists("/opt/datadog-installer", 0755, "root", "root")
state.AssertDirExists("/opt/datadog-installer/tmp", 0755, "dd-agent", "dd-agent")
state.AssertDirExists("/opt/datadog-packages/tmp", 0755, "dd-agent", "dd-agent")
state.AssertDirExists("/opt/datadog-packages", 0755, "root", "root")
state.AssertDirExists("/opt/datadog-packages/datadog-installer", 0755, "root", "root")

Expand Down

0 comments on commit b1170d5

Please sign in to comment.