HDDS-9933. Recon datanode 'Last Heartbeat' should print relative values#5801
HDDS-9933. Recon datanode 'Last Heartbeat' should print relative values#5801xBis7 merged 2 commits intoapache:masterfrom
Conversation
|
cc @devmadhuu |
|
@devmadhuu Thanks for the review. Do you know anyone else that I can ping, who's working on Recon's frontend? |
@devabhishekpal @smitajoshi12 could you pls review |
|
We have implemneted similar functionality uisng one line code using moment library. Can you check associated code so we can apply similar logic on column. moment(lastUpdatedOMDBDelta).fromNow() |
@smitajoshi12 That was my first approach to this but In the last heartbeat scenario default values are up to 30/60 seconds and we need the UI values to be more precise than |
|
@xBis7 |
@smitajoshi12 Yes, sure. I'll post some screenshots. When saying negative test cases, you mean like provide values from dates later than the current? Can you explain more?
@abhishekaypurohit Thanks for the link and the clarification. That's what I'm saying, that |
There was a problem hiding this comment.
Hello @xBis7,
Can you refactor the code for getTimeDiffFromTimestamp to shorter form?
const getTimeDiffFromTimestamp = (timestamp: number): string => {
const timestampDate = new Date(timestamp);
const currentDate = new Date();
let elapsedTime = "";
let duration: moment.Duration = moment.duration(
moment(currentDate).diff(moment(timestampDate))
)
const durationKeys = ["seconds", "minutes", "hours", "days", "months", "years"]
durationKeys.forEach((k) => {
let time = duration["_data"][k]
if (time !== 0){
elapsedTime = time + `${k.substring(0, 1)} ` + elapsedTime
}
})
return elapsedTime.trim().length === 0 ? "Just now" : elapsedTime.trim() + " ago";
}
This would give the appropriate output. Please let me know if you have any questions and thanks a lot for working on this improvement
|
Thanks @devabhishekpal, your code snippet looks good. I'll push the changes shortly. @smitajoshi12 Here is a screenshot from
|
devabhishekpal
left a comment
There was a problem hiding this comment.
This looks good to me @xBis7.
Thanks a lot for working on this improvement.
+1 from me.
|
@smitajoshi12 Any comments? Do you want to another look? Otherwise, I'll merge it once there is a green CI. |
@xBis7 |
@smitajoshi12 If The values I provided in
Check screenshot. We get |
@xBis7 |
|
Thanks @devmadhuu @smitajoshi12 @devabhishekpal for the review. |




What changes were proposed in this pull request?
Recon's frontend receives a timestamp number from the backend and then formats the number as a date. It's more useful to the cluster admin and practical, to view the
Last Heartbeatas a relative value than an entire date.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-9933
How was this patch tested?
The patch was tested manually, see the attached screenshot.
Also, because there are no unit tests for Recon's frontend, the method was tested externally. Here are some sample values
BTW, this what 'Last Heartbeat' looks like in master