Skip to content

Commit

Permalink
Fix timestamp
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Qiu <[email protected]>
  • Loading branch information
wenqiq committed Feb 28, 2024
1 parent bfc98ad commit 94a4759
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/performance/utils/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func extractNanoseconds(logEntry string) (int64, error) {
}

timestampStr := matches[1]
// 1709088530251243475
// 170908853117632348
// not sure why some timestamps fetch from logs are invalid
for len(timestampStr) < 19 {
timestampStr += "0"
}
nanoseconds, err := strconv.Atoi(timestampStr)
if err != nil {
return 0, fmt.Errorf("error converting nanoseconds to integer: %v", err)
Expand Down Expand Up @@ -139,6 +145,9 @@ func FetchTimestampFromLog(ctx context.Context, kc kubernetes.Interface, namespa
if err != nil {
return false, err
}
if time.Duration(time.Now().UnixNano()-changedTimeStamp) > 8*time.Hour {
return false, fmt.Errorf("timestamp fetch from the client Pod log is invalid, please check")
}
select {
case ch <- time.Duration(changedTimeStamp - startTime):
klog.InfoS("Successfully write in channel")
Expand Down

0 comments on commit 94a4759

Please sign in to comment.