ShortURL: Fix wrong creation timestamp conversion (#113646)

This commit is contained in:
Ezequiel Victorero
2025-11-10 09:14:51 -03:00
committed by GitHub
parent 8ce9098765
commit 32db7e176d
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -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,
+1
View File
@@ -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)