From bd25a708823483361d5ea53af23f936375627cf0 Mon Sep 17 00:00:00 2001 From: Misha Sugakov Date: Fri, 31 May 2024 16:54:17 +0200 Subject: [PATCH 1/7] Bump build parallelism to 4 because that's how many cpu cores I gave it in Tekton resource overrides. --- collector/container/konflux.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/container/konflux.Dockerfile b/collector/container/konflux.Dockerfile index 149e178bd7..7d5aa64546 100644 --- a/collector/container/konflux.Dockerfile +++ b/collector/container/konflux.Dockerfile @@ -85,7 +85,7 @@ RUN ./builder/install/install-dependencies.sh && \ -DUSE_VALGRIND=${USE_VALGRIND} \ -DADDRESS_SANITIZER=${ADDRESS_SANITIZER} \ -DTRACE_SINSP_EVENTS=${TRACE_SINSP_EVENTS} && \ - cmake --build ${CMAKE_BUILD_DIR} --target all -- -j "${NPROCS:-2}" && \ + cmake --build ${CMAKE_BUILD_DIR} --target all -- -j "${NPROCS:-4}" && \ ctest -V --test-dir ${CMAKE_BUILD_DIR} && \ strip -v --strip-unneeded "${CMAKE_BUILD_DIR}/collector/collector" From f516409b214aef10818521a8ebff3bc303e280f6 Mon Sep 17 00:00:00 2001 From: Misha Sugakov Date: Fri, 31 May 2024 11:36:09 +0200 Subject: [PATCH 2/7] Inject `version` label and `COLLECTOR_VERSION` env in konflux build --- .tekton/collector-component-pipeline.yaml | 3 +++ collector/container/konflux.Dockerfile | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.tekton/collector-component-pipeline.yaml b/.tekton/collector-component-pipeline.yaml index fb6a55a205..d444505d0f 100644 --- a/.tekton/collector-component-pipeline.yaml +++ b/.tekton/collector-component-pipeline.yaml @@ -238,6 +238,9 @@ spec: value: $(tasks.clone-repository.results.commit) - name: TARGET_STAGE value: $(params.build-target-stage) + - name: BUILD_ARGS + value: + - COLLECTOR_VERSION=$(tasks.determine-image-tag.results.image-tag) runAfter: - prefetch-dependencies - prepare-rhel-rpm-subscriptions diff --git a/collector/container/konflux.Dockerfile b/collector/container/konflux.Dockerfile index 7d5aa64546..a640ed0da2 100644 --- a/collector/container/konflux.Dockerfile +++ b/collector/container/konflux.Dockerfile @@ -116,8 +116,7 @@ FROM scratch COPY --from=rpm-implanter-app /mnt / -# TODO(ROX-20236): configure injection of dynamic version value when it becomes possible. -ARG COLLECTOR_VERSION=0.0.1-todo +ARG COLLECTOR_VERSION WORKDIR / @@ -133,12 +132,13 @@ LABEL \ source-location="https://github.com/stackrox/collector" \ summary="Runtime data collection for Red Hat Advanced Cluster Security for Kubernetes" \ url="https://catalog.redhat.com/software/container-stacks/detail/60eefc88ee05ae7c5b8f041c" \ - version=${COLLECTOR_VERSION} \ + version="$COLLECTOR_VERSION" \ vendor="Red Hat, Inc." ARG BUILD_DIR ARG CMAKE_BUILD_DIR +ENV COLLECTOR_VERSION="$COLLECTOR_VERSION" ENV COLLECTOR_HOST_ROOT=/host COPY kernel-modules/MODULE_VERSION /kernel-modules/MODULE_VERSION.txt From b83a7156e2d72ca6e48c51e64a8fc5c058f6d915 Mon Sep 17 00:00:00 2001 From: Misha Sugakov Date: Fri, 31 May 2024 16:49:19 +0200 Subject: [PATCH 3/7] Externalize parameter for `-fast` suffix --- .tekton/collector-component-pipeline.yaml | 7 +++++++ .tekton/determine-image-tag-task.yaml | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.tekton/collector-component-pipeline.yaml b/.tekton/collector-component-pipeline.yaml index d444505d0f..b3ccf4be63 100644 --- a/.tekton/collector-component-pipeline.yaml +++ b/.tekton/collector-component-pipeline.yaml @@ -53,6 +53,10 @@ spec: - description: Output Image Repository name: output-image-repo type: string + - default: "-fast" + description: Suffix that will be appended to the output image tag. + name: output-tag-suffix + type: string - default: . description: Path to the source code of an application's component from where to build image. @@ -177,6 +181,9 @@ spec: workspace: git-auth - name: determine-image-tag + params: + - name: tag-suffix + value: $(params.output-tag-suffix) runAfter: # This task must run on a freshly cloned repository to prevent seeing any changes from other tasks. - clone-repository diff --git a/.tekton/determine-image-tag-task.yaml b/.tekton/determine-image-tag-task.yaml index 61e4ae152d..9534b45359 100644 --- a/.tekton/determine-image-tag-task.yaml +++ b/.tekton/determine-image-tag-task.yaml @@ -7,6 +7,9 @@ metadata: spec: description: Determines the tag for the output image using the StackRox convention from 'make tag' output. params: + - name: tag-suffix + description: Suffix to append to generated image tag. + type: string results: - name: image-tag description: Image Tag determined by custom logic. @@ -20,7 +23,7 @@ spec: dnf -y install git make cd "$(workspaces.source.path)/source" .konflux/scripts/fail-build-if-git-is-dirty.sh - echo -n "$(make --quiet --no-print-directory tag)-fast" | tee "$(results.image-tag.path)" + echo -n "$(make --quiet --no-print-directory tag)$(params.tag-suffix)" | tee "$(results.image-tag.path)" workspaces: - name: source description: The workspace where source code is included. From 28c185f0650d1ce6155eafb083ade5dee672266d Mon Sep 17 00:00:00 2001 From: Misha Sugakov Date: Fri, 31 May 2024 16:58:49 +0200 Subject: [PATCH 4/7] Rename Dockerfile ARG `COLLECTOR_VERSION` to `COLLECTOR_TAG` Because that's the proper name expected for external override. --- .tekton/collector-component-pipeline.yaml | 2 +- collector/container/konflux.Dockerfile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.tekton/collector-component-pipeline.yaml b/.tekton/collector-component-pipeline.yaml index b3ccf4be63..c01492fac1 100644 --- a/.tekton/collector-component-pipeline.yaml +++ b/.tekton/collector-component-pipeline.yaml @@ -247,7 +247,7 @@ spec: value: $(params.build-target-stage) - name: BUILD_ARGS value: - - COLLECTOR_VERSION=$(tasks.determine-image-tag.results.image-tag) + - COLLECTOR_TAG=$(tasks.determine-image-tag.results.image-tag) runAfter: - prefetch-dependencies - prepare-rhel-rpm-subscriptions diff --git a/collector/container/konflux.Dockerfile b/collector/container/konflux.Dockerfile index a640ed0da2..28b3ab38bc 100644 --- a/collector/container/konflux.Dockerfile +++ b/collector/container/konflux.Dockerfile @@ -116,7 +116,7 @@ FROM scratch COPY --from=rpm-implanter-app /mnt / -ARG COLLECTOR_VERSION +ARG COLLECTOR_TAG WORKDIR / @@ -132,13 +132,13 @@ LABEL \ source-location="https://github.com/stackrox/collector" \ summary="Runtime data collection for Red Hat Advanced Cluster Security for Kubernetes" \ url="https://catalog.redhat.com/software/container-stacks/detail/60eefc88ee05ae7c5b8f041c" \ - version="$COLLECTOR_VERSION" \ + version="$COLLECTOR_TAG" \ vendor="Red Hat, Inc." ARG BUILD_DIR ARG CMAKE_BUILD_DIR -ENV COLLECTOR_VERSION="$COLLECTOR_VERSION" +ENV COLLECTOR_VERSION="$COLLECTOR_TAG" ENV COLLECTOR_HOST_ROOT=/host COPY kernel-modules/MODULE_VERSION /kernel-modules/MODULE_VERSION.txt From 30bbeb5e9146c2ea453c6145c8e00942af24a5b3 Mon Sep 17 00:00:00 2001 From: Misha Sugakov Date: Fri, 31 May 2024 18:04:57 +0200 Subject: [PATCH 5/7] Empty commit to trigger CI From 3476b7b759ed8c7ee436a1c2ede27b4396c62936 Mon Sep 17 00:00:00 2001 From: Misha Sugakov <537715+msugakov@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:07:18 +0200 Subject: [PATCH 6/7] Properly quote ARG Co-authored-by: Tom Martensen --- collector/container/konflux.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/container/konflux.Dockerfile b/collector/container/konflux.Dockerfile index 28b3ab38bc..91594d4dab 100644 --- a/collector/container/konflux.Dockerfile +++ b/collector/container/konflux.Dockerfile @@ -132,7 +132,7 @@ LABEL \ source-location="https://github.com/stackrox/collector" \ summary="Runtime data collection for Red Hat Advanced Cluster Security for Kubernetes" \ url="https://catalog.redhat.com/software/container-stacks/detail/60eefc88ee05ae7c5b8f041c" \ - version="$COLLECTOR_TAG" \ + version="${COLLECTOR_TAG}" \ vendor="Red Hat, Inc." ARG BUILD_DIR From 4fb5f6d62d2025ebba8f91fe2d203aabf59f713f Mon Sep 17 00:00:00 2001 From: Misha Sugakov <537715+msugakov@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:07:31 +0200 Subject: [PATCH 7/7] Properly brace ARG Co-authored-by: Tom Martensen --- collector/container/konflux.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/container/konflux.Dockerfile b/collector/container/konflux.Dockerfile index 91594d4dab..59021338fc 100644 --- a/collector/container/konflux.Dockerfile +++ b/collector/container/konflux.Dockerfile @@ -138,7 +138,7 @@ LABEL \ ARG BUILD_DIR ARG CMAKE_BUILD_DIR -ENV COLLECTOR_VERSION="$COLLECTOR_TAG" +ENV COLLECTOR_VERSION="${COLLECTOR_TAG}" ENV COLLECTOR_HOST_ROOT=/host COPY kernel-modules/MODULE_VERSION /kernel-modules/MODULE_VERSION.txt