Skip to content

Commit

Permalink
upgrade(installer): Add APM injector package installation support (#2…
Browse files Browse the repository at this point in the history
…4372)

* fix(errors): Clearer errors

* upgrade(updater): Add injector support

* fix(updater): Use privileged command to write

* fix(updater): Update catalog and support ld.so.preload not existing

* upgrade(updater): Add injector docker support

* chore(updater): Make writing to ld.so.preload safer and remove experiment

* remove catalog changes for less conflicts

* fix(installer): Cleanup APM injector on setup failure

* fix(updater): Remove APM injector on purge

* test(installer): Add E2E test for injector installation

* fix(installer): Add agent config support for apm injector & fix test

* fix(installer): Add error message to helper commands and tentatively fix e2e

* fix(installer): Fix e2e tests

* refactor(installer): Refactor injector installation

* refactor(installer): Manipulate files in go instead of string manipulation

* feat(updater): Add lock to package installation commands

* fix(tests): Version is not resolved anymore in docker's daemon.json

* fix(installer): Allow installation of the injector before the agent

* address part of the review

* chore(installer): Add more tests

* fix(tests): Skip some tests to be able to merge
  • Loading branch information
BaptisteFoy authored and CelianR committed Apr 26, 2024
1 parent 2643159 commit 0f77d7f
Show file tree
Hide file tree
Showing 13 changed files with 1,233 additions and 24 deletions.
34 changes: 26 additions & 8 deletions pkg/updater/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"path/filepath"
"strings"
"sync"

oci "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/types"
Expand All @@ -27,11 +28,15 @@ const (
datadogPackageConfigLayerMediaType types.MediaType = "application/vnd.datadog.package.config.layer.v1.tar+zstd"
datadogPackageMaxSize = 3 << 30 // 3GiB
defaultConfigsDir = "/etc"

packageDatadogAgent = "datadog-agent"
packageAPMInjector = "datadog-apm-inject"
)

type installer struct {
repositories *repository.Repositories
configsDir string
installLock sync.Mutex
}

func newInstaller(repositories *repository.Repositories) *installer {
Expand All @@ -56,10 +61,17 @@ func (i *installer) installStable(pkg string, version string, image oci.Image) e
if err != nil {
return fmt.Errorf("could not create repository: %w", err)
}
if pkg == "datadog-agent" {

i.installLock.Lock()
defer i.installLock.Unlock()
switch pkg {
case packageDatadogAgent:
return service.SetupAgentUnits()
case packageAPMInjector:
return service.SetupAPMInjector()
default:
return nil
}
return nil
}

func (i *installer) installExperiment(pkg string, version string, image oci.Image) error {
Expand Down Expand Up @@ -100,19 +112,25 @@ func (i *installer) uninstallExperiment(pkg string) error {
}

func (i *installer) startExperiment(pkg string) error {
// TODO(arthur): currently we only support the datadog-agent package
if pkg != "datadog-agent" {
i.installLock.Lock()
defer i.installLock.Unlock()
switch pkg {
case packageDatadogAgent:
return service.StartAgentExperiment()
default:
return nil
}
return service.StartAgentExperiment()
}

func (i *installer) stopExperiment(pkg string) error {
// TODO(arthur): currently we only support the datadog-agent package
if pkg != "datadog-agent" {
i.installLock.Lock()
defer i.installLock.Unlock()
switch pkg {
case packageDatadogAgent:
return service.StopAgentExperiment()
default:
return nil
}
return service.StopAgentExperiment()
}

func extractPackageLayers(image oci.Image, configDir string, packageDir string) error {
Expand Down
Loading

0 comments on commit 0f77d7f

Please sign in to comment.