From 823bee77618abf289cf686e67dbaa8aaca390d53 Mon Sep 17 00:00:00 2001 From: "David L. Smith-Uchida" Date: Mon, 16 Aug 2021 04:46:07 -0700 Subject: [PATCH] Changed format of download request name to use a random UUID rather than (#4034) a timestamp. If two requests were happening very close together for the same backup, the second would fail randomly. Signed-off-by: Dave Smith-Uchida --- pkg/cmd/util/downloadrequest/downloadrequest.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/util/downloadrequest/downloadrequest.go b/pkg/cmd/util/downloadrequest/downloadrequest.go index 73b9b392b..22861245f 100644 --- a/pkg/cmd/util/downloadrequest/downloadrequest.go +++ b/pkg/cmd/util/downloadrequest/downloadrequest.go @@ -28,6 +28,7 @@ import ( "net/url" "time" + "github.com/google/uuid" "github.com/pkg/errors" "k8s.io/apimachinery/pkg/util/wait" kbclient "sigs.k8s.io/controller-runtime/pkg/client" @@ -41,7 +42,12 @@ import ( var ErrNotFound = errors.New("file not found") func Stream(ctx context.Context, kbClient kbclient.Client, namespace, name string, kind velerov1api.DownloadTargetKind, w io.Writer, timeout time.Duration, insecureSkipTLSVerify bool, caCertFile string) error { - reqName := fmt.Sprintf("%s-%s", name, time.Now().Format("20060102150405")) + uuid, err := uuid.NewRandom() + if err != nil { + return errors.WithStack(err) + } + + reqName := fmt.Sprintf("%s-%s", name, uuid.String()) created := builder.ForDownloadRequest(namespace, reqName).Target(kind, name).Result() if err := kbClient.Create(context.Background(), created, &kbclient.CreateOptions{}); err != nil {