Skip to content

Commit 3d74c16

Browse files
naiming-zededaeriknordmark
authored andcommitted
Remove noisy logging and remove previous external boot images
- remove the noisy logging when periodical checking external-boot-image container - remove the unused, and outdated external-boot-image containers - the filter for logging with source "kube", need to include "kube.out" Signed-off-by: naiming-zededa <naiming@zededa.com>
1 parent 0283728 commit 3d74c16

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

pkg/kube/cluster-init.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ external_boot_image_import() {
328328
eve_external_boot_img_name="docker.io/lfedge/eve-external-boot-image"
329329
eve_external_boot_img_tag=$(cat /run/eve-release)
330330
eve_external_boot_img="${eve_external_boot_img_name}:${eve_external_boot_img_tag}"
331-
if /var/lib/k3s/bin/k3s crictl --runtime-endpoint=unix:///run/containerd-user/containerd.sock inspecti "$eve_external_boot_img"; then
331+
if /var/lib/k3s/bin/k3s crictl --runtime-endpoint=unix:///run/containerd-user/containerd.sock inspecti "$eve_external_boot_img" > /dev/null 2>&1; then
332332
# Already imported
333333
return 0
334334
fi
@@ -350,9 +350,38 @@ external_boot_image_import() {
350350
return 1
351351
fi
352352
logmsg "Successfully installed external-boot-image $import_name_tag as $eve_external_boot_img"
353+
354+
# Clean up old eve-external-boot-image versions that don't match current release
355+
cleanup_old_external_boot_images "$eve_external_boot_img_name" "$eve_external_boot_img_tag"
353356
return 0
354357
}
355358

359+
# Remove old eve-external-boot-image images that don't match the current tag
360+
# Usage: cleanup_old_external_boot_images <image_name> <current_tag>
361+
cleanup_old_external_boot_images() {
362+
local img_name="$1"
363+
local current_tag="$2"
364+
365+
logmsg "Cleaning up old external-boot-image versions, keeping tag: $current_tag"
366+
367+
# List all images and filter for eve-external-boot-image
368+
old_images=$(/var/lib/k3s/bin/k3s ctr -a /run/containerd-user/containerd.sock images list -q | grep "^${img_name}:" | grep -v ":${current_tag}$")
369+
370+
if [ -z "$old_images" ]; then
371+
logmsg "No old external-boot-image versions to clean up"
372+
return 0
373+
fi
374+
375+
for old_img in $old_images; do
376+
logmsg "Removing old external-boot-image: $old_img"
377+
if ! /var/lib/k3s/bin/k3s ctr -a /run/containerd-user/containerd.sock image rm "$old_img" 2>/dev/null; then
378+
logmsg "Warning: Failed to remove old image $old_img (may be in use)"
379+
fi
380+
done
381+
382+
logmsg "Old external-boot-image cleanup completed"
383+
}
384+
356385
check_start_containerd() {
357386
# Needed to get the pods to start
358387
if [ ! -L /usr/bin/runc ]; then

pkg/newlog/cmd/getMemlogMsg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func parseMemlogEntry(rawBytes []byte) (inputEntry, error) {
9595
logInfo := parseLogInfo(logEntry)
9696

9797
// don't process kube logs, since they are handled separately in /persist/kubelog
98-
if logInfo.Source == "kube" {
98+
if logInfo.Source == "kube" || logInfo.Source == "kube.out" {
9999
return inputEntry{}, nil
100100
}
101101

0 commit comments

Comments
 (0)