Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/snap-bootstrap: mount base directly on /sysroot #14537

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

alfonsosanchezbeato
Copy link
Member

Mount the base directly on /sysroot in all UC modes, while for hybrid
we mount /run/mnt/data instead of the /run/mnt/sysroot symlink that
was pointing to the former. With this change we do not need to have
the /run/mnt/base mount anymore.

@alfonsosanchezbeato alfonsosanchezbeato added the Run nested The PR also runs tests inluded in nested suite label Sep 25, 2024
@alfonsosanchezbeato
Copy link
Member Author

Opening as draft as we will need canonical/core-initrd#265 landed first. As a side note, we should discuss how to handle this initramfs/snap-bootstrap interlocks in an easier way.

Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 45.87156% with 59 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@6fa2df6). Learn more about missing BASE report.
Report is 59 commits behind head on master.

Files with missing lines Patch % Lines
cmd/snap-bootstrap/cmd_initramfs_mounts.go 45.00% 37 Missing and 7 partials ⚠️
cmd/snap-bootstrap/initramfs_systemd_mount.go 48.27% 10 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #14537   +/-   ##
=========================================
  Coverage          ?   78.20%           
=========================================
  Files             ?     1162           
  Lines             ?   154334           
  Branches          ?        0           
=========================================
  Hits              ?   120692           
  Misses            ?    26199           
  Partials          ?     7443           
Flag Coverage Δ
unittests 78.20% <45.87%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}
}

// Do a daemon reload so systemd knows about the new mount units
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it also perform the mount then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, as the new mount unit has an After=snap-initramfs-mounts.service dependency

}
}

// Do a daemon reload so systemd knows about the new mount units
sysd := systemd.New(systemd.SystemMode, nil)
if err := sysd.DaemonReload(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will will always have units that need loading? daemon-reload is costly. If we could try to not do it if we did not call writeSysrootMountUnit, then it would be very good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but note that we are always creating the unit in this case (the base is always in the essSnaps slice).

Copy link
Member Author

@alfonsosanchezbeato alfonsosanchezbeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have rebased this PR and added the changes to the initramfs that were previously in a PR in the core-initrd repo.

The changes in snap-bootstrap could need to check for the UC release. It depends on whether we want the initramfs changes to be backported to UC20/22.

}
}

// Do a daemon reload so systemd knows about the new mount units
sysd := systemd.New(systemd.SystemMode, nil)
if err := sysd.DaemonReload(); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but note that we are always creating the unit in this case (the base is always in the essSnaps slice).

@alfonsosanchezbeato alfonsosanchezbeato marked this pull request as ready for review January 30, 2025 20:07
@alfonsosanchezbeato
Copy link
Member Author

@valentindavid @pedronis this is ready now for review.

Copy link

github-actions bot commented Jan 30, 2025

Tue Feb 4 18:30:20 UTC 2025
The following results are from: https://github.com/canonical/snapd/actions/runs/13125002142

Failures:

Preparing:

  • google-nested:ubuntu-24.04-64:tests/nested/manual/remodel-min-size

Executing:

  • openstack:debian-sid-64:tests/main/microk8s-smoke:edge
  • google-nested:ubuntu-24.04-64:tests/nested/manual/recovery-system-reboot:factory_reset
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-pre-download:restart
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-pre-download:close_mid_restart
  • openstack:opensuse-tumbleweed-64:tests/main/snap-refresh-hold
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-pre-download:close
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-gating
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-pre-download:ignore
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-backoff
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh:parallel
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh:regular
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-gating-from-snap
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-retry
  • openstack:opensuse-tumbleweed-64:tests/main/microk8s-smoke:edge
  • openstack:opensuse-15.6-64:tests/main/microk8s-smoke:edge
  • openstack:opensuse-tumbleweed-64:tests/main/refresh-app-awareness-notify
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups:kmsg
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-serial-port
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-required-or-optional
  • google:ubuntu-25.04-64:tests/main/cgroup-devices-v2
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-strict-enforced
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups:uinput
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-self-manage
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-helper

Restoring:

  • openstack:opensuse-tumbleweed-64:tests/main/refresh-app-awareness-notify
  • google:ubuntu-25.04-64:tests/main/security-device-cgroups-strict-enforced

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

}{what, mntType}); err != nil {
return err
}
unitContent.Bytes()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a spurious left over?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is indeed, removed now, thanks

Mount the base directly on /sysroot in UC modes, while for hybrid we
mount /run/mnt/data instead of the /run/mnt/sysroot symlink that was
pointing to the former.
@alfonsosanchezbeato
Copy link
Member Author

Some debugging has revealed that this was not working anymore because I had removed the static sysroot.mount unit, we have to keep it as daemon-reload does not trigger a full recalculation of dependencies (see systemd/systemd#23034).

With the snap-bootstrap changes, the base/rootfs is mounted directly
to /sysroot. With this, we do not need the symlinks created by
detect-*-sysroot.service units. However, we need to keep the static
sysroot mount unit so dependencies are still honored.

kernel-snap-generator and classic-mounts.service are not needed as for
24+ the kernel mount units are created by snap-bootstrap.

The units that need to detect if we are on core/hybrid check now for
the /run/mnt/data/system-data (if present, it is UC) instead of for a
mountpoint in /run/mnt/base.
@alfonsosanchezbeato
Copy link
Member Author

I have now also restricted the change to systems based on 24.04 or latter - otherwise we would need to wait for changes in the UC20/22 initramfs before releasing a new snapd and that can take some time.

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run nested The PR also runs tests inluded in nested suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants