Skip to content

Commit

Permalink
Revert "[EBPF] Test correct packaging of eBPF files" (DataDog#26151)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencergilbert authored May 31, 2024
1 parent 598cdb0 commit 2b807a5
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 92 deletions.
5 changes: 0 additions & 5 deletions omnibus/package-scripts/agent-rpm/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ remove_sysprobe_secagent_files()
if [ -d "$INSTALL_DIR/run" ]; then
rmdir "$INSTALL_DIR/run" 2>/dev/null || true
fi

# Remove any unpacked BTF files
find "$INSTALL_DIR/embedded/share/system-probe/ebpf/co-re/btf" -name "*.btf*" -type f -delete || true
# And remove empty directories
find "$INSTALL_DIR/embedded/share/system-probe/ebpf/co-re" -type d -empty -delete || true
}

remove_remote_config_db()
Expand Down
19 changes: 0 additions & 19 deletions pkg/ebpf/c/bpf_metadata.h

This file was deleted.

2 changes: 0 additions & 2 deletions pkg/ebpf/c/kconfig.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef __KCONFIG_H
#define __KCONFIG_H

#include "bpf_metadata.h"

#include <linux/kconfig.h>
// include asm/compiler.h to fix `error: expected string literal in 'asm'` compilation error coming from mte-kasan.h
// this was fixed in https://github.com/torvalds/linux/commit/b859ebedd1e730bbda69142fca87af4e712649a1
Expand Down
2 changes: 0 additions & 2 deletions pkg/ebpf/c/ktypes.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef __KTYPES_H__
#define __KTYPES_H__

#include "bpf_metadata.h"

#ifdef COMPILE_CORE
#include "vmlinux.h"
#else
Expand Down
1 change: 0 additions & 1 deletion tasks/libs/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ def get_build_flags(
env['CGO_LDFLAGS'] = os.environ.get('CGO_LDFLAGS', '') + ' -Wl,--allow-multiple-definition'

extra_cgo_flags = " -Werror -Wno-deprecated-declarations"
extra_cgo_flags += " -D__CGO__" # Some C files include definitions that can cause duplicate symbols if included in CGo code (bpf_metadata.h) mainly
if rtloader_headers:
extra_cgo_flags += f" -I{rtloader_headers}"
if rtloader_common_headers:
Expand Down
55 changes: 2 additions & 53 deletions test/new-e2e/tests/agent-platform/common/agent_behaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import (

componentos "github.com/DataDog/test-infra-definitions/components/os"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

agentclient "github.com/DataDog/datadog-agent/test/new-e2e/pkg/utils/e2e/client/agentclient"
boundport "github.com/DataDog/datadog-agent/test/new-e2e/tests/agent-platform/common/bound-port"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// CheckAgentBehaviour runs test to check the agent is behaving as expected
Expand Down Expand Up @@ -320,53 +319,3 @@ func CheckCWSBehaviour(t *testing.T, client *TestClient) {
require.True(tt, result, "system-probe and security-agent should communicate")
})
}

// CheckSystemProbeBehavior runs tests to check the agent behave correctly when system-probe is enabled
func CheckSystemProbeBehavior(t *testing.T, client *TestClient) {
t.Run("enable system-probe and restarts", func(tt *testing.T) {
err := client.SetConfig(client.Helper.GetConfigFolder()+"system-probe.yaml", "system_probe_config.enabled", "true")
require.NoError(tt, err)

err = client.SetConfig(client.Helper.GetConfigFolder()+"system-probe.yaml", "system_probe_config.enabled", "true")
require.NoError(tt, err)

_, err = client.SvcManager.Restart(client.Helper.GetServiceName())
require.NoError(tt, err, "datadog-agent should restart after CWS is enabled")
})

t.Run("system-probe is running", func(tt *testing.T) {
var err error
require.Eventually(tt, func() bool {
return AgentProcessIsRunning(client, "system-probe")
}, 1*time.Minute, 500*time.Millisecond, "system-probe should be running ", err)
})

t.Run("ebpf programs are unpacked and valid", func(tt *testing.T) {
ebpfPath := "/opt/datadog-agent/embedded/share/system-probe/ebpf"
output, err := client.Host.Execute(fmt.Sprintf("find %s -name '*.o'", ebpfPath))
require.NoError(tt, err)
files := strings.Split(strings.TrimSpace(output), "\n")
require.Greater(tt, len(files), 0, "ebpf object files should be present")

_, err = client.Host.Execute("command -v readelf")
if err != nil {
tt.Skip("readelf is not available on the host")
return
}

hostArch, err := client.Host.Execute("uname -m")
require.NoError(tt, err)
hostArch = strings.TrimSpace(hostArch)
if hostArch == "aarch64" {
hostArch = "arm64"
}
archMetadata := fmt.Sprintf("<arch:%s>", hostArch)

for _, file := range files {
file = strings.TrimSpace(file)
ddMetadata, err := client.Host.Execute(fmt.Sprintf("readelf -p dd_metadata %s", file))
require.NoError(tt, err, "readelf should not error, file is %s", file)
require.Contains(tt, ddMetadata, archMetadata, "invalid arch metadata")
}
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,8 @@ func (is *installScriptSuite) AgentTest(flavor string) {
common.CheckAgentPython(is.T(), client, common.ExpectedPythonVersion3)
common.CheckApmEnabled(is.T(), client)
common.CheckApmDisabled(is.T(), client)
if flavor == "datadog-agent" {
common.CheckSystemProbeBehavior(is.T(), client)
if is.cwsSupported {
common.CheckCWSBehaviour(is.T(), client)
}
if flavor == "datadog-agent" && is.cwsSupported {
common.CheckCWSBehaviour(is.T(), client)
}
common.CheckInstallationInstallScript(is.T(), client)
is.testUninstall(client, flavor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,8 @@ func (is *stepByStepSuite) CheckStepByStepAgentInstallation(VMclient *common.Tes
}
common.CheckApmEnabled(is.T(), VMclient)
common.CheckApmDisabled(is.T(), VMclient)
if *flavorName == "datadog-agent" {
common.CheckSystemProbeBehavior(is.T(), VMclient)
if is.cwsSupported {
common.CheckCWSBehaviour(is.T(), VMclient)
}
if *flavorName == "datadog-agent" && is.cwsSupported {
common.CheckCWSBehaviour(is.T(), VMclient)
}

is.T().Run("remove the agent", func(tt *testing.T) {
Expand Down

0 comments on commit 2b807a5

Please sign in to comment.