lxc / incus

Powerful system container and virtual machine manager
https://linuxcontainers.org/incus
Apache License 2.0
2.78k stars 224 forks source link

Add refresh-exclude-older flag to only transfer new snapshots during instance/volume refresh #1365

Closed ps-gill closed 1 week ago

ps-gill commented 1 week ago

This pull request resolves issue https://github.com/lxc/incus/issues/745

stgraber commented 1 week ago

Looking into this one now

stgraber commented 1 week ago

Just did a few minor tweaks so far:

stgraber commented 1 week ago

There seems to be a problem with the actual logic:

root@v1:~# incus snapshot list a1
+-------+----------------------+------------+----------+
| NAME  |       TAKEN AT       | EXPIRES AT | STATEFUL |
+-------+----------------------+------------+----------+
| snap0 | 2024/11/14 07:03 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap1 | 2024/11/14 07:03 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap2 | 2024/11/14 07:04 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap3 | 2024/11/14 07:04 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap4 | 2024/11/14 07:05 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap5 | 2024/11/14 07:05 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap6 | 2024/11/14 07:05 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap7 | 2024/11/14 07:05 UTC |            | NO       |
+-------+----------------------+------------+----------+
root@v1:~# incus snapshot list v2:a1
+-------+----------------------+------------+----------+
| NAME  |       TAKEN AT       | EXPIRES AT | STATEFUL |
+-------+----------------------+------------+----------+
| snap6 | 2024/11/14 07:05 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap7 | 2024/11/14 07:05 UTC |            | NO       |
+-------+----------------------+------------+----------+
root@v1:~# incus copy a1 v2: --refresh-exclude-older --refresh
root@v1:~# incus snapshot list v2:a1
+-------+----------------------+------------+----------+
| NAME  |       TAKEN AT       | EXPIRES AT | STATEFUL |
+-------+----------------------+------------+----------+
| snap0 | 2024/11/14 07:03 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap1 | 2024/11/14 07:03 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap2 | 2024/11/14 07:04 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap3 | 2024/11/14 07:04 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap4 | 2024/11/14 07:05 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap5 | 2024/11/14 07:05 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap6 | 2024/11/14 07:05 UTC |            | NO       |
+-------+----------------------+------------+----------+
| snap7 | 2024/11/14 07:05 UTC |            | NO       |
+-------+----------------------+------------+----------+
root@v1:~# 
stgraber commented 1 week ago

I fixed the issue. It was the exclude flag not being passed around through migrationSinkArgs combined with then a bad check in utils.go.