From 5c77e0ef369ee9ea60e2cdc1f8a6847e47554133 Mon Sep 17 00:00:00 2001 From: dervoeti Date: Fri, 17 Oct 2025 16:26:05 +0200 Subject: [PATCH 1/7] feat: patch logback in NiFi 2.4.0 build --- nifi/Dockerfile | 7 ++++ nifi/boil-config.toml | 1 + shared/logback/Dockerfile | 23 +++++++++++ shared/logback/boil-config.toml | 2 + ...uilder-into-function-to-prevent-race.patch | 38 +++++++++++++++++++ .../stackable/patches/1.5.18/patchable.toml | 2 + .../logback/stackable/patches/patchable.toml | 2 + 7 files changed, 75 insertions(+) create mode 100644 shared/logback/Dockerfile create mode 100644 shared/logback/boil-config.toml create mode 100644 shared/logback/stackable/patches/1.5.18/0001-fix-move-StringBuilder-into-function-to-prevent-race.patch create mode 100644 shared/logback/stackable/patches/1.5.18/patchable.toml create mode 100644 shared/logback/stackable/patches/patchable.toml diff --git a/nifi/Dockerfile b/nifi/Dockerfile index 462f66afd..5235a8b4e 100644 --- a/nifi/Dockerfile +++ b/nifi/Dockerfile @@ -5,6 +5,8 @@ ARG GIT_SYNC_VERSION FROM oci.stackable.tech/sdp/git-sync/git-sync:${GIT_SYNC_VERSION} AS git-sync-image +FROM local-image/shared/logback AS patched-logback + FROM local-image/java-devel AS nifi-builder ARG PRODUCT_VERSION @@ -23,8 +25,12 @@ WORKDIR /stackable COPY --chown=${STACKABLE_USER_UID}:0 nifi/stackable/patches/patchable.toml /stackable/src/nifi/stackable/patches/patchable.toml COPY --chown=${STACKABLE_USER_UID}:0 nifi/stackable/patches/${PRODUCT_VERSION} /stackable/src/nifi/stackable/patches/${PRODUCT_VERSION} COPY --chown=${STACKABLE_USER_UID}:0 --from=git-sync-image /git-sync /stackable/git-sync +COPY --chown=${STACKABLE_USER_UID}:0 --from=patched-logback /stackable/.m2/repository /stackable/patched-logback-libs RUN < +Date: Fri, 17 Oct 2025 12:07:51 +0200 +Subject: fix: move StringBuilder into function to prevent race conditions + +--- + .../java/ch/qos/logback/classic/log4j/XMLLayout.java | 10 +--------- + 1 file changed, 1 insertion(+), 9 deletions(-) + +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 +index 4bc04388a..405f4ef26 100644 +--- 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 +@@ -38,9 +38,7 @@ import ch.qos.logback.core.helpers.Transform; + public class XMLLayout extends LayoutBase { + + private final int DEFAULT_SIZE = 256; +- private final int UPPER_LIMIT = 2048; + +- private StringBuilder buf = new StringBuilder(DEFAULT_SIZE); + private boolean locationInfo = false; + private boolean properties = false; + +@@ -96,13 +94,7 @@ public class XMLLayout extends LayoutBase { + */ + public String doLayout(ILoggingEvent event) { + +- // Reset working buffer. If the buffer is too large, then we need a new +- // one in order to avoid the penalty of creating a large array. +- if (buf.capacity() > UPPER_LIMIT) { +- buf = new StringBuilder(DEFAULT_SIZE); +- } else { +- buf.setLength(0); +- } ++ StringBuilder buf = new StringBuilder(DEFAULT_SIZE); + + // We yield to the \r\n heresy. + diff --git a/shared/logback/stackable/patches/1.5.18/patchable.toml b/shared/logback/stackable/patches/1.5.18/patchable.toml new file mode 100644 index 000000000..01153d924 --- /dev/null +++ b/shared/logback/stackable/patches/1.5.18/patchable.toml @@ -0,0 +1,2 @@ +mirror = "https://github.com/stackabletech/logback.git" +base = "b2a02f065379a9b1ba5ff837fc08913b744774bc" diff --git a/shared/logback/stackable/patches/patchable.toml b/shared/logback/stackable/patches/patchable.toml new file mode 100644 index 000000000..fb98269ec --- /dev/null +++ b/shared/logback/stackable/patches/patchable.toml @@ -0,0 +1,2 @@ +upstream = "https://github.com/qos-ch/logback.git" +default-mirror = "https://github.com/stackabletech/logback.git" From 1764492903f2d1c7371b60615242b9b75b4e22af Mon Sep 17 00:00:00 2001 From: dervoeti Date: Wed, 22 Oct 2025 10:55:25 +0200 Subject: [PATCH 2/7] fix: pin esbuild to fix NiFi 2.6.0 build --- .../0005-fix-pin-esbuild-to-0.25.10.patch | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-0.25.10.patch diff --git a/nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-0.25.10.patch b/nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-0.25.10.patch new file mode 100644 index 000000000..92449f906 --- /dev/null +++ b/nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-0.25.10.patch @@ -0,0 +1,30 @@ +From e95b46e9dafe152f8a98ac711dab194a45ac4840 Mon Sep 17 00:00:00 2001 +From: dervoeti +Date: Wed, 22 Oct 2025 08:58:51 +0200 +Subject: fix: pin esbuild to 0.25.10 + +--- + nifi-frontend/src/main/frontend/package.json | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/nifi-frontend/src/main/frontend/package.json b/nifi-frontend/src/main/frontend/package.json +index ee125e7663..0ee062fcfc 100644 +--- a/nifi-frontend/src/main/frontend/package.json ++++ b/nifi-frontend/src/main/frontend/package.json +@@ -87,6 +87,7 @@ + "@typescript-eslint/utils": "7.18.0", + "autoprefixer": "^10.4.16", + "env-cmd": "^10.1.0", ++ "esbuild": "0.25.10", + "eslint": "8.57.0", + "eslint-config-prettier": "10.1.1", + "eslint-plugin-prettier": "^5.0.1", +@@ -114,7 +115,7 @@ + "vite": "^5.4.6", + "underscore": "1.13.6", + "rollup": "4.22.4", +- "esbuild": "^0.25.8", ++ "esbuild": "0.25.10", + "koa": "^2.16.1" + }, + "overrides": { From 007359728834c1968ea59f32e59b24abbce6cea2 Mon Sep 17 00:00:00 2001 From: dervoeti Date: Wed, 22 Oct 2025 10:55:45 +0200 Subject: [PATCH 3/7] feat: include the logback patch in NiFi 2.6.0 --- nifi/boil-config.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/nifi/boil-config.toml b/nifi/boil-config.toml index cac8b4085..120633900 100644 --- a/nifi/boil-config.toml +++ b/nifi/boil-config.toml @@ -35,6 +35,7 @@ nifi-iceberg-bundle-version = "0.0.5" [versions."2.6.0".local-images] java-base = "21" java-devel = "21" +"shared/logback" = "1.5.18" [versions."2.6.0".build-arguments] git-sync-version = "v4.4.1" From 4ced7641bc44ee1ab67f772a7757f2a209d11148 Mon Sep 17 00:00:00 2001 From: dervoeti Date: Wed, 22 Oct 2025 17:16:00 +0200 Subject: [PATCH 4/7] fix: pin esbuild to fix NiFi 2.6.0 build --- .../0005-fix-pin-esbuild-to-0.25.10.patch | 30 ------------------- ...-pin-esbuild-to-fix-NiFi-2.6.0-build.patch | 28 +++++++++++++++++ 2 files changed, 28 insertions(+), 30 deletions(-) delete mode 100644 nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-0.25.10.patch create mode 100644 nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-fix-NiFi-2.6.0-build.patch diff --git a/nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-0.25.10.patch b/nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-0.25.10.patch deleted file mode 100644 index 92449f906..000000000 --- a/nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-0.25.10.patch +++ /dev/null @@ -1,30 +0,0 @@ -From e95b46e9dafe152f8a98ac711dab194a45ac4840 Mon Sep 17 00:00:00 2001 -From: dervoeti -Date: Wed, 22 Oct 2025 08:58:51 +0200 -Subject: fix: pin esbuild to 0.25.10 - ---- - nifi-frontend/src/main/frontend/package.json | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/nifi-frontend/src/main/frontend/package.json b/nifi-frontend/src/main/frontend/package.json -index ee125e7663..0ee062fcfc 100644 ---- a/nifi-frontend/src/main/frontend/package.json -+++ b/nifi-frontend/src/main/frontend/package.json -@@ -87,6 +87,7 @@ - "@typescript-eslint/utils": "7.18.0", - "autoprefixer": "^10.4.16", - "env-cmd": "^10.1.0", -+ "esbuild": "0.25.10", - "eslint": "8.57.0", - "eslint-config-prettier": "10.1.1", - "eslint-plugin-prettier": "^5.0.1", -@@ -114,7 +115,7 @@ - "vite": "^5.4.6", - "underscore": "1.13.6", - "rollup": "4.22.4", -- "esbuild": "^0.25.8", -+ "esbuild": "0.25.10", - "koa": "^2.16.1" - }, - "overrides": { diff --git a/nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-fix-NiFi-2.6.0-build.patch b/nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-fix-NiFi-2.6.0-build.patch new file mode 100644 index 000000000..548a2e55c --- /dev/null +++ b/nifi/stackable/patches/2.6.0/0005-fix-pin-esbuild-to-fix-NiFi-2.6.0-build.patch @@ -0,0 +1,28 @@ +From 1fe22dcc974b52d83b8288d5279c3aa8c41a1243 Mon Sep 17 00:00:00 2001 +From: dervoeti +Date: Wed, 22 Oct 2025 15:27:29 +0200 +Subject: fix: pin esbuild to fix NiFi 2.6.0 build + +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. +--- + nifi-frontend/src/main/frontend/package.json | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/nifi-frontend/src/main/frontend/package.json b/nifi-frontend/src/main/frontend/package.json +index ee125e7663..6914c5f00c 100644 +--- a/nifi-frontend/src/main/frontend/package.json ++++ b/nifi-frontend/src/main/frontend/package.json +@@ -114,10 +114,11 @@ + "vite": "^5.4.6", + "underscore": "1.13.6", + "rollup": "4.22.4", +- "esbuild": "^0.25.8", ++ "esbuild": "0.25.10", + "koa": "^2.16.1" + }, + "overrides": { +- "koa": "^2.16.1" ++ "koa": "^2.16.1", ++ "esbuild": "0.25.10" + } + } From e2ddf255e1c5f75198e595ed4293dd3d8eb299e6 Mon Sep 17 00:00:00 2001 From: dervoeti Date: Wed, 22 Oct 2025 17:16:52 +0200 Subject: [PATCH 5/7] feat: build NiFi 1.x with the logback fix --- nifi/boil-config.toml | 2 + shared/logback/Dockerfile | 2 +- shared/logback/boil-config.toml | 5 ++- ...uilder-into-function-to-prevent-race.patch | 38 +++++++++++++++++++ .../stackable/patches/1.3.14/patchable.toml | 2 + 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 shared/logback/stackable/patches/1.3.14/0001-fix-move-StringBuilder-into-function-to-prevent-race.patch create mode 100644 shared/logback/stackable/patches/1.3.14/patchable.toml diff --git a/nifi/boil-config.toml b/nifi/boil-config.toml index 120633900..1181a68a4 100644 --- a/nifi/boil-config.toml +++ b/nifi/boil-config.toml @@ -1,6 +1,7 @@ [versions."1.27.0".local-images] java-base = "11" java-devel = "11" +"shared/logback" = "1.3.14" [versions."1.27.0".build-arguments] git-sync-version = "v4.4.1" @@ -11,6 +12,7 @@ nifi-opa-authorizer-plugin-version = "0.3.0" [versions."1.28.1".local-images] java-base = "11" java-devel = "11" +"shared/logback" = "1.3.14" [versions."1.28.1".build-arguments] git-sync-version = "v4.4.1" diff --git a/shared/logback/Dockerfile b/shared/logback/Dockerfile index 6627a9449..8fcd8b03a 100644 --- a/shared/logback/Dockerfile +++ b/shared/logback/Dockerfile @@ -20,4 +20,4 @@ cd "$(/stackable/patchable --images-repo-root=src checkout shared/logback ${PROD tar -czf /stackable/logback-${PRODUCT_VERSION}-src.tar.gz . mvn --batch-mode --no-transfer-progress clean install -DskipTests -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -EOF \ No newline at end of file +EOF diff --git a/shared/logback/boil-config.toml b/shared/logback/boil-config.toml index d02cc73df..206d0206e 100644 --- a/shared/logback/boil-config.toml +++ b/shared/logback/boil-config.toml @@ -1,2 +1,5 @@ +[versions."1.3.14".local-images] +java-devel = "21" + [versions."1.5.18".local-images] -java-devel = "21" \ No newline at end of file +java-devel = "21" diff --git a/shared/logback/stackable/patches/1.3.14/0001-fix-move-StringBuilder-into-function-to-prevent-race.patch b/shared/logback/stackable/patches/1.3.14/0001-fix-move-StringBuilder-into-function-to-prevent-race.patch new file mode 100644 index 000000000..0d7ec50e1 --- /dev/null +++ b/shared/logback/stackable/patches/1.3.14/0001-fix-move-StringBuilder-into-function-to-prevent-race.patch @@ -0,0 +1,38 @@ +From 2ee74eaf5645576ec0a604941591c9ae09a92a43 Mon Sep 17 00:00:00 2001 +From: dervoeti +Date: Wed, 22 Oct 2025 11:13:02 +0200 +Subject: fix: move StringBuilder into function to prevent race conditions + +--- + .../java/ch/qos/logback/classic/log4j/XMLLayout.java | 10 +--------- + 1 file changed, 1 insertion(+), 9 deletions(-) + +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 +index 4bc04388a..405f4ef26 100644 +--- 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 +@@ -38,9 +38,7 @@ import ch.qos.logback.core.helpers.Transform; + public class XMLLayout extends LayoutBase { + + private final int DEFAULT_SIZE = 256; +- private final int UPPER_LIMIT = 2048; + +- private StringBuilder buf = new StringBuilder(DEFAULT_SIZE); + private boolean locationInfo = false; + private boolean properties = false; + +@@ -96,13 +94,7 @@ public class XMLLayout extends LayoutBase { + */ + public String doLayout(ILoggingEvent event) { + +- // Reset working buffer. If the buffer is too large, then we need a new +- // one in order to avoid the penalty of creating a large array. +- if (buf.capacity() > UPPER_LIMIT) { +- buf = new StringBuilder(DEFAULT_SIZE); +- } else { +- buf.setLength(0); +- } ++ StringBuilder buf = new StringBuilder(DEFAULT_SIZE); + + // We yield to the \r\n heresy. + diff --git a/shared/logback/stackable/patches/1.3.14/patchable.toml b/shared/logback/stackable/patches/1.3.14/patchable.toml new file mode 100644 index 000000000..a33d0f790 --- /dev/null +++ b/shared/logback/stackable/patches/1.3.14/patchable.toml @@ -0,0 +1,2 @@ +mirror = "https://github.com/stackabletech/logback.git" +base = "39fc5461e7a8e15ce9ecd9f148f67f701aed88ad" From 6ed110af30e4def663961e876935c2d385107679 Mon Sep 17 00:00:00 2001 From: dervoeti Date: Thu, 23 Oct 2025 10:28:40 +0200 Subject: [PATCH 6/7] chore: changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfd854865..c77255a35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ All notable changes to this project will be documented in this file. - hbase: replace `sed` calls with `config-utils template` where possible ([#1301]). - superset: Fix the 4.1.2 build when building from source ([#1309]) - superset: Pin `luxon` to version 3.6.1 to fix build ([#1315]) +- nifi: Use a patched version of logback to fix corrupted logs ([#1314]) ### Fixed @@ -107,6 +108,7 @@ All notable changes to this project will be documented in this file. [#1308]: https://github.com/stackabletech/docker-images/pull/1308 [#1309]: https://github.com/stackabletech/docker-images/pull/1309 [#1311]: https://github.com/stackabletech/docker-images/pull/1311 +[#1314]: https://github.com/stackabletech/docker-images/pull/1314 [#1315]: https://github.com/stackabletech/docker-images/pull/1315 ## [25.7.0] - 2025-07-23 From dc6ce5661562937dfb6cb04adf4051b6a71564ab Mon Sep 17 00:00:00 2001 From: Nick <10092581+NickLarsenNZ@users.noreply.github.com> Date: Thu, 23 Oct 2025 10:39:08 +0200 Subject: [PATCH 7/7] Apply suggestions from code review --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 867063f6b..dd5e5c99b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,7 +49,7 @@ All notable changes to this project will be documented in this file. - hbase: move hbck2.env to hbase-operator-tools image and add log4j2 properties for this tool ([#1300]). - hbase: replace `sed` calls with `config-utils template` where possible ([#1301]). - superset: Fix the 4.1.2 build when building from source ([#1309]) -- superset: Pin `luxon` to version 3.6.1 to fix build ([#1315]) +- superset: Pin `luxon` to version 3.6.1 to fix build ([#1315], [#1316]) - nifi: Use a patched version of logback to fix corrupted logs ([#1314]) ### Fixed