Skip to content

Commit

Permalink
Changed format of download request name to use a random UUID rather t…
Browse files Browse the repository at this point in the history
…han (#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 <dsmithuchida@vmware.com>
  • Loading branch information
dsu-igeek authored Aug 16, 2021
1 parent d913f83 commit 823bee7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/cmd/util/downloadrequest/downloadrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down

0 comments on commit 823bee7

Please sign in to comment.