Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2155147

Summary: augeas fails to parse /etc/rsyslog.d/21-cloudinit.conf file
Product: Red Hat Enterprise Linux 9 Reporter: YongkuiGuo <yoguo>
Component: augeasAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED MIGRATED QA Contact: YongkuiGuo <yoguo>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 9.2CC: jmaloy, lersek, qzhang, rjones, ymao
Target Milestone: rcKeywords: MigratedToJIRA, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-07-07 21:20:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description YongkuiGuo 2022-12-20 07:44:05 UTC
Description of problem:
augeas fails to parse /etc/rsyslog.d/21-cloudinit.conf file after the cloud-init package is installed.

$ cat /etc/rsyslog.d/21-cloudinit.conf
# Log cloudinit generated log messages to file
:syslogtag, isequal, "[CLOUDINIT]" /var/log/cloud-init.log

# comment out the following line to allow CLOUDINIT messages through.
# Doing so means you'll also get CLOUDINIT messages in /var/log/syslog
& stop


Version-Release number of selected component (if applicable):
augeas-1.13.0-3.el9.x86_64
cloud-init-22.1-6.el9.noarch
kernel-5.14.0-217.el9.x86_64


How reproducible:
100%


Steps:

1. On rhel9.2 host (make sure the cloud-init package is installed)
$ augtool print /files/etc/rsyslog.d/21-cloudinit.conf
No output

2.
$ augtool print /augeas//error | grep 21-cloudinit.conf
/augeas/files/etc/rsyslog.d/21-cloudinit.conf/error = "parse_failed"
/augeas/files/etc/rsyslog.d/21-cloudinit.conf/error/pos = "248"
/augeas/files/etc/rsyslog.d/21-cloudinit.conf/error/line = "6"
/augeas/files/etc/rsyslog.d/21-cloudinit.conf/error/char = "0"
/augeas/files/etc/rsyslog.d/21-cloudinit.conf/error/lens = "/usr/share/augeas/lenses/dist/rsyslog.aug:92.10-.43:"
/augeas/files/etc/rsyslog.d/21-cloudinit.conf/error/message = "Get did not match entire input"


Actual results:
As above

Expected results:
augeas can parse /etc/rsyslog.d/21-cloudinit.conf file.

Additional info:

Comment 1 Laszlo Ersek 2022-12-20 10:52:06 UTC
Line 6 is:

& stop

There aren't too many things on this line that augeas could fail to understand.

The ampersand (= legacy action continuation syntax) is not the problem. Refer to RH bug 1660884.

The "stop" action is the problem, instead. What I don't understand is why we see this problem *only now*.

Namely, the discard action used to be called "~" in legacy rsyslog; refer to <https://www.rsyslog.com/doc/master/configuration/actions.html#discard-stop>.

In cloud-init, the "& ~" action was replaced with "& stop" in the following commit:

commit b613de733fa7cfbf94666410f252b640019be205
Author: Joshua Powers <josh.powers>
Date:   Mon Apr 10 16:30:33 2017 -0700

    rsyslog: replace ~ with stop
    
    The discard action (tilde character) has been replaced by the
    “stop” RainerScript directive. It is considered more intuitive and
    offers slightly better performance.
    
    The tilde operator was deprecated in rsyslog 7. Distributions
    using rsyslog older than that will need to patch.
    
    LP: #1367899

Launchpad link: https://bugs.launchpad.net/cloud-init/+bug/1367899

I've now checked augeas @ 4f3bbeb3f782 ("Fix date in %changelog in augeas.spec.in (#790)", 2022-12-07), which is the current HEAD of the master branch. At that stage, the rsyslog lens ("lenses/rsyslog.aug") relies, in part, on the syslog lens ("lenses/syslog.aug") for recognizing actions:

> let action = Syslog.action | omusrmsg | file_tmpl | dynamic | namedpipe

and the syslog lens defines the following actions:

>         let action = (file | loghost | users | logprogram | discard)

where discard is only:

> 	let discard = [ label "discard" . Util.del_str "~" ]

Neither lens recognizes "stop".

Comment 2 Laszlo Ersek 2022-12-20 11:13:09 UTC
Reported upstream issue: https://github.com/hercules-team/augeas/issues/794

Comment 3 YongkuiGuo 2022-12-20 11:24:07 UTC
(In reply to Laszlo Ersek from comment #1)
> Line 6 is:
> 
> & stop
> 
> There aren't too many things on this line that augeas could fail to
> understand.
> 
> The ampersand (= legacy action continuation syntax) is not the problem.
> Refer to RH bug 1660884.
> 
> The "stop" action is the problem, instead. What I don't understand is why we
> see this problem *only now*.

That's because QE usually uses bare metal (reserved from beaker) to run augeas testing, and the cloud-init is not installed by default on bare metal. We can consider running augeas test in the VM on the Cloud platform.

Comment 4 Laszlo Ersek 2022-12-22 08:59:25 UTC
Unfortunately the situation is much worse than I had expected. "stop" cannot easily be recognized as an alternative for the discard action, *plus* the multiple actions parsing from bug 1660884 is buggy: it cannot deal with empty lines and comments.

Comment 5 Laszlo Ersek 2022-12-22 09:47:15 UTC
See more details at <https://github.com/hercules-team/augeas/issues/794#issuecomment-1362627179>.