Skip to content

[amtool] update silence add and update flags#1298

Merged
stuartnelson3 merged 3 commits intomasterfrom
stn/update-amtool-silence-flags
Mar 29, 2018
Merged

[amtool] update silence add and update flags#1298
stuartnelson3 merged 3 commits intomasterfrom
stn/update-amtool-silence-flags

Conversation

@stuartnelson3
Copy link
Contributor

@stuartnelson3 stuartnelson3 commented Mar 23, 2018

  • Change --expires/-e to --duration/-d
  • Change --expires-on to --end
  • Add --start
  • silence update has no default duration value
  • silence update now returns the ID of the newly created silence, instead of printing the ID for the old silence.

- Change --expires/-e to --duration/-d
- Change --expires-on to --end
- Add --start
The silences printed before were accurate, except
they had the old ID. Now the new ID is returned.
@stuartnelson3
Copy link
Contributor Author

@sinkingpoint I think you folks are the biggest users of amtool. Do any of the changes here (other than updating flag names) help/hurt your workflows?

@stuartnelson3
Copy link
Contributor Author

@brian-brazil @simonpasquier any comments/objections? my plan is to do #1297 afterwards and have automated tests. So far I've only manually tested this code.

@brian-brazil
Copy link
Contributor

Sounds fine by me.

Copy link
Member

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

One question from me otherwise LGTM.

return nil, fmt.Errorf("silence duration must be greater than 0")
}
silence.EndsAt = time.Now().UTC().Add(time.Duration(duration))
silence.EndsAt = silence.EndsAt.UTC().Add(time.Duration(d))
Copy link
Member

Choose a reason for hiding this comment

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

It is now adding the passed duration to the existing EndsAt. I suppose this is intentional but it wasn't obvious from the change description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, yeah, the original behavior was confusing to me. Now that I'm looking at this again, I'm thinking the duration should be added to StartsAt...

With amtool update <id> --start=<time> --duration=2h, I would expect this silence to be active for 2 hours after the start time.
With amtool update <id> --duration=2h I think it's less clear what the behavior should be. I would take this to mean "set the duration to start_time+2h, but I'm not sure if other folks agree?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah my gut feeling is that amtool update <id> --duration=<x> is ambiguous for users whichever time reference is chosen. Using StartsAt is probably the less confusing option but this is just my opinion ;-)

@sinkingpoint
Copy link
Contributor

sinkingpoint commented Mar 27, 2018

Sorry for the late reply. This is fine by us, but is there a justification for the flag renaming? I'd consider that a breaking change. (I'm aware that we're < 1.0 on this, but It'd be nice to have some reasoning behind it)

@stuartnelson3
Copy link
Contributor Author

stuartnelson3 commented Mar 28, 2018

It more closely maps to the field names used in the alertmanager frontend, and the flag name for the starting time --start (or --begin) seemed to pair in my mind better with --end than --expires-on. This was entirely subjective though.

When a user supplies a duration to update a
silence, it is applied to silence.StartsAt after
any potential changes to the silence's start time.
@stuartnelson3 stuartnelson3 merged commit 1971502 into master Mar 29, 2018
@stuartnelson3 stuartnelson3 deleted the stn/update-amtool-silence-flags branch March 29, 2018 10:11
mxinden pushed a commit to mxinden/alertmanager that referenced this pull request May 5, 2018
* Update silence add/update flags

- Change --expires/-e to --duration/-d
- Change --expires-on to --end
- Add --start

* update subcommand returns ID of new silence

The silences printed before were accurate, except
they had the old ID. Now the new ID is returned.

* Duration is added to silence.StartsAt

When a user supplies a duration to update a
silence, it is applied to silence.StartsAt after
any potential changes to the silence's start time.
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.

4 participants