From: "Schmidt, Adriaan" <adriaan.schmidt@siemens.com>
To: "jan.kiszka@siemens.com" <jan.kiszka@siemens.com>,
"isar-users@googlegroups.com" <isar-users@googlegroups.com>
Subject: RE: [RFC PATCH 5/5] meta: refactor to use the new mounting mechanism
Date: Wed, 20 Oct 2021 09:20:03 +0000 [thread overview]
Message-ID: <AM4PR1001MB1220C6FC36975ED2C1B10BAFEDBE9@AM4PR1001MB1220.EURPRD10.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <ecfa7a6f-21ca-b978-c658-32e6d997eb48@siemens.com>
On 2021-10-13 12:42, Jan Kiszka wrote:
> > -buildchroot_do_mounts() {
> > +buildchroot_task_prefunc() {
> > sudo -s <<'EOSUDO'
> > - ( flock 9
> > set -e
> > -
> > - mountpoint -q '${BUILDCHROOT_DIR}/isar-apt' ||
> > - mount --bind '${REPO_ISAR_DIR}/${DISTRO}'
> '${BUILDCHROOT_DIR}/isar-apt'
> > - mountpoint -q '${BUILDCHROOT_DIR}/downloads' ||
> > - mount --bind '${DL_DIR}' '${BUILDCHROOT_DIR}/downloads'
> > - mountpoint -q '${BUILDCHROOT_DIR}/dev' ||
> > - mount --rbind /dev '${BUILDCHROOT_DIR}/dev'
> > - mount --make-rslave '${BUILDCHROOT_DIR}/dev'
> > - mountpoint -q '${BUILDCHROOT_DIR}/proc' ||
> > - mount -t proc none '${BUILDCHROOT_DIR}/proc'
> > - mountpoint -q '${BUILDCHROOT_DIR}/sys' ||
> > - mount --rbind /sys '${BUILDCHROOT_DIR}/sys'
> > - mount --make-rslave '${BUILDCHROOT_DIR}/sys'
> > -
> > - # Mount base-apt if 'ISAR_USE_CACHED_BASE_REPO' is set
> > - if [
> "${@repr(bb.utils.to_boolean(d.getVar('ISAR_USE_CACHED_BASE_REPO')))}" =
> 'True' ]
> > - then
> > - mkdir -p '${BUILDCHROOT_DIR}/base-apt'
> > - mountpoint -q '${BUILDCHROOT_DIR}/base-apt' || \
> > - mount --bind '${REPO_BASE_DIR}' '${BUILDCHROOT_DIR}/base-
> apt'
> > - fi
> > -
> > - # Refresh or remove /etc/resolv.conf at this chance
> > + # Refresh or remove /etc/resolv.conf
> > if [ "${@repr(bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')))}" =
> 'True' ]
> > then
> > - rm -rf '${BUILDCHROOT_DIR}/etc/resolv.conf'
> > - else
> > + rm -f '${BUILDCHROOT_DIR}/etc/resolv.conf'
> > + elif [ -d '${BUILDCHROOT_DIR}/etc' ]; then
> > cp -L /etc/resolv.conf '${BUILDCHROOT_DIR}/etc'
> > fi
> > -
> > - ) 9>'${MOUNT_LOCKFILE}'
>
> Which lock is protecting the remaining bits? If none, we need a word why
> that is fine.
The only remaining bit is writing resolv.conf, which I think is safe.
Will add a comment.
> > @@ -190,21 +187,6 @@ do_rootfs_finalize() {
> > find "${ROOTFSDIR}/usr/bin" \
> > -maxdepth 1 -name 'qemu-*-static' -type f -delete
> >
> > - mountpoint -q '${ROOTFSDIR}/isar-apt' && \
> > - umount -l ${ROOTFSDIR}/isar-apt
> > - rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/isar-apt
> > -
> > - mountpoint -q '${ROOTFSDIR}/base-apt' && \
> > - umount -l ${ROOTFSDIR}/base-apt
> > - rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/base-apt
>
> Who is deleting the empty isar-apt base-apt dirs?
No-one... The next version will add a feature, so we can define a mount as:
"bind,rmdir:${REPO_ISAR_DIR}/${DISTRO}:${BUILDCHROOT_DIR}/isar-apt"
and then the rmdir will run as part of unmounting.
> > @@ -54,7 +52,7 @@ python build_completed() {
> > with open('/proc/mounts') as f:
> > for line in f.readlines():
> > if basepath in line:
> > - bb.debug(1, '%s left mounted, unmounting...' %
> line.split()[1])
> > + bb.warn('%s left mounted, unmounting...' %
> line.split()[1])
>
> Ah, you are brave and make this a real warning again. Means you've never
> seen it?
The new mounts class comes with its own cleanup, so once that is finished, this one should not find anything.
> > @@ -153,13 +132,15 @@ do_rootfs_install[root_cleandirs] = "${ROOTFSDIR}"
> > do_rootfs_install[vardeps] += "${ROOTFS_CONFIGURE_COMMAND}
> ${ROOTFS_INSTALL_COMMAND}"
> > do_rootfs_install[depends] = "isar-bootstrap-${@'target' if
> d.getVar('ROOTFS_ARCH') == d.getVar('DISTRO_ARCH') else 'host'}:do_build"
> > do_rootfs_install[deptask] = "do_deploy_deb"
> > +do_rootfs_install[mounts] = "${ROOTFS_MOUNTS}"
> > +do_rootfs_install[mounts-noauto] = "1"
>
> Why "noauto"? How is it done otherwise?
"normally" the mount and unmount functions are added to do_task[prefuncs/postfuncs] and run automatically, with some additional code to catch task-failed events and do the unmounting in that case.
The mounts-noauto flag is in case we need mounting/unmounting to happen at different times. Then the functions need to be called explicitly by the task (cf. below: do_rootfs_install adds them to its list of cmds).
If the task fails, there is no way to know if unmounting still needs to happen, but this case should be rare, and the final cleanup handler will catch that.
> > python do_rootfs_install() {
> > configure_cmds = (d.getVar("ROOTFS_CONFIGURE_COMMAND", True) or "").split()
> > install_cmds = (d.getVar("ROOTFS_INSTALL_COMMAND", True) or "").split()
> >
> > # Mount after configure commands, so that they have time to copy
> > # 'isar-apt' (sdkchroot):
> > - cmds = ['rootfs_prepare'] + configure_cmds + ['rootfs_do_mounts'] + install_cmds
> > + cmds = ['rootfs_prepare'] + configure_cmds + ['mounts_task_prefunc'] + install_cmds + ['mounts_task_postfunc']
> Maybe split this up into multiple conversions of the same type?
Yes, V2 will split this commit to make review easier.
Adriaan
next prev parent reply other threads:[~2021-10-20 9:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 13:04 [RFC PATCH 0/5] Refactor mount logic Adriaan Schmidt
2021-10-12 13:04 ` [RFC PATCH 1/5] oe imports in central location Adriaan Schmidt
2021-10-12 13:04 ` [RFC PATCH 2/5] meta: refactor containerization Adriaan Schmidt
2021-10-13 10:17 ` Jan Kiszka
2021-10-12 13:04 ` [RFC PATCH 3/5] meta: add oe.utils Adriaan Schmidt
2021-10-13 10:17 ` Jan Kiszka
2021-10-20 6:49 ` Schmidt, Adriaan
2021-10-12 13:04 ` [RFC PATCH 4/5] meta: add mounts class Adriaan Schmidt
2021-10-13 10:31 ` Jan Kiszka
2021-10-20 7:02 ` Schmidt, Adriaan
2021-10-12 13:04 ` [RFC PATCH 5/5] meta: refactor to use the new mounting mechanism Adriaan Schmidt
2021-10-13 10:42 ` Jan Kiszka
2021-10-20 9:20 ` Schmidt, Adriaan [this message]
2021-11-22 14:45 ` [RFC PATCH 0/5] Refactor mount logic Anton Mikanovich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM4PR1001MB1220C6FC36975ED2C1B10BAFEDBE9@AM4PR1001MB1220.EURPRD10.PROD.OUTLOOK.COM \
--to=adriaan.schmidt@siemens.com \
--cc=isar-users@googlegroups.com \
--cc=jan.kiszka@siemens.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox