ShortURL: Fix wrong creation timestamp conversion (#113646)
This commit is contained in:
@@ -25,14 +25,14 @@ func convertToK8sResource(v *shorturls.ShortUrl, namespacer request.NamespaceMap
|
||||
// resourceVersion can't be 0, since we are using the lastSeenAt value, when it's zero we default to current time
|
||||
resourceVersion := fmt.Sprintf("%d", v.LastSeenAt)
|
||||
if v.LastSeenAt == 0 {
|
||||
resourceVersion = fmt.Sprintf("%d", time.Now().UnixMilli())
|
||||
resourceVersion = fmt.Sprintf("%d", time.Now().Unix())
|
||||
}
|
||||
|
||||
p := &shorturl.ShortURL{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: v.Uid,
|
||||
ResourceVersion: resourceVersion,
|
||||
CreationTimestamp: metav1.NewTime(time.UnixMilli(v.CreatedAt)),
|
||||
CreationTimestamp: metav1.NewTime(time.Unix(v.CreatedAt, 0)),
|
||||
Namespace: namespacer(v.OrgId),
|
||||
},
|
||||
Spec: spec,
|
||||
|
||||
@@ -211,6 +211,7 @@ func doDualWriteTests(t *testing.T, helper *apis.K8sTestHelper, mode grafanarest
|
||||
found, err := client.Resource.Get(context.Background(), uid, metav1.GetOptions{})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, uid, found.GetName())
|
||||
assert.LessOrEqual(t, time.Since(found.GetCreationTimestamp().Time).Seconds(), 30.0, "creation timestamp should be within last 30 seconds")
|
||||
|
||||
// Verify cross-API consistency
|
||||
getFromBothAPIs(t, helper, client, uid)
|
||||
|
||||
Reference in New Issue
Block a user