Skip to content

Add $SUDO_USER to scheduler log "Command received" lines if present #6773

@jarich

Description

@jarich

Problem

The scheduler log provides an excellent source of who did what to which workflow, when those actions are performed via the WUI. For example:

2025-06-02T02:34:56Z INFO - Command "set_verbosity" received from jarich. ID=e98fa3fd-ce49-4fce-953e-d86c36aed48b
    set_verbosity(level=10)
2025-06-02T02:34:56Z DEBUG - Processing 1 queued command(s)

When actions are performed by the workflow owner (for example via sudo on the command line) no user is attributed:

2025-06-02T11:58:21Z INFO - Command "force_trigger_tasks" received. ID=974d42cb-b151-4ea6-877d-28e92f53340f
    force_trigger_tasks(flow=[], flow_wait=False, tasks=['20250602T0000Z/get_winds*'])
2025-06-02T11:58:22Z DEBUG - Processing 1 queued command(s)

Proposed Solution

If $SUDO_USER is set in the environment, add that to the message. For example:

2025-06-02T11:58:21Z INFO - Command "force_trigger_tasks" received (from jarich via sudo). ID=974d42cb-b151-4ea6-877d-28e92f53340f
    force_trigger_tasks(flow=[], flow_wait=False, tasks=['20250602T0000Z/get_winds*'])
2025-06-02T11:58:22Z DEBUG - Processing 1 queued command(s)

Rationale

When a user is working directly with their workflow, they can probably be counted on to remember what they have been doing. However, I imagine it is not unusual for production accounts to not be the same as user accounts, especially if workflows need 24/7 support. Therefore it is very helpful to know who did what, ideally without having to examine system log sources (like /var/log/secure).

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions