Skip to content

Commit 991e614

Browse files
fix: logback fix for NiFi / NiFi 2.6 build fix (#1314)
* feat: patch logback in NiFi 2.4.0 build * fix: pin esbuild to fix NiFi 2.6.0 build * feat: include the logback patch in NiFi 2.6.0 * fix: pin esbuild to fix NiFi 2.6.0 build * feat: build NiFi 1.x with the logback fix * chore: changelog * Apply suggestions from code review --------- Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
1 parent d38c369 commit 991e614

11 files changed

+151
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ All notable changes to this project will be documented in this file.
5050
- hbase: replace `sed` calls with `config-utils template` where possible ([#1301]).
5151
- superset: Fix the 4.1.2 build when building from source ([#1309])
5252
- superset: Pin `luxon` to version 3.6.1 to fix build ([#1315], [#1316])
53+
- nifi: Use a patched version of logback to fix corrupted logs ([#1314])
5354

5455
### Fixed
5556

@@ -107,6 +108,7 @@ All notable changes to this project will be documented in this file.
107108
[#1308]: https://github.com/stackabletech/docker-images/pull/1308
108109
[#1309]: https://github.com/stackabletech/docker-images/pull/1309
109110
[#1311]: https://github.com/stackabletech/docker-images/pull/1311
111+
[#1314]: https://github.com/stackabletech/docker-images/pull/1314
110112
[#1315]: https://github.com/stackabletech/docker-images/pull/1315
111113
[#1316]: https://github.com/stackabletech/docker-images/pull/1316
112114

nifi/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ ARG GIT_SYNC_VERSION
55

66
FROM oci.stackable.tech/sdp/git-sync/git-sync:${GIT_SYNC_VERSION} AS git-sync-image
77

8+
FROM local-image/shared/logback AS patched-logback
9+
810
FROM local-image/java-devel AS nifi-builder
911

1012
ARG PRODUCT_VERSION
@@ -23,8 +25,12 @@ WORKDIR /stackable
2325
COPY --chown=${STACKABLE_USER_UID}:0 nifi/stackable/patches/patchable.toml /stackable/src/nifi/stackable/patches/patchable.toml
2426
COPY --chown=${STACKABLE_USER_UID}:0 nifi/stackable/patches/${PRODUCT_VERSION} /stackable/src/nifi/stackable/patches/${PRODUCT_VERSION}
2527
COPY --chown=${STACKABLE_USER_UID}:0 --from=git-sync-image /git-sync /stackable/git-sync
28+
COPY --chown=${STACKABLE_USER_UID}:0 --from=patched-logback /stackable/.m2/repository /stackable/patched-logback-libs
2629

2730
RUN <<EOF
31+
mkdir -p /stackable/.m2/repository
32+
cp -r /stackable/patched-logback-libs/* /stackable/.m2/repository
33+
2834
# This used to be located in /bin/stackable-bcrypt.jar. We create a softlink for /bin/stackable-bcrypt.jar in the main container for backwards compatibility.
2935
curl 'https://repo.stackable.tech/repository/m2/tech/stackable/nifi/stackable-bcrypt/1.0-SNAPSHOT/stackable-bcrypt-1.0-20240508.153334-1-jar-with-dependencies.jar' \
3036
-o /stackable/stackable-bcrypt.jar
@@ -185,6 +191,7 @@ COPY --chown=${STACKABLE_USER_UID}:0 --from=nifi-iceberg-bundle-builder /stackab
185191
COPY --chown=${STACKABLE_USER_UID}:0 --from=nifi-iceberg-bundle-builder /stackable/*.cdx.json /stackable/nifi-${PRODUCT_VERSION}-stackable${RELEASE_VERSION}/lib/
186192
COPY --chown=${STACKABLE_USER_UID}:0 --from=nifi-iceberg-bundle-builder /stackable/*-src.tar.gz /stackable
187193
COPY --chown=${STACKABLE_USER_UID}:0 --from=nifi-builder /stackable/git-sync /stackable/git-sync
194+
COPY --chown=${STACKABLE_USER_UID}:0 --from=patched-logback /stackable/*-src.tar.gz /stackable
188195

189196
COPY --chown=${STACKABLE_USER_UID}:0 --from=opa-authorizer-builder /stackable/opa-authorizer.nar /stackable/nifi-${PRODUCT_VERSION}-stackable${RELEASE_VERSION}/extensions/opa-authorizer.nar
190197
COPY --chown=${STACKABLE_USER_UID}:0 --from=opa-authorizer-builder /stackable/nifi-opa-plugin-${NIFI_OPA_AUTHORIZER_PLUGIN_VERSION}-src.tar.gz /stackable

nifi/boil-config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[versions."1.27.0".local-images]
22
java-base = "11"
33
java-devel = "11"
4+
"shared/logback" = "1.3.14"
45

56
[versions."1.27.0".build-arguments]
67
git-sync-version = "v4.4.1"
@@ -11,6 +12,7 @@ nifi-opa-authorizer-plugin-version = "0.3.0"
1112
[versions."1.28.1".local-images]
1213
java-base = "11"
1314
java-devel = "11"
15+
"shared/logback" = "1.3.14"
1416

1517
[versions."1.28.1".build-arguments]
1618
git-sync-version = "v4.4.1"
@@ -21,6 +23,7 @@ nifi-opa-authorizer-plugin-version = "0.3.0"
2123
[versions."2.4.0".local-images]
2224
java-base = "21"
2325
java-devel = "21"
26+
"shared/logback" = "1.5.18"
2427

2528
[versions."2.4.0".build-arguments]
2629
git-sync-version = "v4.4.1"
@@ -34,6 +37,7 @@ nifi-iceberg-bundle-version = "0.0.5"
3437
[versions."2.6.0".local-images]
3538
java-base = "21"
3639
java-devel = "21"
40+
"shared/logback" = "1.5.18"
3741

3842
[versions."2.6.0".build-arguments]
3943
git-sync-version = "v4.4.1"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From 1fe22dcc974b52d83b8288d5279c3aa8c41a1243 Mon Sep 17 00:00:00 2001
2+
From: dervoeti <lukas.krug@stackable.tech>
3+
Date: Wed, 22 Oct 2025 15:27:29 +0200
4+
Subject: fix: pin esbuild to fix NiFi 2.6.0 build
5+
6+
For some reason, npm tries to use a newer version of esbuild than the version in the lock file. I suspect this might be related to how npm handles optional dependencies in lock files. The esbuild version is set to 0.25.10 now to prevent npm from trying to select a newer version, so that the same packages as in the original NiFi build are used.
7+
---
8+
nifi-frontend/src/main/frontend/package.json | 5 +++--
9+
1 file changed, 3 insertions(+), 2 deletions(-)
10+
11+
diff --git a/nifi-frontend/src/main/frontend/package.json b/nifi-frontend/src/main/frontend/package.json
12+
index ee125e7663..6914c5f00c 100644
13+
--- a/nifi-frontend/src/main/frontend/package.json
14+
+++ b/nifi-frontend/src/main/frontend/package.json
15+
@@ -114,10 +114,11 @@
16+
"vite": "^5.4.6",
17+
"underscore": "1.13.6",
18+
"rollup": "4.22.4",
19+
- "esbuild": "^0.25.8",
20+
+ "esbuild": "0.25.10",
21+
"koa": "^2.16.1"
22+
},
23+
"overrides": {
24+
- "koa": "^2.16.1"
25+
+ "koa": "^2.16.1",
26+
+ "esbuild": "0.25.10"
27+
}
28+
}

shared/logback/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1.15.1@sha256:9857836c9ee4268391bb5b09f9f157f3c91bb15821bb77969642813b0d00518d
2+
# check=error=true
3+
4+
FROM local-image/java-devel AS builder
5+
6+
ARG PRODUCT_VERSION
7+
ARG RELEASE_VERSION
8+
ARG STACKABLE_USER_UID
9+
10+
COPY --chown=${STACKABLE_USER_UID}:0 shared/logback/stackable/patches/patchable.toml /stackable/src/shared/logback/stackable/patches/patchable.toml
11+
COPY --chown=${STACKABLE_USER_UID}:0 shared/logback/stackable/patches/${PRODUCT_VERSION} /stackable/src/shared/logback/stackable/patches/${PRODUCT_VERSION}
12+
13+
USER ${STACKABLE_USER_UID}
14+
WORKDIR /stackable
15+
16+
RUN <<EOF
17+
cd "$(/stackable/patchable --images-repo-root=src checkout shared/logback ${PRODUCT_VERSION})"
18+
19+
# Create snapshot of the source code including custom patches
20+
tar -czf /stackable/logback-${PRODUCT_VERSION}-src.tar.gz .
21+
22+
mvn --batch-mode --no-transfer-progress clean install -DskipTests -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
23+
EOF

shared/logback/boil-config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[versions."1.3.14".local-images]
2+
java-devel = "21"
3+
4+
[versions."1.5.18".local-images]
5+
java-devel = "21"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 2ee74eaf5645576ec0a604941591c9ae09a92a43 Mon Sep 17 00:00:00 2001
2+
From: dervoeti <lukas.krug@stackable.tech>
3+
Date: Wed, 22 Oct 2025 11:13:02 +0200
4+
Subject: fix: move StringBuilder into function to prevent race conditions
5+
6+
---
7+
.../java/ch/qos/logback/classic/log4j/XMLLayout.java | 10 +---------
8+
1 file changed, 1 insertion(+), 9 deletions(-)
9+
10+
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java b/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
11+
index 4bc04388a..405f4ef26 100644
12+
--- a/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
13+
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
14+
@@ -38,9 +38,7 @@ import ch.qos.logback.core.helpers.Transform;
15+
public class XMLLayout extends LayoutBase<ILoggingEvent> {
16+
17+
private final int DEFAULT_SIZE = 256;
18+
- private final int UPPER_LIMIT = 2048;
19+
20+
- private StringBuilder buf = new StringBuilder(DEFAULT_SIZE);
21+
private boolean locationInfo = false;
22+
private boolean properties = false;
23+
24+
@@ -96,13 +94,7 @@ public class XMLLayout extends LayoutBase<ILoggingEvent> {
25+
*/
26+
public String doLayout(ILoggingEvent event) {
27+
28+
- // Reset working buffer. If the buffer is too large, then we need a new
29+
- // one in order to avoid the penalty of creating a large array.
30+
- if (buf.capacity() > UPPER_LIMIT) {
31+
- buf = new StringBuilder(DEFAULT_SIZE);
32+
- } else {
33+
- buf.setLength(0);
34+
- }
35+
+ StringBuilder buf = new StringBuilder(DEFAULT_SIZE);
36+
37+
// We yield to the \r\n heresy.
38+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mirror = "https://github.com/stackabletech/logback.git"
2+
base = "39fc5461e7a8e15ce9ecd9f148f67f701aed88ad"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 174aa552f3f1fc03dcce3b37f24993b77b90ab71 Mon Sep 17 00:00:00 2001
2+
From: dervoeti <lukas.krug@stackable.tech>
3+
Date: Fri, 17 Oct 2025 12:07:51 +0200
4+
Subject: fix: move StringBuilder into function to prevent race conditions
5+
6+
---
7+
.../java/ch/qos/logback/classic/log4j/XMLLayout.java | 10 +---------
8+
1 file changed, 1 insertion(+), 9 deletions(-)
9+
10+
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java b/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
11+
index 4bc04388a..405f4ef26 100644
12+
--- a/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
13+
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
14+
@@ -38,9 +38,7 @@ import ch.qos.logback.core.helpers.Transform;
15+
public class XMLLayout extends LayoutBase<ILoggingEvent> {
16+
17+
private final int DEFAULT_SIZE = 256;
18+
- private final int UPPER_LIMIT = 2048;
19+
20+
- private StringBuilder buf = new StringBuilder(DEFAULT_SIZE);
21+
private boolean locationInfo = false;
22+
private boolean properties = false;
23+
24+
@@ -96,13 +94,7 @@ public class XMLLayout extends LayoutBase<ILoggingEvent> {
25+
*/
26+
public String doLayout(ILoggingEvent event) {
27+
28+
- // Reset working buffer. If the buffer is too large, then we need a new
29+
- // one in order to avoid the penalty of creating a large array.
30+
- if (buf.capacity() > UPPER_LIMIT) {
31+
- buf = new StringBuilder(DEFAULT_SIZE);
32+
- } else {
33+
- buf.setLength(0);
34+
- }
35+
+ StringBuilder buf = new StringBuilder(DEFAULT_SIZE);
36+
37+
// We yield to the \r\n heresy.
38+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mirror = "https://github.com/stackabletech/logback.git"
2+
base = "b2a02f065379a9b1ba5ff837fc08913b744774bc"

0 commit comments

Comments
 (0)