Skip to content

Commit

Permalink
fix(installer): Don't run preinst when there is nothing to do (DataDo…
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptisteFoy authored Jan 9, 2025
1 parent 3fa0ffd commit 3a9edff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/fleet/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ func (i *installerImpl) Install(ctx context.Context, url string, args []string)
span.SetResourceName(pkg.Name)
span.SetTag("package_version", pkg.Version)
}
err = i.preparePackage(ctx, pkg.Name, args) // Preinst
if err != nil {
return fmt.Errorf("could not prepare package: %w", err)
}
dbPkg, err := i.db.GetPackage(pkg.Name)
if err != nil && !errors.Is(err, db.ErrPackageNotFound) {
return fmt.Errorf("could not get package: %w", err)
Expand All @@ -181,6 +177,10 @@ func (i *installerImpl) Install(ctx context.Context, url string, args []string)
log.Infof("package %s version %s is already installed", pkg.Name, pkg.Version)
return nil
}
err = i.preparePackage(ctx, pkg.Name, args) // Preinst
if err != nil {
return fmt.Errorf("could not prepare package: %w", err)
}
err = checkAvailableDiskSpace(i.packages, pkg)
if err != nil {
return fmt.Errorf("not enough disk space: %w", err)
Expand Down
5 changes: 0 additions & 5 deletions pkg/fleet/installer/packages/datadog_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ func PrepareAgent(ctx context.Context) (err error) {
span, ctx := telemetry.StartSpanFromContext(ctx, "prepare_agent")
defer func() { span.Finish(err) }()

err = removeDebRPMPackage(ctx, "datadog-agent")
if err != nil {
return fmt.Errorf("failed to remove deb/rpm datadog-agent package: %w", err)
}

for _, unit := range stableUnits {
if err := stopUnit(ctx, unit); err != nil {
log.Warnf("Failed to stop %s: %s", unit, err)
Expand Down

0 comments on commit 3a9edff

Please sign in to comment.