ubuntu / zsys

ZSys daemon and client for zfs systems
GNU General Public License v3.0
301 stars 43 forks source link

Zsys should handle "received" properties like "local" rather than like "default"/"inherited" #182

Open lciti opened 3 years ago

lciti commented 3 years ago

If we backup and restore a bootable rpool, the source of some of the properties will be "received":

$ zfs get all -s received -o all rpool/ROOT/ubuntu_aaaybd
NAME                      PROPERTY                            VALUE                     RECEIVED                  SOURCE
rpool/ROOT/ubuntu_aaaybd  mountpoint                          /                         /                         received
rpool/ROOT/ubuntu_aaaybd  com.ubuntu.zsys:last-booted-kernel  vmlinuz-5.4.0-58-generic  vmlinuz-5.4.0-58-generic  received
rpool/ROOT/ubuntu_aaaybd  com.ubuntu.zsys:bootfs              yes                       yes                       received
rpool/ROOT/ubuntu_aaaybd  com.ubuntu.zsys:last-used           1608162156                1608162156                received

These are the properties that were "local" in the original rpool and should effectively be treated as such for zsys' purposes. Instead, in helpers.go they are effectively treated as "inherited" (see for example the switch statement at lines 61-70). Similarly, in zfs.go, the code checks for the value "local" (see line 605) before deciding whether to set the bootfs property of the new dataset, completely ignoring that the same should be done if d.sources.BootFS == "received".

A quick workaround is to manually zfs set each "received" property to its current value so the source becomes "local". In the longer term, I think it would be better to make zsys handle "received" correctly (i.e. exactly the same way as "local").