-
Notifications
You must be signed in to change notification settings - Fork 24
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
Build the collector binary directly in the docker image build #1827
base: master
Are you sure you want to change the base?
Changes from all commits
a4c0800
85ab2f0
8d9b3a7
96817ea
0d76ded
a828140
39a0b7c
c519303
a5b9bf3
04a8fbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* | ||
** | ||
!collector/ | ||
!falcosecurity-libs/ | ||
!CMakeLists.txt | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ NPROCS ?= $(shell nproc) | |
DEV_SSH_SERVER_KEY ?= $(CURDIR)/.collector_dev_ssh_host_ed25519_key | ||
BUILD_BUILDER_IMAGE ?= false | ||
|
||
DOCKERFILE = collector/container/Dockerfile | ||
BUILD_TYPE = rhel | ||
|
||
export COLLECTOR_VERSION := $(COLLECTOR_TAG) | ||
|
||
.PHONY: tag | ||
|
@@ -18,7 +21,7 @@ builder-tag: | |
|
||
.PHONY: container-dockerfile-dev | ||
container-dockerfile-dev: | ||
sed '1s/ubi-minimal/ubi/' $(CURDIR)/collector/container/Dockerfile > \ | ||
sed 's/ubi-minimal/ubi/' $(CURDIR)/collector/container/Dockerfile > \ | ||
$(CURDIR)/collector/container/Dockerfile.dev | ||
|
||
.PHONY: builder | ||
|
@@ -41,22 +44,24 @@ connscrape: | |
unittest: | ||
make -C collector unittest | ||
|
||
image: collector unittest | ||
image: | ||
make -C collector txt-files | ||
docker buildx build --load --platform ${PLATFORM} \ | ||
--build-arg BUILD_TYPE="$(BUILD_TYPE)" \ | ||
--build-arg CMAKE_BUILD_TYPE="$(CMAKE_BUILD_TYPE)" \ | ||
--build-arg USE_VALGRIND="$(USE_VALGRIND)" \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does USE_VALGRIND even do anything now that the wrapper script has been removed? If it doesn't, it would be nice to make it work in another PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It disables profiling here. Think that was due to tcmalloc not being compatible with valgrind because they both overwrite the malloc implementation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how I missed this when I wrote my answer, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked at the valgrind unit tests. Valgrind found many errors, but the test passed. They all seemed to have to do with RE2, so maybe it is not a huge concern. If valgrind finds errors, the test should fail. Or are we ignoring the RE2 errors? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember trying to ignore them but can't remember why I gave up on it, there's a way to set up an ignore file for valgrind (https://valgrind.org/docs/manual/manual-core.html/manual-core.html#manual-core.suppress). I also remember the errors where in a place that would be really hard to actually fix and didn't seem like too big a deal. IIRC, the error was on the initialization of the re2 regexes that Falco does statically, so if it was a serious issue we would see collector crashing at start up. I'm also pretty sure we don't use the regexes. |
||
--build-arg ADDRESS_SANITIZER="$(ADDRESS_SANITIZER)" \ | ||
--build-arg TRACE_SINSP_EVENTS="$(TRACE_SINSP_EVENTS)" \ | ||
--build-arg BPF_DEBUG_MODE="$(BPF_DEBUG_MODE)" \ | ||
--build-arg COLLECTOR_VERSION="$(COLLECTOR_TAG)" \ | ||
-f collector/container/Dockerfile \ | ||
--build-arg BUILDER_TAG="$(COLLECTOR_BUILDER_TAG)" \ | ||
-f "$(DOCKERFILE)" \ | ||
-t quay.io/stackrox-io/collector:$(COLLECTOR_TAG) \ | ||
$(COLLECTOR_BUILD_CONTEXT) | ||
|
||
image-dev: collector unittest container-dockerfile-dev | ||
make -C collector txt-files | ||
docker buildx build --load --platform ${PLATFORM} \ | ||
--build-arg COLLECTOR_VERSION="$(COLLECTOR_TAG)" \ | ||
--build-arg BUILD_TYPE=devel \ | ||
-f collector/container/Dockerfile.dev \ | ||
-t quay.io/stackrox-io/collector:$(COLLECTOR_TAG) \ | ||
$(COLLECTOR_BUILD_CONTEXT) | ||
image-dev: DOCKERFILE = collector/container/Dockerfile.dev | ||
image-dev: BUILD_TYPE = devel | ||
image-dev: container-dockerfile-dev image | ||
|
||
.PHONY: integration-tests-report | ||
integration-tests-report: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,45 +5,10 @@ NPROCS ?= $(shell nproc) | |
|
||
CMAKE_BASE_DIR = cmake-build | ||
CMAKE_DIR= $(BASE_PATH)/$(CMAKE_BASE_DIR) | ||
COLLECTOR_BIN_DIR = $(CMAKE_DIR)/collector | ||
LIBSINSP_BIN_DIR = $(CMAKE_DIR)/collector/EXCLUDE_FROM_DEFAULT_BUILD/libsinsp | ||
SRC_MOUNT_DIR = /tmp/collector | ||
|
||
HDRS := $(wildcard lib/*.h) $(shell find $(BASE_PATH)/falcosecurity-libs/userspace -name '*.h') | ||
|
||
SRCS := $(wildcard lib/*.cpp) collector.cpp | ||
|
||
COLLECTOR_BUILD_DEPS := $(HDRS) $(SRCS) $(shell find $(BASE_PATH)/falcosecurity-libs -name '*.h' -o -name '*.cpp' -o -name '*.c') | ||
|
||
.SUFFIXES: | ||
|
||
cmake-configure/collector: | ||
docker exec $(COLLECTOR_BUILDER_NAME) \ | ||
cmake -S $(BASE_PATH) -B $(CMAKE_DIR) \ | ||
-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \ | ||
-DDISABLE_PROFILING=$(DISABLE_PROFILING) \ | ||
-DUSE_VALGRIND=$(USE_VALGRIND) \ | ||
-DADDRESS_SANITIZER=$(ADDRESS_SANITIZER) \ | ||
-DTRACE_SINSP_EVENTS=$(TRACE_SINSP_EVENTS) \ | ||
-DBPF_DEBUG_MODE=$(BPF_DEBUG_MODE) \ | ||
-DCOLLECTOR_VERSION=$(COLLECTOR_VERSION) | ||
|
||
cmake-build/collector: cmake-configure/collector $(COLLECTOR_BUILD_DEPS) | ||
docker exec $(COLLECTOR_BUILDER_NAME) \ | ||
cmake --build $(CMAKE_DIR) -- -j $(NPROCS) | ||
docker exec $(COLLECTOR_BUILDER_NAME) \ | ||
bash -c "[ $(CMAKE_BUILD_TYPE) == Release ] && strip --strip-unneeded $(COLLECTOR_BIN_DIR)/collector || exit 0" | ||
|
||
container/bin/collector: cmake-build/collector | ||
mkdir -p container/bin | ||
cp "$(COLLECTOR_BIN_DIR)/collector" container/bin/collector | ||
cp "$(COLLECTOR_BIN_DIR)/self-checks" container/bin/self-checks | ||
|
||
.PHONY: collector | ||
collector: container/bin/collector txt-files | ||
mkdir -p container/libs | ||
docker cp $(COLLECTOR_BUILDER_NAME):/THIRD_PARTY_NOTICES/ container/ | ||
|
||
.PHONY: build-connscrape-test | ||
build-connscrape-test: | ||
docker build -f $(CURDIR)/connscrape-test/Dockerfile -t connscrape-test $(CURDIR)/connscrape-test | ||
|
@@ -54,7 +19,7 @@ connscrape: build-connscrape-test | |
-v "$(BASE_PATH):$(SRC_MOUNT_DIR)" \ | ||
connscrape-test "$(SRC_MOUNT_DIR)/collector/connscrape-test/connscrape-test.sh" | ||
|
||
unittest: collector | ||
unittest: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This target should still work, but you'll need to exec into the image and run cmake/make yourself, at that point you should be able to directly run ctest though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That does not seem convenient. I should be able to run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, I would rather just remove the target altogether, I just thought leaving it could be nice. IMO, running the unit tests should be done by exec'ing into the container from a terminal anyways, |
||
docker exec $(COLLECTOR_BUILDER_NAME) \ | ||
ctest -V --test-dir $(CMAKE_DIR) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we move the definition of the project to the
collector/CMakeLists.txt
file and move the falco directory into collector/ as well, we should be able to directly use that directory as the context for the image build. However, when I tried it, it give me a weird error locally and I don't want this PR to get out of hand, so we could consider doing that in a follow up.