Skip to content

Commit

Permalink
🐛 Fix custom binds set as RW_PATHS (#944)
Browse files Browse the repository at this point in the history
* Fix custom binds set as RW_PATHS

RW_PATHS are meant for overlay dirs which go away after a reboot.
Custom binds/binds are mounted under COS_PERSISTENT, so they persist
after reboot AND are RW by default.

This patch removes adding the custom binds into the RW_PATHS on the
cos-layout file as that can lead to unintended consequences

Signed-off-by: Itxaka <[email protected]>

* Dont run custom mounts on livecd and recovery

Signed-off-by: Itxaka <[email protected]>

* Rework writing custom ephemeral/binds

Signed-off-by: Itxaka <[email protected]>

* Maybe fix tests

Signed-off-by: Itxaka <[email protected]>

* Update install_test.go

Signed-off-by: Itxaka <[email protected]>

---------

Signed-off-by: Itxaka <[email protected]>
  • Loading branch information
Itxaka authored Feb 22, 2023
1 parent 498b8ec commit 31d9491
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
27 changes: 14 additions & 13 deletions overlay/files/system/oem/11_persistency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@ stages:
/usr/share/pki/trust/anchors
/var/lib/ca-certificates
PERSISTENT_STATE_BIND: "true"
- if: |
[ -r /run/cos/custom-layout.env ]
name: "append custom bind and ephemeral mounts to /run/cos/cos-layout.env"
- if: '[ -r /run/cos/custom-layout.env ] && [ ! -f "/run/cos/recovery_mode" ] && [ ! -f /run/cos/live_mode ]'
name: "add custom bind and ephemeral mounts to /run/cos/cos-layout.env"
commands:
- |
source /run/cos/cos-layout.env
source /run/cos/custom-layout.env
PERSISTENT_STATE_PATHS="${CUSTOM_EPHEMERAL_MOUNTS} ${PERSISTENT_STATE_PATHS}"
RW_PATHS="${CUSTOM_BIND_MOUNTS} ${RW_PATHS}"
echo CUSTOM_BIND_MOUNTS=\"${CUSTOM_BIND_MOUNTS}\" >> /run/cos/cos-layout.env
echo CUSTOM_EPHEMERAL_MOUNTS=\"${CUSTOM_EPHEMERAL_MOUNTS}\" >> /run/cos/cos-layout.env
echo "# rw paths with user bind mounts" >> /run/cos/cos-layout.env
echo RW_PATHS=\"${RW_PATHS}\" >> /run/cos/cos-layout.env
echo "# persistent state paths with user ephemeral mounts" >> /run/cos/cos-layout.env
echo PERSISTENT_STATE_PATHS=\"${PERSISTENT_STATE_PATHS}\" >> /run/cos/cos-layout.env
source /run/cos/cos-layout.env
source /run/cos/custom-layout.env
PERSISTENT_STATE_PATHS="${CUSTOM_BIND_MOUNTS} ${PERSISTENT_STATE_PATHS}"
RW_PATHS="${CUSTOM_EPHEMERAL_MOUNTS} ${RW_PATHS}"
# Remove the existing lines that we are gonna rewrite
sed -i "/RW_PATHS/d" /run/cos/cos-layout.env
sed -i "/PERSISTENT_STATE_PATHS/d" /run/cos/cos-layout.env
# Add the new lines
echo "# rw paths with user bind mounts" >> /run/cos/cos-layout.env
echo RW_PATHS=\"${RW_PATHS}\" >> /run/cos/cos-layout.env
echo "# persistent state paths with user ephemeral mounts" >> /run/cos/cos-layout.env
echo PERSISTENT_STATE_PATHS=\"${PERSISTENT_STATE_PATHS}\" >> /run/cos/cos-layout.env
- if: |
cat /proc/cmdline | grep -q "kairos.boot_live_mode"
name: "Layout configuration"
Expand Down
4 changes: 2 additions & 2 deletions tests/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ bundles:
Eventually(func() string {
out, _ := Sudo("cat /run/cos/cos-layout.env")
return out
}, 5*time.Minute, 10*time.Second).Should(ContainSubstring("CUSTOM_BIND_MOUNTS=\"/mnt/bind1 /mnt/bind2\""))
}, 5*time.Minute, 10*time.Second).Should(ContainSubstring("PERSISTENT_STATE_PATHS=\"/mnt/bind1 /mnt/bind2"))
Eventually(func() string {
out, _ := Sudo("cat /run/cos/cos-layout.env")
return out
}, 5*time.Minute, 10*time.Second).Should(ContainSubstring("CUSTOM_EPHEMERAL_MOUNTS=\"/mnt/ephemeral /mnt/ephemeral2\""))
}, 5*time.Minute, 10*time.Second).Should(ContainSubstring("RW_PATHS=\"/mnt/ephemeral /mnt/ephemeral2"))

Eventually(func() string {
out, _ := Sudo("/usr/local/bin/usr/bin/edgevpn --help | grep peer")
Expand Down

0 comments on commit 31d9491

Please sign in to comment.