Skip to content

Commit

Permalink
Merge #131340
Browse files Browse the repository at this point in the history
131340: cli: add timestamp in datadog uploadID r=aa-joshi a=aa-joshi

Previously, we were generating short UUID and creating uploadID tag with format clusterName-UUID. This was inadequate because it was challenging to figure out latest upload. To address this, this patch replaces short UUID with timestamp with format `yyyyMMddHHmmss`. So new uploadID would look like `clusterName-yyyyMMddHHmmss`.

Epic: None
Release note: None

Co-authored-by: Akshay Joshi <[email protected]>
  • Loading branch information
craig[bot] and aa-joshi committed Sep 25, 2024
2 parents a6c075a + cb62659 commit f5beced
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/cli/zip_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/cockroachdb/cockroach/pkg/util/system"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
"github.com/cockroachdb/errors"
"github.com/spf13/cobra"
"golang.org/x/oauth2/google"
Expand Down Expand Up @@ -710,14 +709,16 @@ var doUploadReq = func(req *http.Request) ([]byte, error) {
return rawBody, nil
}

// a wrapper around uuid.MakeV4().String() to make the tests more deterministic.
// a wrapper around timestamp to make the tests more deterministic.
// Everything is converted to lowercase and spaces are replaced with hyphens. Because,
// datadog will do this anyway and we want to make sure the UUIDs match when we generate the
// explore/dashboard links.
var newUploadID = func(cluster string) string {
currentTime := timeutil.Now()
formattedTime := currentTime.Format("20060102150405")
return strings.ToLower(
strings.ReplaceAll(
fmt.Sprintf("%s-%s", cluster, uuid.NewV4().Short()), " ", "-",
fmt.Sprintf("%s-%s", cluster, formattedTime), " ", "-",
),
)
}
Expand Down

0 comments on commit f5beced

Please sign in to comment.