New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vmlatency: Fix latency comparison #243
Conversation
Currently, the config.Config struct, holds a field named: `DesiredMaxLatencyMilliseconds`. Change this field type to `time.Duration` and remove the `Milliseconds` suffix, in order to better compare it with the actual measured latency during `Checkup.Run()`. Signed-off-by: Orel Misan <omisan@redhat.com>
Change the error message format to use the string format of `time.Duration` in order to improve readability. Signed-off-by: Orel Misan <omisan@redhat.com>
Currently, `millisecondsPrefix` is used only as a suffix. Change its name accordingly. Signed-off-by: Orel Misan <omisan@redhat.com>
0f23c64
to
b9d5f89
Compare
Change: Added "vmlatency" prefix to commit message subject. |
return Config{}, fmt.Errorf("%q parameter is invalid: %v", DesiredMaxLatencyMillisecondsParamName, err) | ||
} | ||
|
||
newConfig.DesiredMaxLatency = time.Duration(rawDesiredMaxLatencyMilliseconds) * time.Millisecond |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using the built-in ParseDuration?
cost MillisecondUnit= "ms"
desiredMaxLatency, err := time.ParseDuration(rawDesiredMaxLatencyMilliseconds + MillisecondUnit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great idea (that maybe could be implemented in the other checkups as well).
The problem is that it requires more changes to the unit test.
I prefer to do it in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either are ok by my book
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Currently, if the actual measured latency is less than 1ms, it is considered as 0ms.
This created a small bug[1] when the max desired latency was 0ms.
Improve the comparison of the max desired latency and the actual measured latency.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=2156392