diff mbox series

rpm: workaround to remove dnf lock file

Message ID 20231208101253.4042712-3-changqing.li@windriver.com
State New
Headers show
Series rpm: workaround to remove dnf lock file | expand

Commit Message

Changqing Li Dec. 8, 2023, 10:12 a.m. UTC
From: Changqing Li <changqing.li@windriver.com>

dnf has a bug, refer [1], it cause that log_lock.pid may not removed
after dnf exit. And for native dnf, since we change the lock file path
to /, it will never be removed, and make the rootfs not clean,refer
[2][3].  This patch is a workaround to fix above issue.

[1] https://github.com/rpm-software-management/dnf/issues/1963
[2] https://git.openembedded.org/openembedded-core/commit/?id=742a1b71249f4da1c8d8e13e270b0eb6128a3f66
[3] https://github.com/rpm-software-management/dnf/blob/master/etc/tmpfiles.d/dnf.conf

Signed-off-by: Changqing Li <changqing.li@windriver.com>
---
 meta/lib/oe/package_manager/rpm/__init__.py | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Alexander Kanavin Dec. 8, 2023, 10:21 a.m. UTC | #1
On Fri, 8 Dec 2023 at 11:13, Changqing Li
<changqing.li@eng.windriver.com> wrote:
> dnf has a bug, refer [1], it cause that log_lock.pid may not removed
> after dnf exit. And for native dnf, since we change the lock file path
> to /, it will never be removed, and make the rootfs not clean,refer
> [2][3].  This patch is a workaround to fix above issue.

> @@ -420,3 +422,7 @@ class RpmPM(PackageManager):
>          os.chdir(current_dir)
>
>          return tmp_dir
> +
> +    def _remove_dnf_lock_file(self):
> +       if os.path.exists(self.rootfs_dir + "/log_lock.pid")
> +            os.remove(self.rootfs_dir + "/log_lock.pid")

Both the description and the code in the patch seem to imply that
sometimes dnf leaves the lock file behind and sometimes it does not.
If that is the case, we need to dig deeper into the reasons why.

If that is not the case, please change the removal to be deterministic
(remove the existence check), so that it produces an error if the lock
file is not actually left behind by dnf. That way we'll also know when
upstream resolved the issue, if ever.

Alex
Changqing Li Dec. 11, 2023, 1:06 a.m. UTC | #2
On 12/8/23 18:21, Alexander Kanavin wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> On Fri, 8 Dec 2023 at 11:13, Changqing Li
> <changqing.li@eng.windriver.com>  wrote:
>> dnf has a bug, refer [1], it cause that log_lock.pid may not removed
>> after dnf exit. And for native dnf, since we change the lock file path
>> to /, it will never be removed, and make the rootfs not clean,refer
>> [2][3].  This patch is a workaround to fix above issue.
>> @@ -420,3 +422,7 @@ class RpmPM(PackageManager):
>>           os.chdir(current_dir)
>>
>>           return tmp_dir
>> +
>> +    def _remove_dnf_lock_file(self):
>> +       if os.path.exists(self.rootfs_dir + "/log_lock.pid")
>> +            os.remove(self.rootfs_dir + "/log_lock.pid")
> Both the description and the code in the patch seem to imply that
> sometimes dnf leaves the lock file behind and sometimes it does not.
> If that is the case, we need to dig deeper into the reasons why.

Yes, sometimes dnf leaves the lock file behind and sometimes it does not.

I think it is related to in which condition this dnf issue can be 
reproduced. I am not

very clear about the exact reproduce steps now. That's why existence 
check is added.

Maybe I can take some time to find the step.   And a v2 version will be 
sent.

//changqing

>
> If that is not the case, please change the removal to be deterministic
> (remove the existence check), so that it produces an error if the lock
> file is not actually left behind by dnf. That way we'll also know when
> upstream resolved the issue, if ever.
>
> Alex
diff mbox series

Patch

diff --git a/meta/lib/oe/package_manager/rpm/__init__.py b/meta/lib/oe/package_manager/rpm/__init__.py
index f40c880af4..bfd40fa691 100644
--- a/meta/lib/oe/package_manager/rpm/__init__.py
+++ b/meta/lib/oe/package_manager/rpm/__init__.py
@@ -217,6 +217,8 @@  class RpmPM(PackageManager):
         if len(failed_scriptlets_pkgnames) > 0:
             failed_postinsts_abort(list(failed_scriptlets_pkgnames.keys()), self.d.expand("${T}/log.do_${BB_CURRENTTASK}"))
 
+        self._remove_dnf_lock_file()
+
     def remove(self, pkgs, with_dependencies = True):
         if not pkgs:
             return
@@ -420,3 +422,7 @@  class RpmPM(PackageManager):
         os.chdir(current_dir)
 
         return tmp_dir
+
+    def _remove_dnf_lock_file(self):
+	if os.path.exists(self.rootfs_dir + "/log_lock.pid")
+            os.remove(self.rootfs_dir + "/log_lock.pid")