Bug 1826658 - systemd presets request - rpmdb-rebuild
Summary: systemd presets request - rpmdb-rebuild
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: fedora-release
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Stephen Gallagher
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1818910
TreeView+ depends on / blocked
 
Reported: 2020-04-22 09:10 UTC by Panu Matilainen
Modified: 2020-04-29 16:33 UTC (History)
10 users (show)

Fixed In Version: fedora-release-33-0.7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-29 16:33:56 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Panu Matilainen 2020-04-22 09:10:37 UTC
rpmdb-rebuild is a newly added (rpm >= 4.15.90-0.git14971.7.fc33) service which performs an rpm database rebuild at boot-time when /var/lib/rpm/.rebuilddb flag file exists (ie similar to selinux-autorelabel service hooked on /.autorelabel). 

The immediate motivation is for performing database format conversion for https://fedoraproject.org/wiki/Changes/Sqlite_Rpmdb in a reasonably safe and controlled environment, but can serve other recovery etc purposes too.

* Does the service require post-rpm-installation configuration in order to be useful (for example, does it need manual edits to a configuration file)?

No

* Does the service listen on a network socket for connections originating on a separate physical or virtual machine?

No

* Is the service non-persistent (i.e. run once at startup and exit)?

Yes

* What is the exact name (or names) of the systemd unit files to be enabled?

rpmdb-rebuild.service

* Is this request for all Fedora deliverables or only for some Editions (list them)?

All

Comment 1 Stephen Gallagher 2020-04-22 18:36:59 UTC
I'm not implementing this yet because I took a look at RPM's new rpmdb-rebuild.service and realized that it won't actually work the way you are expecting for upgrades.

Two problems:

1) You didn't include the `%systemd_post rpmdb-rebuild.service` (and `%systemd_preun` and `%systemd_postun_with_restart`). As a result, systemd won't set up the service properly.

2) Even once those are added, the service won't get enabled by default because those scripts only run `systemctl preset rpmdb-rebuild.service` on initial package installation. Meaning it won't be enabled during upgrades. (The check is `if [ $1 -eq 1 ] && [ -x /usr/bin/systemctl ] ; then` in `%systemd_post`)

Probably we need to get FESCo's permission to do:

```
%post
/usr/bin/systemctl enable rpmdb-rebuild.service || :
```

The problem with this approach is that it will result in rpmdb-rebuild.service being enabled unconditionally. It won't be possible to disable it (if for some reason this was desired.)

Comment 2 Stephen Gallagher 2020-04-22 18:40:15 UTC
(In reply to Stephen Gallagher from comment #1)
> ```
> %post
> /usr/bin/systemctl enable rpmdb-rebuild.service || :
> ```

Correction:

```
if [ -x /usr/bin/systemctl ] ; then 
        # Initial installation 
        /usr/bin/systemctl enable rpmdb-rebuild.service || : 
fi
```

(I forgot to include the check for systemctl above)

Comment 3 Panu Matilainen 2020-04-23 06:45:01 UTC
Oh, I know the service addition in current rpm is incomplete due to missing details, just added it to tick of another box from my list while spinning wheels. Looks like my secret plan to evoke feedback from the community is working beyond expectations :P

%post seems like the wrong place to do anything about this as it imposes ordering constraints related to systemd that we absolutely don't want in rpm. It seems to me the right place to do this would be %posttrans instead, maybe:

%posttrans
if [ -x /usr/bin/systemctl ] ; then 
        /usr/bin/systemctl --no-reload preset rpmdb-rebuild.service || : 
fi

Doing this in %posttrans means any new presets will already be there, and so will /usr/bin/systemctl if its to be there at all. Whether this is preferable to explicit enable I dunno. From my point of view it'd certainly be easier to manage if all this was inside rpm.spec and not spread around in multiple places.

Should I just go ahead and file a FESCo ticket for this?

Comment 4 Panu Matilainen 2020-04-23 10:10:09 UTC
Filed https://pagure.io/fesco/issue/2382, lets see.

Comment 5 Panu Matilainen 2020-04-29 11:19:58 UTC
So... regardless of whether rpm itself ends up needing an exception for its "systemctl preset" calling mechanism, we'll need the preset to be set in fedora-release-common. And AIUI the service itself does not need an exception. Can we just proceed with this part, please?

Comment 6 Stephen Gallagher 2020-04-29 14:56:21 UTC
Committed to fedora-release: https://src.fedoraproject.org/rpms/fedora-release/c/e951fe6b674c2daceb3f00c4a0601cb5f214ff2d?branch=master

It will be in the next Rawhide build of that package.

Comment 7 Stephen Gallagher 2020-04-29 16:33:56 UTC
Built for Rawhide and should be in the next compose.


Note You need to log in before you can comment on or make changes to this bug.