Skip to content
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

Correcting the condition for updating a silence. Earlier was checking… #2816

Merged
merged 1 commit into from
Mar 4, 2022

Conversation

prashbnair
Copy link
Contributor

@prashbnair prashbnair commented Jan 12, 2022

Correcting the condition for updating a silence. Earlier was checking upto
nanosecond precision but reduced to second as the UI only sends upto millisecond

Signed-off-by: Prashant Balachandran pnair@redhat.com

@prashbnair
Copy link
Contributor Author

Fixes #2809

@@ -586,7 +586,7 @@ func canUpdate(a, b *pb.Silence, now time.Time) bool {
// Allowed timestamp modifications depend on the current time.
switch st := getState(a, now); st {
case types.SilenceStateActive:
if !b.StartsAt.Equal(a.StartsAt) {
if b.StartsAt.Unix()-a.StartsAt.Unix() != 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if b.StartsAt.Unix()-a.StartsAt.Unix() != 0 {
if b.StartsAt.Unix() != a.StartsAt.Unix() {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@roidelapluie
Copy link
Member

roidelapluie commented Jan 19, 2022

Thanks, I have added a comment that makes this simpler. Is there an easy test we could add for this, or a comment we should write about why we call that method?

@prashbnair
Copy link
Contributor Author

Is there an easy test we could add for this, or a comment we should write about why we call that method?

There is a test case that I have added. Is there something else that you are looking for?

}
id1, _ := s.Set(sil1)

// Update silence
Copy link
Member

@roidelapluie roidelapluie Jan 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Update silence
// Update silence with 2 extra nanoseconds, so the "seconds" part should not change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

… upto

nanosecond precision but reduced to second as the UI only sends upto millisecond

Signed-off-by: Prashant Balachandran <pnair@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants