mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-03 22:57:04 +00:00
perf: better string concatenation (#9705)
* perf: better string concatenation Signed-off-by: emirot <emirot.nolan@gmail.com> Signed-off-by: nolanemirot <nolan.emirot@broadcom.com> Signed-off-by: emirot <emirot.nolan@gmail.com> * fix: backup deletion silently succeeds when tarball download fails (#9693) * Enhance backup deletion logic to handle tarball download failures and clean up associated CSI VolumeSnapshotContents Signed-off-by: Priyansh Choudhary <im1706@gmail.com> * added changelog Signed-off-by: Priyansh Choudhary <im1706@gmail.com> * Refactor error handling in backup deletion Signed-off-by: Priyansh Choudhary <im1706@gmail.com> * Refactor backup deletion logic to skip CSI snapshot cleanup on tarball download failure Signed-off-by: Priyansh Choudhary <im1706@gmail.com> * prevent backup deletion when errors occur Signed-off-by: Priyansh Choudhary <im1706@gmail.com> * added logger Signed-off-by: Priyansh Choudhary <im1706@gmail.com> Signed-off-by: emirot <emirot.nolan@gmail.com> * perf: better string concatenation Signed-off-by: emirot <emirot.nolan@gmail.com> * Add delay to avoid race conditions during VolumeSnapshotContent deletion (#9700) * Add delay to avoid race conditions during VolumeSnapshotContent deletion Signed-off-by: Priyansh Choudhary <im1706@gmail.com> * updated changelog Signed-off-by: Priyansh Choudhary <im1706@gmail.com> * Updated Changelog Signed-off-by: Priyansh Choudhary <im1706@gmail.com> Signed-off-by: emirot <emirot.nolan@gmail.com> * block data mover design Signed-off-by: Lyndon-Li <lyonghui@vmware.com> Signed-off-by: emirot <emirot.nolan@gmail.com> * block data mover design Signed-off-by: Lyndon-Li <lyonghui@vmware.com> Signed-off-by: emirot <emirot.nolan@gmail.com> * irregular volume size Signed-off-by: Lyndon-Li <lyonghui@vmware.com> Signed-off-by: emirot <emirot.nolan@gmail.com> * block data mover design Signed-off-by: Lyndon-Li <lyonghui@vmware.com> Signed-off-by: emirot <emirot.nolan@gmail.com> * Update the "community" page of website (#9722) Update the community page to add the correct links to community meeting and meeting notes. I also removed the referece of google group as I confirmed the last message was sent 2 years ago. Signed-off-by: Daniel Jiang <daniel.jiang@broadcom.com> Signed-off-by: emirot <emirot.nolan@gmail.com> * perf: better string concatenation Signed-off-by: emirot <emirot.nolan@gmail.com> --------- Signed-off-by: emirot <emirot.nolan@gmail.com> Signed-off-by: nolanemirot <nolan.emirot@broadcom.com> Signed-off-by: Priyansh Choudhary <im1706@gmail.com> Signed-off-by: Lyndon-Li <lyonghui@vmware.com> Signed-off-by: Daniel Jiang <daniel.jiang@broadcom.com> Co-authored-by: Priyansh Choudhary <im1706@gmail.com> Co-authored-by: nolanemirot <nolan.emirot@broadcom.com> Co-authored-by: Lyndon-Li <lyonghui@vmware.com> Co-authored-by: Daniel Jiang <daniel.jiang@broadcom.com>
This commit is contained in:
co-authored by
Priyansh Choudhary
nolanemirot
Lyndon-Li
Daniel Jiang
parent
4d9bd91200
commit
fc6361ba06
@@ -0,0 +1 @@
|
||||
perf: better string concatenation
|
||||
@@ -708,17 +708,18 @@ func DiagnoseVS(vs *snapshotv1api.VolumeSnapshot, events *corev1api.EventList) s
|
||||
}
|
||||
}
|
||||
|
||||
diag := fmt.Sprintf("VS %s/%s, bind to %s, readyToUse %v, errMessage %s\n", vs.Namespace, vs.Name, vscName, readyToUse, errMessage)
|
||||
var diag strings.Builder
|
||||
_, _ = fmt.Fprintf(&diag, "VS %s/%s, bind to %s, readyToUse %v, errMessage %s\n", vs.Namespace, vs.Name, vscName, readyToUse, errMessage)
|
||||
|
||||
if events != nil {
|
||||
for _, e := range events.Items {
|
||||
if e.InvolvedObject.UID == vs.UID && e.Type == corev1api.EventTypeWarning {
|
||||
diag += fmt.Sprintf("VS event reason %s, message %s\n", e.Reason, e.Message)
|
||||
_, _ = fmt.Fprintf(&diag, "VS event reason %s, message %s\n", e.Reason, e.Message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return diag
|
||||
return diag.String()
|
||||
}
|
||||
|
||||
func DiagnoseVSC(vsc *snapshotv1api.VolumeSnapshotContent) string {
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -183,16 +184,16 @@ func GetPodContainerTerminateMessage(pod *corev1api.Pod, container string) strin
|
||||
|
||||
// GetPodTerminateMessage returns the terminate message for all containers of a pod
|
||||
func GetPodTerminateMessage(pod *corev1api.Pod) string {
|
||||
message := ""
|
||||
var message strings.Builder
|
||||
for _, containerStatus := range pod.Status.ContainerStatuses {
|
||||
if containerStatus.State.Terminated != nil {
|
||||
if containerStatus.State.Terminated.Message != "" {
|
||||
message += containerStatus.State.Terminated.Message + "/"
|
||||
message.WriteString(containerStatus.State.Terminated.Message + "/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return message
|
||||
return message.String()
|
||||
}
|
||||
|
||||
func getPodLogReader(ctx context.Context, podGetter corev1client.CoreV1Interface, pod string, namespace string, logOptions *corev1api.PodLogOptions) (io.ReadCloser, error) {
|
||||
@@ -272,21 +273,22 @@ func ToSystemAffinity(loadAffinity *LoadAffinity, volumeTopology *corev1api.Node
|
||||
}
|
||||
|
||||
func DiagnosePod(pod *corev1api.Pod, events *corev1api.EventList) string {
|
||||
diag := fmt.Sprintf("Pod %s/%s, phase %s, node name %s, message %s\n", pod.Namespace, pod.Name, pod.Status.Phase, pod.Spec.NodeName, pod.Status.Message)
|
||||
var diag strings.Builder
|
||||
_, _ = fmt.Fprintf(&diag, "Pod %s/%s, phase %s, node name %s, message %s\n", pod.Namespace, pod.Name, pod.Status.Phase, pod.Spec.NodeName, pod.Status.Message)
|
||||
|
||||
for _, condition := range pod.Status.Conditions {
|
||||
diag += fmt.Sprintf("Pod condition %s, status %s, reason %s, message %s\n", condition.Type, condition.Status, condition.Reason, condition.Message)
|
||||
_, _ = fmt.Fprintf(&diag, "Pod condition %s, status %s, reason %s, message %s\n", condition.Type, condition.Status, condition.Reason, condition.Message)
|
||||
}
|
||||
|
||||
if events != nil {
|
||||
for _, e := range events.Items {
|
||||
if e.InvolvedObject.UID == pod.UID && e.Type == corev1api.EventTypeWarning {
|
||||
diag += fmt.Sprintf("Pod event reason %s, message %s\n", e.Reason, e.Message)
|
||||
_, _ = fmt.Fprintf(&diag, "Pod event reason %s, message %s\n", e.Reason, e.Message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return diag
|
||||
return diag.String()
|
||||
}
|
||||
|
||||
var funcExit = os.Exit
|
||||
|
||||
@@ -464,17 +464,18 @@ func GetPVCForPodVolume(vol *corev1api.Volume, pod *corev1api.Pod, crClient crcl
|
||||
}
|
||||
|
||||
func DiagnosePVC(pvc *corev1api.PersistentVolumeClaim, events *corev1api.EventList) string {
|
||||
diag := fmt.Sprintf("PVC %s/%s, phase %s, binding to %s\n", pvc.Namespace, pvc.Name, pvc.Status.Phase, pvc.Spec.VolumeName)
|
||||
var diag strings.Builder
|
||||
_, _ = fmt.Fprintf(&diag, "PVC %s/%s, phase %s, binding to %s\n", pvc.Namespace, pvc.Name, pvc.Status.Phase, pvc.Spec.VolumeName)
|
||||
|
||||
if events != nil {
|
||||
for _, e := range events.Items {
|
||||
if e.InvolvedObject.UID == pvc.UID && e.Type == corev1api.EventTypeWarning {
|
||||
diag += fmt.Sprintf("PVC event reason %s, message %s\n", e.Reason, e.Message)
|
||||
_, _ = fmt.Fprintf(&diag, "PVC event reason %s, message %s\n", e.Reason, e.Message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return diag
|
||||
return diag.String()
|
||||
}
|
||||
|
||||
func DiagnosePV(pv *corev1api.PersistentVolume) string {
|
||||
|
||||
Reference in New Issue
Block a user