Page MenuHomePhabricator

Spicerack: don't IRC log start/stop of cookbook
Open, MediumPublic

Description

To reduce IRC and SAL noise would it be possible to have the option to only log to IRC when needed?

For example instead of having:

!log ayounsi@cumin1001 START - Cookbook sre.network.peering with action 'email' for AS: 35320
11:00 
!log ayounsi@cumin1001 END (PASS) - Cookbook sre.network.peering (exit_code=0) with action 'email' for AS: 35320

I should have:
!log ayounsi@cumin1001 - Cookbook sre.network.peering emailed AS35320

Or instead of:

!log ayounsi@cumin1001 START - Cookbook sre.network.peering with action 'email' for AS: 8932
11:00 
!log ayounsi@cumin1001 END (FAIL) - Cookbook sre.network.peering (exit_code=99) with action 'email' for AS: 8932

I should have... nothing... As the cookbook got stopped before doing any useful action.

This would also allow running the cookbook with a "show" command without having to run it in dry-run mode.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

For the latter part, you can move all the RO pre-requisite checks in the cookbook's init that is run before the START !log, so that the failure will be shown only to you.

For the first part we could add something to Spicerack, for example a flag to say to just log the cookbook completion for simpler cookbooks that do just one thing like this one and the downtime one. Toughts?

For the latter part, you can move all the RO pre-requisite checks in the cookbook's init that is run before the START !log, so that the failure will be shown only to you.

Is there a risk to put way too many things in the __init__ ?

For the first part we could add something to Spicerack, for example a flag to say to just log the cookbook completion for simpler cookbooks that do just one thing like this one and the downtime one. Toughts?

I don't know Spicerack enough, but I was thinking about a flag or parameter to not output to IRC the start/stop at all, and provide a way to write to IRC any custom messages.

For the latter part, you can move all the RO pre-requisite checks in the cookbook's init that is run before the START !log, so that the failure will be shown only to you.

Is there a risk to put way too many things in the __init__ ?

As long as the perform just RO operations no, I don't see any issue.

For the first part we could add something to Spicerack, for example a flag to say to just log the cookbook completion for simpler cookbooks that do just one thing like this one and the downtime one. Toughts?

I don't know Spicerack enough, but I was thinking about a flag or parameter to not output to IRC the start/stop at all, and provide a way to write to IRC any custom messages.

The way to write to IRC is already present, see https://doc.wikimedia.org/spicerack/master/api/index.html#spicerack.Spicerack.irc_logger
I'd be a bit reluctant to remove any !log-ging from cookbooks because then it's too easy with a refactor to loose the logging and starting to have cookbooks that don't log anything.

The way to write to IRC is already present, see https://doc.wikimedia.org/spicerack/master/api/index.html#spicerack.Spicerack.irc_logger

I'd be a bit reluctant to remove any !log-ging from cookbooks because then it's too easy with a refactor to loose the logging and starting to have cookbooks that don't log anything.
SGTM, the ability to only log successful executions would be a win for not impactful cookbooks.

Change 912779 had a related patch set uploaded (by Ayounsi; author: Ayounsi):

[operations/cookbooks@master] sre.network.peering: don't log on "show" command

https://gerrit.wikimedia.org/r/912779

Change 912779 merged by jenkins-bot:

[operations/cookbooks@master] sre.network.peering: don't log on "show" command

https://gerrit.wikimedia.org/r/912779

SGTM, the ability to only log successful executions would be a win for not impactful cookbooks.

@ayounsi i think i see you have updated the networking cookbook and seems like you agree with @Volans reasoning. Is there any further action on this task or can we close it down, cheers

I still think it would be valuable to be able to not log anything without hack. right now the cookbook fails with a success during a show operation.

jbond triaged this task as Medium priority.Jun 19 2023, 3:48 PM

I still think it would be valuable to be able to not log anything without hack. right now the cookbook fails with a success during a show operation.

ack thanks

We have quite a few cookbooks in WMCS that are read-only and used to show a cluster status or similar things. Logging to SAL every time someone runs one of them is a bit noisy, so it would be nice to have a Spicerack option to disable SAL logging for those cookbooks.

Right now we used a hack: https://gerrit.wikimedia.org/r/c/cloud/wmcs-cookbooks/+/954260/