`cloud-init analyze` fails to produce useful output on Amazon Linux 2 due to log format configuration

Bug #1876323 reported by Dan Watkins
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
High
Dan Watkins

Bug Description

When running `cloud-init analyze show` against a log file from an Amazon Linux 2 instance (e.g. https://pastebin.com/uhJNysgm), no useful output is produced:

$ cloud-init analyze show -i ~/Downloads/uhJNysgm.txt
-- Boot Record 01 --
The total time elapsed since completing an event is printed after the "@" character.
The time the event takes is printed after the "+" character.

Total Time: 0.00000 seconds

1 boot records analyzed

This is because the log configuration on Amazon Linux 2 (https://pastebin.com/x6NZ4NFJ) configures this for arg0Formatter:

  format=%(asctime)s cloud-init[%(process)d]: %(filename)s[%(levelname)s]: %(message)s

which differs from the upstream definition:

  format=%(asctime)s - %(filename)s[%(levelname)s]: %(message)s

This is a problem, because the `cloud-init analyze` commands depend on the " - " part of the line's presence as a separator (see https://github.com/canonical/cloud-init/blob/master/cloudinit/analyze/dump.py#L78), so when we run analyze against an Amazon Linux 2 log file, we incorrectly fail to identify any of the lines in it as being cloud-init log lines.

(As an aside, this is the only non-whitespace difference between the two configuration files.)

Revision history for this message
Ryan Harper (raharper) wrote :

Do we know if Amazon Linux 2 has journald ? we could (prefer) or (fallback) to journalctl output.

Revision history for this message
Brian O'Rourke (bpo-t) wrote :

Yes, Amazon Linux 2 has journald

Revision history for this message
Dan Watkins (oddbloke) wrote :

I've filed https://bugs.launchpad.net/cloud-init/+bug/1876794 for the general case of this ("
`cloud-init analyze` depends on the upstream-shipped log format to function") and https://bugs.launchpad.net/cloud-init/+bug/1876795 for improving the error message when we hit something like this.

I'm going to use this bug specifically to track modifying `cloud-init analyze` to read Amazon Linux 2's log format.

Revision history for this message
Dan Watkins (oddbloke) wrote :

A pull request for this is open at https://github.com/canonical/cloud-init/pull/346

Changed in cloud-init:
status: New → In Progress
importance: Undecided → High
assignee: nobody → Dan Watkins (daniel-thewatkins)
Revision history for this message
Dan Watkins (oddbloke) wrote :
Changed in cloud-init:
status: In Progress → Fix Committed
Revision history for this message
James Falcon (falcojr) wrote : Fixed in cloud-init version 20.3.

This bug is believed to be fixed in cloud-init in version 20.3. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers