Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fleet) installer setup scripts improvements #32062

Merged
merged 18 commits into from
Dec 12, 2024
Merged
4 changes: 4 additions & 0 deletions cmd/installer-downloader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func downloadInstaller(ctx context.Context, env *env.Env, version string, tmpDir
if downloadedPackage.Name != installerPackage {
return fmt.Errorf("unexpected package name: %s, expected %s", downloadedPackage.Name, installerPackage)
}
err = downloadedPackage.WriteOCILayout(tmpDir)
if err != nil {
return fmt.Errorf("failed to write OCI layout: %w", err)
}
err = downloadedPackage.ExtractLayers(oci.DatadogPackageLayerMediaType, tmpDir)
if err != nil {
return fmt.Errorf("failed to extract layers: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/fleet/installer/packages/datadog_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func SetupAgent(ctx context.Context, _ []string) (err error) {
if err = os.MkdirAll("/etc/datadog-agent", 0755); err != nil {
return fmt.Errorf("failed to create /etc/datadog-agent: %v", err)
}
ddAgentUID, ddAgentGID, err := GetAgentIDs()
ddAgentUID, ddAgentGID, err := getAgentIDs()
if err != nil {
return fmt.Errorf("error getting dd-agent user and group IDs: %w", err)
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func chownRecursive(path string, uid int, gid int, ignorePaths []string) error {

// StartAgentExperiment starts the agent experiment
func StartAgentExperiment(ctx context.Context) error {
ddAgentUID, ddAgentGID, err := GetAgentIDs()
ddAgentUID, ddAgentGID, err := getAgentIDs()
if err != nil {
return fmt.Errorf("error getting dd-agent user and group IDs: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/fleet/installer/packages/datadog_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func SetupInstaller(ctx context.Context) (err error) {
if err != nil {
return fmt.Errorf("error adding dd-agent user to dd-agent group: %w", err)
}
ddAgentUID, ddAgentGID, err := GetAgentIDs()
ddAgentUID, ddAgentGID, err := getAgentIDs()
if err != nil {
return fmt.Errorf("error getting dd-agent user and group IDs: %w", err)
}
Expand Down Expand Up @@ -165,8 +165,8 @@ func SetupInstaller(ctx context.Context) (err error) {
return startInstallerStable(ctx)
}

// GetAgentIDs returns the UID and GID of the dd-agent user and group.
func GetAgentIDs() (uid, gid int, err error) {
// getAgentIDs returns the UID and GID of the dd-agent user and group.
func getAgentIDs() (uid, gid int, err error) {
ddAgentUser, err := user.Lookup("dd-agent")
if err != nil {
return -1, -1, fmt.Errorf("dd-agent user not found: %w", err)
Expand Down
Loading
Loading