diff mbox series

[4/4] oe-selftest: overlayfs: Add a demo case for /etc

Message ID 20251222113840.2163929-4-uvv.mail@gmail.com
State Under Review
Headers show
Series [1/4] overlayfs: Fix QA failure | expand

Commit Message

Vyacheslav Yurkov Dec. 22, 2025, 11:38 a.m. UTC
From: Vyacheslav Yurkov <uvv.mail@gmail.com>

/etc is a special directory. It's possible to create a mount unit for
it, but many system services that start early at boot time will not
rescan its content when you mount overlay on top. The added test case
demonstrates this but adding a sample systemd service and enabling it in
overlay.

Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>
---
 meta/lib/oeqa/selftest/cases/overlayfs.py | 98 +++++++++++++++++++++++
 1 file changed, 98 insertions(+)

Comments

Mathieu Dubois-Briand Dec. 24, 2025, 12:07 p.m. UTC | #1
On Mon Dec 22, 2025 at 12:38 PM CET, Vyacheslav Yurkov via lists.openembedded.org wrote:
> From: Vyacheslav Yurkov <uvv.mail@gmail.com>
>
> /etc is a special directory. It's possible to create a mount unit for
> it, but many system services that start early at boot time will not
> rescan its content when you mount overlay on top. The added test case
> demonstrates this but adding a sample systemd service and enabling it in
> overlay.
>
> Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>
> ---

Hi Vyacheslav,

Thanks for your patches.

It looks like the added test is failing on the autobuilder, on arm host
platform, with some wic related error:

2025-12-24 10:16:24,719 - oe-selftest - INFO - overlayfs.OverlayFSTests.test_etc_mount (subunit.RemotedTestCase)
2025-12-24 10:16:24,720 - oe-selftest - INFO -  ... FAIL
...
39519	/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-904882/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/tmp-wic/boot.img
| ERROR: Couldn't find correct bootimg_dir, exiting
|
| WARNING: exit code 1 from a shell command.
NOTE: recipe core-image-minimal-1.0-r0: task do_image_wic: Failed
ERROR: Task (/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/openembedded-core/meta/recipes-core/images/core-image-minimal.bb:do_image_wic) failed with exit code '1'
NOTE: Tasks Summary: Attempted 5451 tasks of which 5354 didn't need to be rerun and 1 failed.
NOTE: The errors for this build are stored in /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-904882/tmp/log/error-report/error_report_20251224101317.txt
You can send the errors to a reports server by running:
  send-error-report /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-904882/tmp/log/error-report/error_report_20251224101317.txt [-s server]
NOTE: The contents of these logs will be posted in public if you use the above command with the default server. Please ensure you remove any identifying or proprietary information when prompted before sending.

Summary: 1 task failed:
  /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/openembedded-core/meta/recipes-core/images/core-image-minimal.bb:do_image_wic
    log: /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-904882/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/temp/log.do_image_wic.3087704
Summary: There was 1 ERROR message, returning a non-zero exit code.

https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3043

Can you have a look at this?

Thanks,
Mathieu
Vyacheslav Yurkov Dec. 24, 2025, 2:12 p.m. UTC | #2
On 24.12.2025 13:07, Mathieu Dubois-Briand wrote:
> On Mon Dec 22, 2025 at 12:38 PM CET, Vyacheslav Yurkov via lists.openembedded.org wrote:
>> From: Vyacheslav Yurkov <uvv.mail@gmail.com>
>>
>> /etc is a special directory. It's possible to create a mount unit for
>> it, but many system services that start early at boot time will not
>> rescan its content when you mount overlay on top. The added test case
>> demonstrates this but adding a sample systemd service and enabling it in
>> overlay.
>>
>> Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>
>> ---
> Hi Vyacheslav,
>
> Thanks for your patches.
>
> It looks like the added test is failing on the autobuilder, on arm host
> platform, with some wic related error:
>
> 2025-12-24 10:16:24,719 - oe-selftest - INFO - overlayfs.OverlayFSTests.test_etc_mount (subunit.RemotedTestCase)
> 2025-12-24 10:16:24,720 - oe-selftest - INFO -  ... FAIL
> ...
> 39519	/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-904882/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/tmp-wic/boot.img
> | ERROR: Couldn't find correct bootimg_dir, exiting
> |
> | WARNING: exit code 1 from a shell command.
> NOTE: recipe core-image-minimal-1.0-r0: task do_image_wic: Failed
> ERROR: Task (/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/openembedded-core/meta/recipes-core/images/core-image-minimal.bb:do_image_wic) failed with exit code '1'
> NOTE: Tasks Summary: Attempted 5451 tasks of which 5354 didn't need to be rerun and 1 failed.
> NOTE: The errors for this build are stored in /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-904882/tmp/log/error-report/error_report_20251224101317.txt
> You can send the errors to a reports server by running:
>    send-error-report /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-904882/tmp/log/error-report/error_report_20251224101317.txt [-s server]
> NOTE: The contents of these logs will be posted in public if you use the above command with the default server. Please ensure you remove any identifying or proprietary information when prompted before sending.
>
> Summary: 1 task failed:
>    /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/openembedded-core/meta/recipes-core/images/core-image-minimal.bb:do_image_wic
>      log: /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-904882/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/temp/log.do_image_wic.3087704
> Summary: There was 1 ERROR message, returning a non-zero exit code.
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3043
>
> Can you have a look at this?
>
> Thanks,
> Mathieu
>

Hi Mathieu,
It was not supposed to run on arm yet. Did I forget a tag?

There's a ticket to fix it for arm 
https://bugzilla.yoctoproject.org/show_bug.cgi?id=14963 , but I haven't 
addressed it yet.

Slava
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/overlayfs.py b/meta/lib/oeqa/selftest/cases/overlayfs.py
index 3e55e97927..288d889f03 100644
--- a/meta/lib/oeqa/selftest/cases/overlayfs.py
+++ b/meta/lib/oeqa/selftest/cases/overlayfs.py
@@ -263,6 +263,104 @@  EOT
 
         self._test_correct_image('systemd-machine-units', systemd_machine_unit_append)
 
+    @OETestTag("runqemu")
+    def test_etc_mount(self):
+        """
+        Summary:   /etc is not supposed to be used with overlayfs.bbclass
+        Expected:  Observe inconsistencies after using etc overlay with a mount unit
+        Author:    Vyacheslav Yurkov <uvv.mail@gmail.com>
+        """
+        systemd_machine_unit_append = """
+SYSTEMD_SERVICE:${PN} += " \
+    data.mount \
+    etc.mount \
+"
+
+do_install:append() {
+    install -d ${D}${systemd_system_unitdir}
+    install -d ${D}${ROOT_HOME}
+    cat <<EOT > ${D}${systemd_system_unitdir}/etc.mount
+[Unit]
+Description=OverlayFS mount for /etc directory
+DefaultDependencies=no
+RequiresMountsFor=/data
+
+[Mount]
+What=overlay
+Where=/etc
+Type=overlay
+Options=lowerdir=/etc,upperdir=/data/overlay/etc,workdir=/data/overlay-workdir/etc
+[Install]
+WantedBy=local-fs.target
+EOT
+
+    cat <<EOT >${D}${systemd_system_unitdir}/data.mount
+[Unit]
+Description=Persistent storage partition
+
+[Mount]
+What=/dev/sda3
+Where=/data
+Type=ext4
+Options=defaults
+
+[Install]
+WantedBy=local-fs.target
+EOT
+    cat <<EOT > ${D}${ROOT_HOME}/test-daemon.service
+[Unit]
+Description=My one-shot task
+After=local-fs.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/echo test
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
+EOT
+}
+
+FILES:${PN} += "${ROOT_HOME}"
+"""
+
+        config = """
+IMAGE_INSTALL:append = " systemd-machine-units"
+DISTRO_FEATURES:append = " overlayfs"
+
+# Use systemd as init manager
+INIT_MANAGER = "systemd"
+
+# enable overlayfs in the kernel
+KERNEL_EXTRA_FEATURES:append = " features/overlayfs/overlayfs.scc"
+
+IMAGE_FSTYPES += "wic"
+WKS_FILE = "overlayfs_etc.wks.in"
+OVERLAYFS_ROOTFS_TYPE = "ext4"
+"""
+
+        self.write_config(config)
+
+        machine_inc = """
+OVERLAYFS_MOUNT_POINT[etc] = "/etc"
+OVERLAYFS_QA_SKIP[mnt-overlay] = "mount-configured"
+"""
+        self.set_machine_config(machine_inc)
+        self.write_recipeinc('systemd-machine-units', systemd_machine_unit_append)
+        bitbake('core-image-minimal')
+        with runqemu('core-image-minimal', image_fstype='wic', discard_writes=False) as qemu:
+            test_daemon_path = get_bb_var('ROOT_HOME') + '/test-daemon.service'
+            status, output = qemu.run_serial('cp -f ' + test_daemon_path + ' /etc/systemd/system/')
+            status, output = qemu.run_serial("systemctl enable test-daemon")
+            status, output = qemu.run_serial("sync")
+        with runqemu('core-image-minimal', image_fstype='wic') as qemu:
+            # Check the test service status. It's enabled and supposed to start, but it didn't
+            status, output = qemu.run_serial("systemctl is-enabled test-daemon")
+            self.assertTrue("enabled" in output, msg=output)
+            status, output = qemu.run_serial("systemctl is-active test-daemon")
+            self.assertTrue("inactive" in output, msg=output)
+
 @OETestTag("runqemu")
 class OverlayFSEtcRunTimeTests(OESelftestTestCase):
     """overlayfs-etc class tests"""