[PATCH v2 0/3] Fixes for unattended installation

15 views
Skip to first unread message

Uladzimir Bely

unread,
Mar 18, 2025, 2:13:11 AMMar 18
to isar-...@googlegroups.com
Changes since v1:

- P2: Install directly to "installer.wic"
- P3: Fix race between to copies of unattended installer running on
different terminals.

Uladzimir Bely (3):
meta-isar: Use to_boolean for INSTALLER_UNATTENDED variable
testsuite: Disable "snapshot" feature for installer image.
installer: Run in unattended mode only on ttyS0

meta-isar/recipes-core/images/isar-image-installer.bb | 2 +-
.../deploy-image/files/usr/bin/deploy-image-wic.sh | 6 ++++++
testsuite/cibuilder.py | 3 ++-
3 files changed, 9 insertions(+), 2 deletions(-)

--
2.45.3

Uladzimir Bely

unread,
Mar 18, 2025, 2:13:11 AMMar 18
to isar-...@googlegroups.com
Existing implementation treated INSTALLER_UNATTENDED = "0" like
it was enabled.

See also commit 29bb5a5c.

Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
---
meta-isar/recipes-core/images/isar-image-installer.bb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta-isar/recipes-core/images/isar-image-installer.bb b/meta-isar/recipes-core/images/isar-image-installer.bb
index ee04bb41..db379f5d 100644
--- a/meta-isar/recipes-core/images/isar-image-installer.bb
+++ b/meta-isar/recipes-core/images/isar-image-installer.bb
@@ -13,7 +13,7 @@ WKS_FILE = "${INSTALLER_WKS_FILE}"

ADDITIONAL_KERNEL_CMDLINE ??= ""

-OVERRIDES .= "${@':unattended-installer' if d.getVar('INSTALLER_UNATTENDED') else ''}"
+OVERRIDES .= "${@':unattended-installer' if bb.utils.to_boolean(d.getVar('INSTALLER_UNATTENDED')) else ''}"
ADDITIONAL_KERNEL_CMDLINE:append:unattended-installer = " \
installer.unattended \
installer.image.uri=/install/${IMAGE_DATA_FILE}.${IMAGE_DATA_POSTFIX} \
--
2.45.3

Uladzimir Bely

unread,
Mar 18, 2025, 2:13:12 AMMar 18
to isar-...@googlegroups.com
This fixes race between two unattended installer instances running
on serial "ttyS0" and graphic "tty1" terminals.

While one of them starts writing the disk, another one fails
and schedules reboot in 60 seconds. Depending on build machine
performance we can get incomplete installation and broken target
filesystem.

Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
---
.../deploy-image/files/usr/bin/deploy-image-wic.sh | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
index 7f552eee..bd580694 100755
--- a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
+++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
@@ -10,6 +10,12 @@ SCRIPT_DIR=$( dirname -- "$( readlink -f -- "$0"; )"; )

. ${SCRIPT_DIR}/../lib/deploy-image-wic/handle-config.sh

+if $installer_unattended; then
+ if [ "$(tty)" != "/dev/ttyS0" ]; then
+ echo "Disable unattended mode on $(tty), it's active on /dev/ttyS0"
+ installer_unattended=0
+ fi
+fi

if ! $installer_unattended; then
installer_image_uri=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)
--
2.45.3

Uladzimir Bely

unread,
Mar 18, 2025, 2:13:13 AMMar 18
to isar-...@googlegroups.com
In the testsuite we use qemu-system with "-shapshot" optiop with wic
images thus preventing them from unwanted modification by tests.

For installer.wic it's reasonable to disable this feature so that
bmaptool will write directly to "installer.wic" instead of temporary
file used by qemu for providing snapshot features.

It also allows to mount it after build for debugging purposes.
---
testsuite/cibuilder.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index 52eb35e8..eb5de190 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -236,7 +236,8 @@ class CIBuilder(Test):
f.write(f'DISTRO ?= "{installer_distro}"\n')
f.write(f'MACHINE ?= "{installer_machine}"\n')
f.write(f'QEMU_DISK_ARGS = "-bios /usr/share/ovmf/OVMF.fd"\n')
- f.write(f'QEMU_DISK_ARGS += "-hda {install_target}"\n')
+ f.write(f'QEMU_DISK_ARGS += "-drive file={install_target},'\
+ 'if=ide,bus=0,unit=0,format=raw,snapshot=off"\n')
f.write(f'QEMU_DISK_ARGS += "-hdb ##ROOTFS_IMAGE##"\n')

# include ci_build.conf in local.conf
--
2.45.3

Jan Kiszka

unread,
Mar 18, 2025, 2:25:45 AMMar 18
to Uladzimir Bely, isar-...@googlegroups.com
On 18.03.25 07:10, Uladzimir Bely wrote:
> This fixes race between two unattended installer instances running
> on serial "ttyS0" and graphic "tty1" terminals.
>
> While one of them starts writing the disk, another one fails
> and schedules reboot in 60 seconds. Depending on build machine
> performance we can get incomplete installation and broken target
> filesystem.
>
> Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
> ---
> .../deploy-image/files/usr/bin/deploy-image-wic.sh | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
> index 7f552eee..bd580694 100755
> --- a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
> +++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
> @@ -10,6 +10,12 @@ SCRIPT_DIR=$( dirname -- "$( readlink -f -- "$0"; )"; )
>
> . ${SCRIPT_DIR}/../lib/deploy-image-wic/handle-config.sh
>
> +if $installer_unattended; then
> + if [ "$(tty)" != "/dev/ttyS0" ]; then

This is wrong. "ttyS0" is target-specific. We need a different, generic
mechanism to detect multiple executions.

Jan

> + echo "Disable unattended mode on $(tty), it's active on /dev/ttyS0"
> + installer_unattended=0
> + fi
> +fi
>
> if ! $installer_unattended; then
> installer_image_uri=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)


--
Siemens AG, Foundational Technologies
Linux Expert Center

Jan Kiszka

unread,
Mar 18, 2025, 2:30:01 AMMar 18
to Uladzimir Bely, isar-...@googlegroups.com
And this would be also wrong.

But all this does not make sense yet. We have a single service that is
supposed to run a single script. I don't see why systemd should
instantiate the service multiple times. Is our service file incorrect?

Jan

Uladzimir Bely

unread,
Mar 18, 2025, 2:34:04 AMMar 18
to Jan Kiszka, isar-...@googlegroups.com
The service itself is correct, the problem is that it's run twice.

https://github.com/ilbers/isar/blob/master/meta-isar/recipes-installer/deploy-image-service/deploy-image-service.bb#L19-L20

For non-unattended mode it doesn't matter, but in unattended mode one
of instances fails and schedules rebooting.

> Jan
>
> > > +    fi
> > > +fi
> > >  
> > >  if ! $installer_unattended; then
> > >      installer_image_uri=$(find "$installdata" -type f -iname
> > > "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)
> >
> >
>

--
Best regards,
Uladzimir.

Uladzimir Bely

unread,
Mar 18, 2025, 2:37:21 AMMar 18
to Jan Kiszka, isar-...@googlegroups.com
On Tue, 2025-03-18 at 07:25 +0100, Jan Kiszka wrote:
> On 18.03.25 07:10, Uladzimir Bely wrote:
> > This fixes race between two unattended installer instances running
> > on serial "ttyS0" and graphic "tty1" terminals.
> >
> > While one of them starts writing the disk, another one fails
> > and schedules reboot in 60 seconds. Depending on build machine
> > performance we can get incomplete installation and broken target
> > filesystem.
> >
> > Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
> > ---
> >  .../deploy-image/files/usr/bin/deploy-image-wic.sh          | 6
> > ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/deploy-image-wic.sh b/meta-isar/recipes-
> > installer/deploy-image/files/usr/bin/deploy-image-wic.sh
> > index 7f552eee..bd580694 100755
> > --- a/meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/deploy-image-wic.sh
> > +++ b/meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/deploy-image-wic.sh
> > @@ -10,6 +10,12 @@ SCRIPT_DIR=$( dirname -- "$( readlink -f --
> > "$0"; )"; )
> >  
> >  . ${SCRIPT_DIR}/../lib/deploy-image-wic/handle-config.sh
> >  
> > +if $installer_unattended; then
> > +    if [ "$(tty)" != "/dev/ttyS0" ]; then
>
> This is wrong. "ttyS0" is target-specific. We need a different,
> generic
> mechanism to detect multiple executions.
>
> Jan

I agree. But this is also hardcoded in the service recipe, so this
generic mechanism should also make change in it.

I think, it could be some "main" tty variable defined in the recipe and
some additional ttys to run always in "attended" mode.

>
> > +        echo "Disable unattended mode on $(tty), it's active on
> > /dev/ttyS0"
> > +        installer_unattended=0
> > +    fi
> > +fi
> >  
> >  if ! $installer_unattended; then
> >      installer_image_uri=$(find "$installdata" -type f -iname
> > "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)
>
>

--
Best regards,
Uladzimir.

Jan Kiszka

unread,
Mar 18, 2025, 3:08:59 AMMar 18
to Uladzimir Bely, isar-...@googlegroups.com
Ah, now I remember.

But, again, we need a proper fix here. Re-entrance needs to be detected,
the core copy job needs to be run only once. And all other entrances of
the script skip over the copying core or otherwise wait at the same
dialog that semi-unattended modes may show.

Jan

Jan Kiszka

unread,
Mar 18, 2025, 3:09:33 AMMar 18
to Uladzimir Bely, isar-...@googlegroups.com
That's no excuse for hard-coding that in the script as well.

Jan

> I think, it could be some "main" tty variable defined in the recipe and
> some additional ttys to run always in "attended" mode.
>
>>
>>> +        echo "Disable unattended mode on $(tty), it's active on
>>> /dev/ttyS0"
>>> +        installer_unattended=0
>>> +    fi
>>> +fi
>>>  
>>>  if ! $installer_unattended; then
>>>      installer_image_uri=$(find "$installdata" -type f -iname
>>> "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)
>>
>>
>


--

Uladzimir Bely

unread,
Mar 18, 2025, 3:51:41 AMMar 18
to Jan Kiszka, isar-...@googlegroups.com
OK, I see.

So, there are two ways to deal with the issue:

1. Make one of terminals (for example, first virtual console ttyS1)
main one, e.g.:

INSTALLER_UNATTENDED_CONSOLE ?= "ttyS1"

And refer to this variable instead of hardcoded value.

2. Unattended installation will be done by the service which was the
first one in the race (first who run bmaptool and locked e.g.
/dev/sda). Other services just should not trigger reboot in this case,
that means "reboot" should be moved from service unit to script again.

As for me, I would prefer option 1 since it's more predictable.


--
Best regards,
Uladzimir.

Uladzimir Bely

unread,
Mar 18, 2025, 4:13:59 AMMar 18
to Jan Kiszka, isar-...@googlegroups.com
...Actually, we could simply check for MACHINE_SERIAL here without
adding new variable.

>
> 2. Unattended installation will be done by the service which was the
> first one in the race (first who run bmaptool and locked e.g.
> /dev/sda). Other services just should not trigger reboot in this
> case,
> that means "reboot" should be moved from service unit to script
> again.
>
> As for me, I would prefer option 1 since it's more predictable.
>
>
> --
> Best regards,
> Uladzimir.
>

--
Best regards,
Uladzimir.

Uladzimir Bely

unread,
Mar 18, 2025, 10:06:33 AMMar 18
to isar-...@googlegroups.com
Changes since v2:

- Allow to specify TTY to run unattended installation on;
- Allow to specify getty instances to run installer on.

Changes since v1:

- Install directly to "installer.wic", without "-snapshot" option;
- Fix race between to copies of unattended installer running on.

Uladzimir Bely (4):
meta-isar: Use to_boolean for INSTALLER_UNATTENDED variable
testsuite: Disable "snapshot" feature for installer image.
Installer: allow to set custom TTYs for installer
installer: Run unattended mode on the only terminal

meta-isar/recipes-core/images/isar-image-installer.bb | 2 +-
.../deploy-image-service/deploy-image-service.bb | 9 +++++++--
.../recipes-installer/deploy-image/deploy-image_0.1.bb | 8 +++++++-
.../{deploy-image-wic.sh => deploy-image-wic.sh.tmpl} | 6 ++++++
testsuite/cibuilder.py | 3 ++-
5 files changed, 23 insertions(+), 5 deletions(-)
rename meta-isar/recipes-installer/deploy-image/files/usr/bin/{deploy-image-wic.sh => deploy-image-wic.sh.tmpl} (95%)

--
2.45.3

Uladzimir Bely

unread,
Mar 18, 2025, 10:06:33 AMMar 18
to isar-...@googlegroups.com
Existing implementation treated INSTALLER_UNATTENDED = "0" like
it was enabled.

See also commit 29bb5a5c.

Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
---

Uladzimir Bely

unread,
Mar 18, 2025, 10:06:34 AMMar 18
to isar-...@googlegroups.com

Uladzimir Bely

unread,
Mar 18, 2025, 10:06:34 AMMar 18
to isar-...@googlegroups.com
This fixes race between two unattended installer instances running
on different (e.g. serial "ttyS0" and graphic "tty1") terminals.

While one of them starts writing the disk, another one fails
and schedules reboot in 60 seconds. Depending on build machine
performance we can get incomplete installation and broken target
filesystem.

Selected terminal with unattended installer can be set by
INSTALLER_UNATTENDED_TTY variable. It should correspond to one
of INSTALLER_GETTY_TARGETS from deploy-image.service recipe.

Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
---
.../recipes-installer/deploy-image/deploy-image_0.1.bb | 8 +++++++-
.../bin/{deploy-image-wic.sh => deploy-image-wic.sh.tmpl} | 6 ++++++
2 files changed, 13 insertions(+), 1 deletion(-)
rename meta-isar/recipes-installer/deploy-image/files/usr/bin/{deploy-image-wic.sh => deploy-image-wic.sh.tmpl} (95%)

diff --git a/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb b/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb
index 242ca88e..1af3a6dd 100644
--- a/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb
+++ b/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb
@@ -7,10 +7,16 @@ DESCRIPTION = "Install image to device"

inherit dpkg-raw

-SRC_URI = "file://usr/bin/deploy-image-wic.sh \
+SRC_URI = "file://usr/bin/deploy-image-wic.sh.tmpl \
file://usr/lib/deploy-image-wic/handle-config.sh \
"
DEBIAN_DEPENDS = "bmap-tools, pv, dialog, util-linux, parted, fdisk, gdisk, pigz, xz-utils, pbzip2, zstd"
+
+INSTALLER_UNATTENDED_TTY ?= "${MACHINE_SERIAL}"
+
+TEMPLATE_FILES += "usr/bin/deploy-image-wic.sh.tmpl"
+TEMPLATE_VARS += "INSTALLER_UNATTENDED_TTY"
+
do_install[cleandirs] = "${D}/usr/bin/ \
${D}/usr/lib/deploy-image-wic \
"
diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh.tmpl
similarity index 95%
rename from meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
rename to meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh.tmpl
index 7f552eee..33a409f3 100755
--- a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
+++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh.tmpl
@@ -10,6 +10,12 @@ SCRIPT_DIR=$( dirname -- "$( readlink -f -- "$0"; )"; )

. ${SCRIPT_DIR}/../lib/deploy-image-wic/handle-config.sh

+if $installer_unattended; then
+ if [ "$(tty)" != "/dev/${INSTALLER_UNATTENDED_TTY}" ]; then
+ dialog --msgbox "Unattended installer is active on ${INSTALLER_UNATTENDED_TTY}. Please wait for it to finish." 7 60
+ installer_unattended=false
+ fi
+fi

if ! $installer_unattended; then
installer_image_uri=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)
--
2.45.3

Uladzimir Bely

unread,
Mar 18, 2025, 10:06:34 AMMar 18
to isar-...@googlegroups.com
Different machines may use different terminals we want to
run installer on. Allow this to be set in local.conf via
INSTALLER_GETTY_TARGETS variables.

Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
---
.../deploy-image-service/deploy-image-service.bb | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/meta-isar/recipes-installer/deploy-image-service/deploy-image-service.bb b/meta-isar/recipes-installer/deploy-image-service/deploy-image-service.bb
index 0fa3dcf3..fbcfbbfa 100644
--- a/meta-isar/recipes-installer/deploy-image-service/deploy-image-service.bb
+++ b/meta-isar/recipes-installer/deploy-image-service/deploy-image-service.bb
@@ -13,9 +13,14 @@ SRC_URI = "file://install.override.conf \
DEPENDS += " deploy-image"
DEBIAN_DEPENDS = "deploy-image"

+INSTALLER_GETTY_TARGETS ?= "getty@tty1 serial-getty@ttyS0"
+
do_install[cleandirs] = "${D}/usr/lib/systemd/system/ge...@tty1.service.d/ \
${D}/usr/lib/systemd/system/serial...@ttyS0.service.d/"
do_install() {
- install -m 0600 ${WORKDIR}/install.override.conf ${D}/usr/lib/systemd/system/ge...@tty1.service.d/override.conf
- install -m 0600 ${WORKDIR}/install.override.conf ${D}/usr/lib/systemd/system/serial...@ttyS0.service.d/override.conf
+ for target in ${INSTALLER_GETTY_TARGETS}; do
+ rm -rf ${D}/usr/lib/systemd/system/${target}.service.d/*
+ install -d -m 0700 ${D}/usr/lib/systemd/system/${target}.service.d/
+ install -m 0600 ${WORKDIR}/install.override.conf ${D}/usr/lib/systemd/system/${target}.service.d/
+ done
}
--
2.45.3

Jan Kiszka

unread,
Mar 18, 2025, 5:25:39 PMMar 18
to Uladzimir Bely, isar-...@googlegroups.com
On 18.03.25 15:02, Uladzimir Bely wrote:
> Different machines may use different terminals we want to
> run installer on. Allow this to be set in local.conf via
> INSTALLER_GETTY_TARGETS variables.
>
> Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
> ---
> .../deploy-image-service/deploy-image-service.bb | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/meta-isar/recipes-installer/deploy-image-service/deploy-image-service.bb b/meta-isar/recipes-installer/deploy-image-service/deploy-image-service.bb
> index 0fa3dcf3..fbcfbbfa 100644
> --- a/meta-isar/recipes-installer/deploy-image-service/deploy-image-service.bb
> +++ b/meta-isar/recipes-installer/deploy-image-service/deploy-image-service.bb
> @@ -13,9 +13,14 @@ SRC_URI = "file://install.override.conf \
> DEPENDS += " deploy-image"
> DEBIAN_DEPENDS = "deploy-image"
>
> +INSTALLER_GETTY_TARGETS ?= "getty@tty1 serial-getty@ttyS0"
> +
> do_install[cleandirs] = "${D}/usr/lib/systemd/system/ge...@tty1.service.d/ \
> ${D}/usr/lib/systemd/system/serial...@ttyS0.service.d/"

Now only "${D}/usr/lib/systemd/system/"

> do_install() {
> - install -m 0600 ${WORKDIR}/install.override.conf ${D}/usr/lib/systemd/system/ge...@tty1.service.d/override.conf
> - install -m 0600 ${WORKDIR}/install.override.conf ${D}/usr/lib/systemd/system/serial...@ttyS0.service.d/override.conf
> + for target in ${INSTALLER_GETTY_TARGETS}; do
> + rm -rf ${D}/usr/lib/systemd/system/${target}.service.d/*

Unneeded, we already have cleandirs.

> + install -d -m 0700 ${D}/usr/lib/systemd/system/${target}.service.d/
> + install -m 0600 ${WORKDIR}/install.override.conf ${D}/usr/lib/systemd/system/${target}.service.d/
> + done
> }

Jan

Jan Kiszka

unread,
Mar 18, 2025, 5:39:47 PMMar 18
to Uladzimir Bely, isar-...@googlegroups.com
On 18.03.25 15:02, Uladzimir Bely wrote:
This remains wrong, already wrote before. Even more now with the new
model where we define that we will only handle even errors on
INSTALLER_UNATTENDED_TTY.

But all this is not what I suggested: First entry into the script that
passes the "target dev empty" test will do the copying, the other
instances terminate without error. If the empty test fails and
installer_target_overwrite is not set, the dialog will still be shown on
all terminals. The one that is then used will become the first (and
only) to copy.

Jan

> + fi
> +fi
>
> if ! $installer_unattended; then
> installer_image_uri=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)

--

Uladzimir Bely

unread,
Mar 19, 2025, 5:15:46 AMMar 19
to Jan Kiszka, isar-...@googlegroups.com
> > index 7f552eee..33a409f3 100755
> > --- a/meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/deploy-image-wic.sh
> > +++ b/meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/deploy-image-wic.sh.tmpl
> > @@ -10,6 +10,12 @@ SCRIPT_DIR=$( dirname -- "$( readlink -f --
> > "$0"; )"; )
> >  
> >  . ${SCRIPT_DIR}/../lib/deploy-image-wic/handle-config.sh
> >  
> > +if $installer_unattended; then
> > +    if [ "$(tty)" != "/dev/${INSTALLER_UNATTENDED_TTY}" ]; then
> > +        dialog --msgbox "Unattended installer is active on
> > ${INSTALLER_UNATTENDED_TTY}. Please wait for it to finish." 7 60
> > +        installer_unattended=false
>
> This remains wrong, already wrote before. Even more now with the new
> model where we define that we will only handle even errors on
> INSTALLER_UNATTENDED_TTY.
>
> But all this is not what I suggested: First entry into the script
> that
> passes the "target dev empty" test will do the copying,

But if there is no direct definition of UNATTENDED_TTY and we allow
such kind of race, it's not predictable, where to look at the
installation process.

> the other
> instances terminate without error.

I didn't get why, but for some reason board reboots even if the
instance immediately terminates without errors (i.e. returns 0). That's
strange (because we have ' || <reboot logic>' in the service, but it
is. So, the only way I found is to leave other instances waiting for
user input.

> If the empty test fails and
> installer_target_overwrite is not set, the dialog will still be shown
> on
> all te mrminals. The one that is then used will become the first (and
> only) to copy.
>

The main thing I tried to achieve with the patchset is to fix problems
that make CI fail and block merging other patches from maillist.

Probably, from the user perspective the ideal behaviour would be run
unattended installation on one TTY and just show the progress on all
TTYs.

> Jan
>
> > +    fi
> > +fi
> >  
> >  if ! $installer_unattended; then
> >      installer_image_uri=$(find "$installdata" -type f -iname
> > "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)
>

--
Best regards,
Uladzimir.

Uladzimir Bely

unread,
Mar 19, 2025, 6:13:55 AMMar 19
to Jan Kiszka, isar-...@googlegroups.com
On Tue, 2025-03-18 at 22:39 +0100, Jan Kiszka wrote:
> On 18.03.25 15:02, Uladzimir Bely wrote:
> > This fixes race between two unattended installer instances running
> > on different (e.g. serial "ttyS0" and graphic "tty1") terminals.
> >
> > While one of them starts writing the disk, another one fails
> > and schedules reboot in 60 seconds. Depending on build machine
> > performance we can get incomplete installation and broken target
> > filesystem.
> >
> > Selected terminal with unattended installer can be set by
> > INSTALLER_UNATTENDED_TTY variable. It should correspond to one
> > of INSTALLER_GETTY_TARGETS from deploy-image.service recipe.
> >
> > Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
> > ---
> >  .../recipes-installer/deploy-image/deploy-image_0.1.bb    | 8
> > +++++++-
> >  .../bin/{deploy-image-wic.sh => deploy-image-wic.sh.tmpl} | 6
> > ++++++
> >  2 files changed, 13 insertions(+), 1 deletion(-)
> >  rename meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/{deploy-image-wic.sh => deploy-image-
> > wic.sh.tmpl} (95%)
> >
> > diff --git a/meta-isar/recipes-installer/deploy-image/deploy-
> > image_0.1.bb b/meta-isar/recipes-installer/deploy-image/deploy-
> > image_0.1.bb
> > index 242ca88e..1af3a6dd 100644
> > --- a/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb
> > +++ b/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb
> > @@ -7,10 +7,16 @@ DESCRIPTION = "Install image to device"
> >  
> >  inherit dpkg-raw
> >  
> > -SRC_URI = "file://usr/bin/deploy-image-wic.sh \
> > +SRC_URI = "file://usr/bin/deploy-image-wic.sh.tmpl \
> >             file://usr/lib/deploy-image-wic/handle-config.sh \
> >            "
> >  DEBIAN_DEPENDS = "bmap-tools, pv, dialog, util-linux, parted,
> > fdisk, gdisk, pigz, xz-utils, pbzip2, zstd"
> > +
> > +INSTALLER_UNATTENDED_TTY ?= "${MACHINE_SERIAL}"
> > +
> > +TEMPLATE_FILES += "usr/bin/deploy-image-wic.sh.tmpl"
> > +TEMPLATE_VARS += "INSTALLER_UNATTENDED_TTY"
> > +
> >  do_install[cleandirs] = "${D}/usr/bin/ \
> >                           ${D}/usr/lib/deploy-image-wic \
> >                          "
> > diff --git a/meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/deploy-image-wic.sh b/meta-isar/recipes-
> > installer/deploy-image/files/usr/bin/deploy-image-wic.sh.tmpl
> > similarity index 95%
> > rename from meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/deploy-image-wic.sh
> > rename to meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/deploy-image-wic.sh.tmpl
> > index 7f552eee..33a409f3 100755
> > --- a/meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/deploy-image-wic.sh
> > +++ b/meta-isar/recipes-installer/deploy-
> > image/files/usr/bin/deploy-image-wic.sh.tmpl
> > @@ -10,6 +10,12 @@ SCRIPT_DIR=$( dirname -- "$( readlink -f --
> > "$0"; )"; )
> >  
> >  . ${SCRIPT_DIR}/../lib/deploy-image-wic/handle-config.sh
> >  
> > +if $installer_unattended; then
> > +    if [ "$(tty)" != "/dev/${INSTALLER_UNATTENDED_TTY}" ]; then
> > +        dialog --msgbox "Unattended installer is active on
> > ${INSTALLER_UNATTENDED_TTY}. Please wait for it to finish." 7 60
> > +        installer_unattended=false
>
> This remains wrong, already wrote before. Even more now with the new
> model where we define that we will only handle even errors on
> INSTALLER_UNATTENDED_TTY.
>
> But all this is not what I suggested: First entry into the script
> that
> passes the "target dev empty" test will do the copying, the other
> instances terminate without error.

Actually, all instances will pass "target dev empty" test since they
are working in parallel. First error starts at "bmaptool" stage.

> If the empty test fails and
> installer_target_overwrite is not set, the dialog will still be shown
> on
> all terminals. The one that is then used will become the first (and
> only) to copy.
>
> Jan
>
> > +    fi
> > +fi
> >  
> >  if ! $installer_unattended; then
> >      installer_image_uri=$(find "$installdata" -type f -iname
> > "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)
>

--
Best regards,
Uladzimir.

Uladzimir Bely

unread,
Mar 24, 2025, 5:20:49 AMMar 24
to isar-...@googlegroups.com
Patches 1 and 2 are merged to next.

This makes full CI passing on all our servers with CI and unblocks
testing/merging other patches from the list.

Patches 3 and 4 fixing core issues with installer race in unattended
mode are not yet merged since they require some time to rework.

--
Best regards,
Uladzimir.


Reply all
Reply to author
Forward
0 new messages