Skip to content

Commit 7c13894

Browse files
authored
Local dev fixes (#1826)
add back json array format for collector entrypoint rename collector version file Version.h to CollectorVersion.h to prevent conflicts with libsinsp/version.h on case-insensitive build envs auto-detect platform arch specify arch in builder image name and cmake-dir remove references to COLLECTOR_PRE_ARGUMENTS
1 parent a9d467c commit 7c13894

File tree

13 files changed

+39
-45
lines changed

13 files changed

+39
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ falcosecurity-libs/cmake-build-rhel
1212
kernel-modules/kobuild-tmp
1313
utilities/PerformanceTesting/TestResults
1414
cmake-build/
15+
cmake-build-*/
1516

1617
# Mac OS hidden file
1718
.DS_Store

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ image: collector unittest
5151

5252
image-dev: collector unittest container-dockerfile-dev
5353
make -C collector txt-files
54-
docker build --build-arg collector_version="$(COLLECTOR_TAG)" \
54+
docker buildx build --load --platform ${PLATFORM} \
55+
--build-arg COLLECTOR_VERSION="$(COLLECTOR_TAG)" \
5556
--build-arg BUILD_TYPE=devel \
5657
-f collector/container/Dockerfile.dev \
5758
-t quay.io/stackrox-io/collector:$(COLLECTOR_TAG) \
@@ -99,8 +100,9 @@ teardown-builder:
99100

100101
.PHONY: clean
101102
clean:
102-
rm -rf cmake-build/
103+
rm -rf cmake-build*
103104
make -C collector clean
105+
make -C integration-tests docker-clean
104106

105107
.PHONY: shfmt-check
106108
shfmt-check:

Makefile-constants.mk

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
21
ifeq ($(COLLECTOR_BUILDER_TAG),)
32
COLLECTOR_BUILDER_TAG=master
43
endif
54

65
ifeq ($(COLLECTOR_TAG),)
7-
ifeq ($(CIRCLE_TAG),)
86
COLLECTOR_TAG=$(shell git describe --tags --abbrev=10 --dirty)
9-
else
10-
COLLECTOR_TAG := $(CIRCLE_TAG)
117
endif
8+
9+
DOCKER_CLI := $(shell command -v docker 2>/dev/null)
10+
11+
ifeq ($(DOCKER_CLI),)
12+
$(error "docker is required for building")
1213
endif
1314

15+
HOST_ARCH := $(shell docker system info --format '{{.Architecture}}')
16+
PLATFORM ?= "linux/$(HOST_ARCH)"
17+
1418
USE_VALGRIND ?= false
1519
ADDRESS_SANITIZER ?= false
1620
CMAKE_BUILD_TYPE ?= Release
17-
PLATFORM ?= linux/amd64
21+
CMAKE_BASE_DIR = cmake-build-$(shell echo $(CMAKE_BUILD_TYPE) | tr A-Z a-z)-$(HOST_ARCH)
1822
TRACE_SINSP_EVENTS ?= false
1923
DISABLE_PROFILING ?= false
2024
BPF_DEBUG_MODE ?= false
2125

2226
COLLECTOR_BUILD_CONTEXT = collector/
23-
COLLECTOR_BUILDER_NAME ?= collector_builder
24-
25-
export COLLECTOR_PRE_ARGUMENTS
27+
COLLECTOR_BUILDER_NAME ?= collector_builder_$(HOST_ARCH)

collector/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ if (NOT COLLECTOR_VERSION)
3535
set(COLLECTOR_VERSION "0.0.0")
3636
endif()
3737

38-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/Version.h)
38+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lib/CollectorVersion.h.in ${CMAKE_CURRENT_BINARY_DIR}/CollectorVersion.h)
3939

4040
set(FALCO_DIR ${PROJECT_SOURCE_DIR}/../falcosecurity-libs)
4141

collector/Makefile

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ COLLECTOR_BIN_DIR = $(CMAKE_DIR)/collector
99
LIBSINSP_BIN_DIR = $(CMAKE_DIR)/collector/EXCLUDE_FROM_DEFAULT_BUILD/libsinsp
1010
SRC_MOUNT_DIR = /tmp/collector
1111

12-
HDRS := $(wildcard lib/*.h) $(shell find falcosecurity-libs/userspace -name '*.h')
12+
HDRS := $(wildcard lib/*.h) $(shell find $(BASE_PATH)/falcosecurity-libs/userspace -name '*.h')
1313

1414
SRCS := $(wildcard lib/*.cpp) collector.cpp
1515

16-
COLLECTOR_BUILD_DEPS := $(HDRS) $(SRCS) $(shell find falcosecurity-libs -name '*.h' -o -name '*.cpp' -o -name '*.c')
16+
COLLECTOR_BUILD_DEPS := $(HDRS) $(SRCS) $(shell find $(BASE_PATH)/falcosecurity-libs -name '*.h' -o -name '*.cpp' -o -name '*.c')
1717

1818
.SUFFIXES:
1919

@@ -65,17 +65,8 @@ txt-files:
6565

6666
.PHONY: clean
6767
clean:
68-
docker rm -fv build_collector || true
69-
docker rm -fv container-stats benchmark collector grpc-server || true
70-
rm -rf falcosecurity-libs/cmake-build
71-
rm -rf falcosecurity-libs/falcosecurity-libs-build
68+
rm -rf container/LICENSE-kernel-modules.txt
7269
rm -rf container/bin
73-
rm -rf container/driver
74-
rm -rf container/libs
75-
rm -rf container/rhel/scripts
76-
rm -rf container/rhel/bundle.tar.gz
77-
rm -rf container/devel/scripts
78-
rm -rf container/devel/bundle.tar.gz
7970
rm -rf container/THIRD_PARTY_NOTICES
8071
rm -f container/Dockerfile.dev
8172

collector/collector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extern "C" {
2929
#include "CollectorArgs.h"
3030
#include "CollectorService.h"
3131
#include "CollectorStatsExporter.h"
32+
#include "CollectorVersion.h"
3233
#include "Control.h"
3334
#include "Diagnostics.h"
3435
#include "EventNames.h"
@@ -40,7 +41,6 @@ extern "C" {
4041
#include "LogLevel.h"
4142
#include "Logging.h"
4243
#include "Utility.h"
43-
#include "Version.h"
4444

4545
static const int MAX_GRPC_CONNECTION_POLLS = 30;
4646

collector/container/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ HEALTHCHECK \
3838
# the command uses /ready API
3939
CMD /usr/local/bin/status-check.sh
4040

41-
ENTRYPOINT collector
41+
ENTRYPOINT ["collector"]

collector/container/konflux.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ COPY LICENSE /licenses/LICENSE
153153

154154
EXPOSE 8080 9090
155155

156-
ENTRYPOINT collector
156+
ENTRYPOINT ["collector"]
157157

158158
LABEL \
159159
com.redhat.component="rhacs-collector-container" \
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#ifndef _VERSION_H_
2-
#define _VERSION_H_
1+
#ifndef _COLLECTOR_VERSION_H_
2+
#define _COLLECTOR_VERSION_H_
33

44
#define COLLECTOR_VERSION "${COLLECTOR_VERSION}"
55

66
inline const char* GetCollectorVersion() {
77
return COLLECTOR_VERSION;
88
}
99

10-
#endif // _VERSION_H_
10+
#endif // _COLLECTOR_VERSION_H_

docs/how-to-start.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,18 @@ spec:
209209
- name: COLLECTOR_CONFIG
210210
value: |
211211
'{"tlsConfig":{"caCertPath":"/var/run/secrets/stackrox.io/certs/ca.pem","clientCertPath":"/var/run/secrets/stackrox.io/certs/cert.pem","clientKeyPath":"/var/run/secrets/stackrox.io/certs/key.pem"}}'
212-
# This will direct collector to run under GDB
213-
- name: COLLECTOR_PRE_ARGUMENTS
214-
value: gdbserver 0.0.0.0:1337
215-
image: quay.io/stackrox-io/collector:<your-built-tag-here>
216-
# Expose the port GDB will be listening on
217-
ports:
218-
- containerPort: 1337
219-
name: gdb
220-
protocol: TCP
212+
# Use command and args to override the entrypoint to run under GDB
213+
command:
214+
- gdbserver
215+
- 0.0.0.0:1337
216+
args:
217+
- collector
218+
image: quay.io/stackrox-io/collector:<your-built-tag-here>
219+
# Expose the port GDB will be listening on
220+
ports:
221+
- containerPort: 1337
222+
name: gdb
223+
protocol: TCP
221224
```
222225

223226
Once the configuration is applied, the collector pod will restart and wait for a GDB client to connect to it.

0 commit comments

Comments
 (0)