Page MenuHomePhabricator

[spicerack] support including {project} in SAL messages
Closed, ResolvedPublic

Description

Spicerack emits some default SAL log messages when a cookbook starts and ends:

sal_logger.info("START - %s", message)
sal_logger.info("END (%s) - %s", status, message)

When Spicerack is used in WMCS cookbooks, we would like {message} to be prefixed with the WMCS project name, so that the message can be displayed under the right project in https://sal.toolforge.org/

This requires modifying Spicerack so that we can somehow inject the project name from a WMCS cookbook.

Event Timeline

fnegri changed the task status from Open to In Progress.Jul 18 2023, 1:03 PM
fnegri triaged this task as High priority.
fnegri moved this task from Backlog to In progress on the cloud-services-team (FY2022/2023-Q4) board.

Change 940968 had a related patch set uploaded (by FNegri; author: FNegri):

[operations/software/pywmflib@master] irc: Handler customer logging formatters

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

Change 941453 had a related patch set uploaded (by FNegri; author: FNegri):

[cloud/wmcs-cookbooks@main] Add project name to Spicerack's sal_logger

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

After discussing this with @Volans we think there's no need to modify the Spicerack codebase, it should be enough to:

  1. patch pywmflib to properly support Python logging formatters (https://gerrit.wikimedia.org/r/940968)
  2. in WMCS cookbooks, use a formatter to add the required prefix to log messages (https://gerrit.wikimedia.org/r/c/cloud/wmcs-cookbooks/+/941453)

Change 940968 merged by jenkins-bot:

[operations/software/pywmflib@master] irc: Handle custom logging formatters

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

Change 941453 merged by FNegri:

[cloud/wmcs-cookbooks@main] Add project name to Spicerack's sal_logger

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

Change 944927 had a related patch set uploaded (by FNegri; author: FNegri):

[cloud/wmcs-cookbooks@main] Always pass common_opts to the BaseRunner

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

fnegri reopened this task as In Progress.Aug 2 2023, 2:58 PM

Reopening, because I realized we need to patch all WMCS cookbooks, and in https://gerrit.wikimedia.org/r/c/cloud/wmcs-cookbooks/+/941453 I only patched one cookbook as a test.

The new patch https://gerrit.wikimedia.org/r/944927 does the same for all WMCS cookbooks.

Mentioned in SAL (#wikimedia-cloud-feed) [2023-08-03T13:06:59Z] <wm-bot2> Test SAL log (T341793) - cookbook ran by root@cloudcumin1001

Change 945605 had a related patch set uploaded (by FNegri; author: FNegri):

[cloud/wmcs-cookbooks@main] Add proxy option to all SALLogger instances

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

Change 944927 merged by jenkins-bot:

[cloud/wmcs-cookbooks@main] Always pass common_opts to the BaseRunner

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

Change 945605 merged by jenkins-bot:

[cloud/wmcs-cookbooks@main] Add proxy option to all SALLogger instances

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

Mentioned in SAL (#wikimedia-cloud-feed) [2023-08-04T11:58:55Z] <wm-bot2> added user fnegri to the project as reader (T341793) - cookbook ran by root@cloudcumin1001

Logs are now working correctly, though the fact they are going through two different bots means the order is not always right:

Screenshot 2023-08-04 at 14.01.19.png (252×1 px, 87 KB)

I created T343528 to track this issue.