From 2e7854f62985f1e695de1ce6fc1d76d9e1822249 Mon Sep 17 00:00:00 2001 From: eding Date: Sat, 12 Sep 2026 19:52:36 +0200 Subject: [PATCH] fix: bound static build memory --- catalog/maidn-node-static-image.yaml | 12 ++++++++++++ catalog/test-node-static-image.sh | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/catalog/maidn-node-static-image.yaml b/catalog/maidn-node-static-image.yaml index 8cb35eb..5745bc2 100644 --- a/catalog/maidn-node-static-image.yaml +++ b/catalog/maidn-node-static-image.yaml @@ -91,6 +91,13 @@ spec: value: $(params.target-directory) - name: BUILD_CONFIGURATION value: $(params.build-configuration) + - name: NODE_OPTIONS + value: --max-old-space-size=384 + resources: + requests: + memory: 256Mi + limits: + memory: 512Mi script: | #!/bin/sh set -eu @@ -111,6 +118,11 @@ spec: mkdir -p "$layer_dir/$target_path" cp -R "$OUTPUT_DIRECTORY"/. "$layer_dir/$target_path/" tar -C "$layer_dir" -cf "$SOURCE_PATH/layer.tar" "$target_path" + for memory_peak_path in /sys/fs/cgroup/memory.peak /sys/fs/cgroup/memory/memory.max_usage_in_bytes; do + if [ -r "$memory_peak_path" ] && memory_peak=$(cat "$memory_peak_path"); then + case "$memory_peak" in ''|*[!0-9]*) ;; *) printf 'cgroup memory peak: %s\n' "$memory_peak"; break ;; esac + fi + done --- apiVersion: tekton.dev/v1 kind: Task diff --git a/catalog/test-node-static-image.sh b/catalog/test-node-static-image.sh index d16397c..bc86caa 100644 --- a/catalog/test-node-static-image.sh +++ b/catalog/test-node-static-image.sh @@ -26,7 +26,12 @@ for name in maidn-git-clone maidn-node-static-build maidn-node-static-push; do done grep -qF 'git clone "$REPOSITORY_URL" "$SOURCE_PATH"' "$tmp/maidn-git-clone" -grep -qF 'tar -C "$layer_dir" -cf layer.tar "$target_path"' "$tmp/maidn-node-static-build" +grep -qF 'value: --max-old-space-size=384' "$tmp/maidn-node-static-build" +grep -qF 'memory: 256Mi' "$tmp/maidn-node-static-build" +grep -qF 'memory: 512Mi' "$tmp/maidn-node-static-build" +grep -qF 'tar -C "$layer_dir" -cf "$SOURCE_PATH/layer.tar" "$target_path"' "$tmp/maidn-node-static-build" +grep -qF 'for memory_peak_path in /sys/fs/cgroup/memory.peak /sys/fs/cgroup/memory/memory.max_usage_in_bytes; do' "$tmp/maidn-node-static-build" +grep -qF "if [ -r \"\$memory_peak_path\" ] && memory_peak=\$(cat \"\$memory_peak_path\"); then" "$tmp/maidn-node-static-build" grep -qF 'image: gcr.io/go-containerregistry/crane:v0.21.7' "$tmp/maidn-node-static-push" grep -qF ' - append' "$tmp/maidn-node-static-push" grep -qF 'mountPath: /tekton/home/.docker' "$tmp/maidn-node-static-push" -- 2.43.7