Skip to content
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

Remove bootstrap.sh and collector-wrapper.sh #1814

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions collector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ if(NOT BPF_DEBUG_MODE)
set(BPF_DEBUG_MODE OFF)
endif()

if (NOT COLLECTOR_VERSION)
set(COLLECTOR_VERSION "0.0.0")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/Version.h)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious about when this gets reevaluated. For instance, in a dev environment, is the Collector version going to remain the same until the project is reconfigured ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the cmake docs:

If the input file is modified the build system will re-run CMake to re-configure the file and generate the build system again. The generated file is modified and its timestamp updated on subsequent cmake runs only if its content is changed.

So it will retrigger if you change the file or manually re-run cmake. The way we use it right now running with our make files, this file gets re-created on every make image call.


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

add_subdirectory(${PROJECT_SOURCE_DIR}/proto)
Expand All @@ -43,6 +49,7 @@ include_directories(${FALCO_DIR}/userspace/libsinsp)
include_directories(${FALCO_DIR}/userspace/chisel)
include_directories(${FALCO_DIR}/userspace/common)
include_directories(${PROJECT_BINARY_DIR}/EXCLUDE_FROM_DEFAULT_BUILD/common)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(/usr/local/include)
include_directories(/usr/local/include/tbb)
include_directories(/usr/local/include/jsoncpp)
Expand Down
3 changes: 2 additions & 1 deletion collector/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ cmake-configure/collector:
-DUSE_VALGRIND=$(USE_VALGRIND) \
-DADDRESS_SANITIZER=$(ADDRESS_SANITIZER) \
-DTRACE_SINSP_EVENTS=$(TRACE_SINSP_EVENTS) \
-DBPF_DEBUG_MODE=$(BPF_DEBUG_MODE)
-DBPF_DEBUG_MODE=$(BPF_DEBUG_MODE) \
-DCOLLECTOR_VERSION=$(COLLECTOR_VERSION)

cmake-build/collector: cmake-configure/collector $(COLLECTOR_BUILD_DEPS)
docker exec $(COLLECTOR_BUILDER_NAME) \
Expand Down
10 changes: 10 additions & 0 deletions collector/Version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef _VERSION_H_
#define _VERSION_H_

#define COLLECTOR_VERSION "${COLLECTOR_VERSION}"

inline const char* GetCollectorVersion() {
return COLLECTOR_VERSION;
}

#endif // _VERSION_H_
7 changes: 7 additions & 0 deletions collector/collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern "C" {
#include "LogLevel.h"
#include "Logging.h"
#include "Utility.h"
#include "Version.h"

static const int MAX_GRPC_CONNECTION_POLLS = 30;

Expand Down Expand Up @@ -123,6 +124,12 @@ void initialChecks() {
}

int main(int argc, char** argv) {
// Print system information before doing actual work.
auto& host_info = HostInfo::Instance();
CLOG(INFO) << "Collector Version: " << GetCollectorVersion();
CLOG(INFO) << "OS: " << host_info.GetDistro();
CLOG(INFO) << "Kernel Version: " << host_info.GetKernelVersion().GetRelease();

initialChecks();

CollectorArgs* args = CollectorArgs::getInstance();
Expand Down
12 changes: 4 additions & 8 deletions collector/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ARG ROOT_DIR=.
ARG COLLECTOR_VERSION

ENV ROOT_DIR=$ROOT_DIR
ENV COLLECTOR_VERSION="${COLLECTOR_VERSION}"
ENV COLLECTOR_HOST_ROOT=/host

LABEL name="collector" \
Expand All @@ -20,16 +19,15 @@ WORKDIR /
COPY container/${BUILD_TYPE}/install.sh /
RUN ./install.sh && rm -f install.sh

COPY container/scripts/collector-wrapper.sh /usr/local/bin
COPY container/scripts/bootstrap.sh /
# Uncomment this line to enable generation of core for collector
# RUN echo '/core/core.%e.%p.%t' > /proc/sys/kernel/core_pattern

COPY container/THIRD_PARTY_NOTICES/ /THIRD_PARTY_NOTICES/
COPY kernel-modules /kernel-modules
COPY container/bin/collector /usr/local/bin/
COPY container/bin/self-checks /usr/local/bin/self-checks
COPY container/status-check.sh /usr/local/bin/status-check.sh

RUN chmod 700 bootstrap.sh

EXPOSE 8080 9090

HEALTHCHECK \
Expand All @@ -40,9 +38,7 @@ HEALTHCHECK \
# the command uses /ready API
CMD /usr/local/bin/status-check.sh

ENTRYPOINT ["/bootstrap.sh"]

CMD collector-wrapper.sh \
ENTRYPOINT collector \
--collector-config=$COLLECTOR_CONFIG \
--collection-method=$COLLECTION_METHOD \
--grpc-server=$GRPC_SERVER
9 changes: 2 additions & 7 deletions collector/container/konflux.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,18 @@ LABEL \
ARG BUILD_DIR
ARG CMAKE_BUILD_DIR

ENV COLLECTOR_VERSION="${COLLECTOR_TAG}"
ENV COLLECTOR_HOST_ROOT=/host

COPY --from=builder ${CMAKE_BUILD_DIR}/collector/collector /usr/local/bin/
COPY --from=builder ${CMAKE_BUILD_DIR}/collector/self-checks /usr/local/bin/
COPY --from=builder ${BUILD_DIR}/collector/container/scripts /

RUN mv /collector-wrapper.sh /usr/local/bin/ && \
chmod 700 bootstrap.sh && \
echo '/usr/local/lib' > /etc/ld.so.conf.d/usrlocallib.conf && \
RUN echo '/usr/local/lib' > /etc/ld.so.conf.d/usrlocallib.conf && \
ldconfig

EXPOSE 8080 9090

ENTRYPOINT ["/bootstrap.sh"]

CMD collector-wrapper.sh \
ENTRYPOINT collector \
--collector-config=$COLLECTOR_CONFIG \
--collection-method=$COLLECTION_METHOD \
--grpc-server=$GRPC_SERVER
Expand Down
91 changes: 0 additions & 91 deletions collector/container/scripts/bootstrap.sh

This file was deleted.

5 changes: 0 additions & 5 deletions collector/container/scripts/collector-wrapper.sh

This file was deleted.

5 changes: 5 additions & 0 deletions collector/lib/HostInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ struct KernelVersion {
return ss.str();
}

// Same output as calling `uname -r` in the shell
const std::string& GetRelease() {
return release;
}

// the kernel version
int kernel;
// the kernel major version
Expand Down
Loading