From 8142ab5df4e5d33e97fa7a0c8b82d70bc730770a Mon Sep 17 00:00:00 2001 From: R4mbo Date: Tue, 25 Aug 2026 01:02:56 +0530 Subject: [PATCH] fix log format string mismatches that produce wrong or mangled output (#10370) * fix log format string mismatches that produce wrong or mangled output Signed-off-by: samay43 * add changelog entry Signed-off-by: samay43 --------- Signed-off-by: samay43 (cherry picked from commit d374854b0e297a9b4221c5a688ef30368c58e166) --- changelogs/unreleased/10370-samay43 | 1 + internal/hook/item_hook_handler.go | 2 +- internal/volume/volumes_information.go | 4 +++- pkg/backup/actions/csi/pvc_action.go | 2 +- pkg/backup/actions/csi/volumesnapshot_action.go | 4 ++-- pkg/backup/actions/csi/volumesnapshotcontent_action.go | 3 +-- pkg/restore/restore.go | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 changelogs/unreleased/10370-samay43 diff --git a/changelogs/unreleased/10370-samay43 b/changelogs/unreleased/10370-samay43 new file mode 100644 index 000000000..3ffb47ca0 --- /dev/null +++ b/changelogs/unreleased/10370-samay43 @@ -0,0 +1 @@ +fix log format string mismatches that produce wrong or mangled output diff --git a/internal/hook/item_hook_handler.go b/internal/hook/item_hook_handler.go index bed48c5ea..cd0d33982 100644 --- a/internal/hook/item_hook_handler.go +++ b/internal/hook/item_hook_handler.go @@ -419,7 +419,7 @@ func getInitContainerFromAnnotation(podName string, annotations map[string]strin return nil } if command == "" { - log.Infof("RestoreHook init container for pod %s is using container's default entrypoint", podName, containerImage) + log.Infof("RestoreHook init container for pod %s is using the default entrypoint of image %s", podName, containerImage) } if containerName == "" { uid, err := uuid.NewRandom() diff --git a/internal/volume/volumes_information.go b/internal/volume/volumes_information.go index ad8993447..69214ef45 100644 --- a/internal/volume/volumes_information.go +++ b/internal/volume/volumes_information.go @@ -36,6 +36,7 @@ import ( "github.com/vmware-tanzu/velero/pkg/features" "github.com/vmware-tanzu/velero/pkg/itemoperation" "github.com/vmware-tanzu/velero/pkg/kuberesource" + "github.com/vmware-tanzu/velero/pkg/util/stringptr" ) type Method string @@ -494,7 +495,8 @@ func (v *BackupVolumesInformation) generateVolumeInfoForCSIVolumeSnapshot() { tmpVolumeInfos = append(tmpVolumeInfos, volumeInfo) } else { - v.logger.Warnf("cannot find info for PVC %s/%s", volumeSnapshot.Namespace, volumeSnapshot.Spec.Source.PersistentVolumeClaimName) + v.logger.Warnf("cannot find info for PVC %s/%s", volumeSnapshot.Namespace, + stringptr.GetString(volumeSnapshot.Spec.Source.PersistentVolumeClaimName)) continue } } diff --git a/pkg/backup/actions/csi/pvc_action.go b/pkg/backup/actions/csi/pvc_action.go index da690626b..09c58ffbb 100644 --- a/pkg/backup/actions/csi/pvc_action.go +++ b/pkg/backup/actions/csi/pvc_action.go @@ -1183,7 +1183,7 @@ func setPVCRequestSizeToVSRestoreSize( logger logrus.FieldLogger, ) { if vsc.Status.RestoreSize != nil { - logger.Debugf("Patching PVC request size to fit the volumesnapshot restore size %d", vsc.Status.RestoreSize) + logger.Debugf("Patching PVC request size to fit the volumesnapshot restore size %d", *vsc.Status.RestoreSize) restoreSize := *resource.NewQuantity(*vsc.Status.RestoreSize, resource.BinarySI) // It is possible that the volume provider allocated a larger diff --git a/pkg/backup/actions/csi/volumesnapshot_action.go b/pkg/backup/actions/csi/volumesnapshot_action.go index 49e690e93..16d5a16ff 100644 --- a/pkg/backup/actions/csi/volumesnapshot_action.go +++ b/pkg/backup/actions/csi/volumesnapshot_action.go @@ -269,8 +269,8 @@ func (p *volumeSnapshotBackupItemAction) Progress( } var err error if progress.Started, err = time.Parse(time.RFC3339, operationIDParts[2]); err != nil { - p.log.Errorf("error parsing operation ID's StartedTime", - "part into time %s: %s", operationID, err.Error()) + p.log.Errorf("error parsing operation ID's StartedTime part into time %s: %s", + operationID, err.Error()) return progress, errors.WithStack(err) } diff --git a/pkg/backup/actions/csi/volumesnapshotcontent_action.go b/pkg/backup/actions/csi/volumesnapshotcontent_action.go index f184230d1..fc93cfb87 100644 --- a/pkg/backup/actions/csi/volumesnapshotcontent_action.go +++ b/pkg/backup/actions/csi/volumesnapshotcontent_action.go @@ -107,8 +107,7 @@ func (p *volumeSnapshotContentBackupItemAction) Execute( } p.log.Infof( - "Returning from VolumeSnapshotContentBackupItemAction", - "with %d additionalItems to backup", + "Returning from VolumeSnapshotContentBackupItemAction with %d additionalItems to backup", len(additionalItems), ) return &unstructured.Unstructured{Object: snapContMap}, additionalItems, "", nil, nil diff --git a/pkg/restore/restore.go b/pkg/restore/restore.go index 1ae1381f0..3d2620912 100644 --- a/pkg/restore/restore.go +++ b/pkg/restore/restore.go @@ -2804,7 +2804,7 @@ func (ctx *restoreContext) getSelectedRestoreableItems(resource string, original } if skipItem { - ctx.log.Infof("restore orSelector labels did not match, skipping restore of item: %s", skipItem, item) + ctx.log.Infof("restore orSelector labels did not match, skipping restore of item: %s", item) continue } }