Bug 1173319

Summary: Move /etc/logrotate.d/* to /usr/etc/logrotate.d
Product: [openSUSE] openSUSE Tumbleweed Reporter: Stefan Dirsch <sndirsch>
Component: BasesystemAssignee: Stefan Schubert <schubi>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: bjoernv, crrodriguez, david.anes, dmueller, genes1122, paul.pgp-7, pmonrealgonzalez, schubi, suse-beta, toganm
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Stefan Dirsch 2020-06-24 14:32:22 UTC
I'm currently working on the config file switch /etc --> /usr/etc (find Details on https://en.opensuse.org/openSUSE:Packaging_UsrEtc) and now I'm wondering what should be done with /etc/logrotate.d/* files.

Thorsten Kukuk:
Somebody need to rewrite logrotate first. ;-)
Comment 1 Stefan Dirsch 2020-06-24 14:33:35 UTC
Adding maintainers of logrotate to Cc
Comment 2 Pedro Monreal Gonzalez 2020-06-24 17:09:37 UTC
Just for reference, see also the opensuse-factory ML thread:
   https://lists.opensuse.org/opensuse-factory/2020-06/msg00248.html
Comment 3 Stefan Dirsch 2020-11-24 13:35:11 UTC
Pedro, any plans to look into this? Just to make sure, I'm not planning to implement this. I just need it for some of my packages. ;-)
Others need it as well for sure ....
Comment 4 Pedro Monreal Gonzalez 2020-11-24 15:13:15 UTC
We were discussing this in the packaging team but I'm not yet sure how to do it, especially with the files in /etc/logrotate.d/*. Lots of packages would need to be adapted with this change. Variant 1 should be applied here.
Comment 5 Stefan Dirsch 2020-11-24 15:31:45 UTC
(In reply to Pedro Monreal Gonzalez from comment #4)
> We were discussing this in the packaging team but I'm not yet sure how to do
> it, especially with the files in /etc/logrotate.d/*. Lots of packages would need to be adapted with this change. 

So what? I would be happy to adjsut all affected files of my pacckages.

> Variant 1 should be applied here.

Yes, of course.
Comment 6 Pedro Monreal Gonzalez 2020-11-24 15:47:58 UTC
(In reply to Stefan Dirsch from comment #5)
> (In reply to Pedro Monreal Gonzalez from comment #4)
> > We were discussing this in the packaging team but I'm not yet sure how to do
> > it, especially with the files in /etc/logrotate.d/*. Lots of packages would need to be adapted with this change. 
> 
> So what? I would be happy to adjsut all affected files of my pacckages.

From [https://build.opensuse.org/package/view_file/Base:System/logrotate/logrotate.default?expand=1], there is this directory where packages write their rotation info:

   # RPM packages drop log rotation information into this directory
   include /etc/logrotate.d

Also the systemd files, to which .conf file should they point to?

   ExecStart=/usr/sbin/logrotate /etc/logrotate.conf

> > Variant 1 should be applied here.
> 
> Yes, of course.
Comment 7 Stefan Dirsch 2020-11-24 17:53:14 UTC
Yeah. That's why Thorsten Kukuk wrote: "Somebody need to rewrite logrotate first. ;-)".
Comment 8 Togan Muftuoglu 2021-11-14 09:44:26 UTC
So after almost one year there is no progress on any approach :(
Comment 9 Pedro Monreal Gonzalez 2021-11-15 13:24:27 UTC
Yes, I just can't find the time to work on this but patches/fixes are welcome.
Comment 10 Christian Boltz 2022-08-24 22:34:39 UTC
It seems logrotate now supports /usr/etc/logrotate.d/ using an interesting[tm] solution in logrotate.service.

One confusing thing is that /usr/etc/logrotate.conf only has
    include /usr/etc/logrotate.d
but it does NOT have
    include /etc/logrotate.d

That missing   include /etc/logrotate.d   is at least confusing. Is there a specific reason why it isn't in the default config? If not, adding it might prevent confusion for people who read logrotate.conf.
Comment 11 Stefan Dirsch 2022-08-25 09:41:54 UTC
Thanks for finding this ticket, Christian! Let's better reassign this ticket to schubi, since he has implemented that feature - obviously without knowing that such a ticket exists since two years ...
Comment 12 Gene Snider 2022-09-10 20:02:31 UTC
This was implemented in logrotate-3.20.1-2.2, but now using /etc/logrotate.d/zypp-history.lr is broken.  The file in /etc/logrotate.d is preserved across updates, but I get this journal error message since that update:

> journalctl -p err -u logrotate.service
Sep 06 00:00:02 Mobile-PC systemd[1]: Failed to start Rotate log files.
-- Boot ac535881d63e4741a64e81cbb73e153a --
Sep 07 04:45:13 Mobile-PC systemd[1]: Failed to start Rotate log files.
-- Boot 35f3b6fda0984c4cb85d380f76bf607e --
Sep 08 02:48:29 Mobile-PC systemd[1]: Failed to start Rotate log files.
-- Boot acb8ef636b604f88bdc345ec5436fd8c --
Sep 09 07:50:22 Mobile-PC systemd[1]: Failed to start Rotate log files.
-- Boot 0e96e0a1f82a47668f52ac8b4f4c9625 --
Sep 10 07:25:37 Mobile-PC systemd[1]: Failed to start Rotate log files.

and

> journalctl -b ac535881d63e4741a64e81cbb73e153a -u logrotate.serviceSep 07 04:45:13 Mobile-PC systemd[1]: Starting Rotate log files...
Sep 07 04:45:13 Mobile-PC sh[1185]: error: zypp-history.lr:1 duplicate log entry for /var/log/zypp/hist>
Sep 07 04:45:13 Mobile-PC sh[1185]: error: found error in file zypp-history.lr, skipping
Sep 07 04:45:13 Mobile-PC systemd[1]: logrotate.service: Main process exited, code=exited, status=1/FAI>
Sep 07 04:45:13 Mobile-PC systemd[1]: logrotate.service: Failed with result 'exit-code'.
Sep 07 04:45:13 Mobile-PC systemd[1]: Failed to start Rotate log files.

So this update introduced a problem when the administrator uses files in /etc/logrotate.d to over-ride package config files.

Gene
Comment 14 Stefan Schubert 2022-09-12 08:42:19 UTC
(In reply to Gene Snider from comment #12)
> Sep 07 04:45:13 Mobile-PC sh[1185]: error: zypp-history.lr:1 duplicate log
> entry for /var/log/zypp/hist>
> Sep 07 04:45:13 Mobile-PC sh[1185]: error: found error in file
> zypp-history.lr, skipping
Could you please attach your zypp-history.lr from /etc AND /usr/etc ?
Comment 15 Stefan Schubert 2022-09-12 14:05:40 UTC
(In reply to Stefan Schubert from comment #14)
> (In reply to Gene Snider from comment #12)
> > Sep 07 04:45:13 Mobile-PC sh[1185]: error: zypp-history.lr:1 duplicate log
> > entry for /var/log/zypp/hist>
> > Sep 07 04:45:13 Mobile-PC sh[1185]: error: found error in file
> > zypp-history.lr, skipping
> Could you please attach your zypp-history.lr from /etc AND /usr/etc ?

Not needed anymore. I can reproduce this bug.
Comment 16 Stefan Schubert 2022-09-15 06:49:45 UTC
https://build.opensuse.org/request/show/1003701
-------------------------------------------------------------------
Wed Sep 14 11:15:55 UTC 2022 - Stefan Schubert <schubi@suse.com>

Ignoring vendor logs settings in /usr/etc/logrotate.d if they
have already been defined by the the admin in the /etc/logrotate.d
directory (bsc#1173319).
-------------------------------------------------------------------

I have also removed the "include" in logrotate.conf because it will be
handled in logrotate.service.

Thanks for the hints ! :-)
Comment 17 Gene Snider 2022-09-15 19:57:28 UTC
Your welcome!  Thanks for the fixes.

Gene
Comment 18 David Anes 2022-12-14 15:53:36 UTC
While performing an update to latest version of logrotate in Factory, I found a new feature is implemented: 
* https://github.com/logrotate/logrotate/pull/473

@Stefan, do you mind to review the patch you introduced[1] (or remove it entirely) from TW by using that feature? I prefer to ask than breaking something that took so long to fix.

Thanks.

[1] https://build.opensuse.org/package/rdiff/Base:System/logrotate?linkrev=base&rev=103
Comment 19 Stefan Schubert 2022-12-15 13:10:08 UTC
(In reply to David Anes from comment #18)
> While performing an update to latest version of logrotate in Factory, I
> found a new feature is implemented: 
> * https://github.com/logrotate/logrotate/pull/473
> 
> @Stefan, do you mind to review the patch you introduced[1] (or remove it
> entirely) from TW by using that feature? I prefer to ask than breaking
> something that took so long to fix.
> 
> Thanks.
> 
> [1]
> https://build.opensuse.org/package/rdiff/Base:System/
> logrotate?linkrev=base&rev=103

The question is how LOG_FLAG_IGNOREDUPLICATES is set. If this flag is set when ENABLE_VENDORDIR has also been set then there is a chance to drop the patch because you can manage it in the configure.ac script outside of the code.