cockpit-podman icon indicating copy to clipboard operation
cockpit-podman copied to clipboard

Add import and export of checkpoints

Open lenticularis39 opened this issue 4 years ago • 7 comments

Adds export (download of checkpoint tarball after making a checkpoint) and import (upload of checkpoint tarball for restore) support.

Upload is done by directly reading a file selected by the PatternFly file upload component; ~download is handled using a service worker (it's a little bit hacky, but seems to work fine in both Firefox and Chromium and doesn't store the tarball in memory; maybe there is a better way, but as far as I know Cockpit can download only files from the file system, not channels/HTTP streams)~ download uses channel redirection to save the checkpoint into a file, which is then downloaded directly using a read channel. (Direct download of the checkpoint stream is not possible, because the checkpoint process takes some time, and also errors have to be handled in the UI, not downloaded instead of the tarball).

There are currently no tests - I'm not sure how Selenium handles downloads (the download has to be done in the test browser because of the service worker); I can have a look at it.

checkpoint restore

lenticularis39 avatar Aug 11 '20 08:08 lenticularis39

Sorry for getting to you only now. It looks cool! I have a few questions first.

@andreasn can you please take a look design-wise? Thanks!

marusak avatar Aug 18 '20 12:08 marusak

I think I cannot make this work. Let see. When I pick export on my local (cgroupsv2) system, I get my favourite error: whataniceerrormessage When I try this in fedora-31 VM, sitting in tests (so it switches to cgroupsv1) it does not produce any error,, but the dialog just gets closed after a bit of waiting without any download prompt (thats what I was expecting). Tried on chromium and firefox, same result. Am I missing here something?

marusak avatar Aug 31 '20 09:08 marusak

I tried it again myself and I discovered a possible cause of your problems.

There is a bug that causes the download not to trigger in Firefox when opening Cockpit for the first time in the browser session (it probably has something to do with the service worker not running) - reloading the page works for me. I thought this was fixed, but apparently that's not the case.

In Chromium, the service worker doesn't start when the SSL certificate couldn't be verified (it throws an error in my case, but it's possible that doesn't happen on every version of Chromium).

I'll try to fix the bug and push the changes.

Edit: bug seems to be caused by a race condition between the page thread and the service worker thread.

lenticularis39 avatar Sep 01 '20 07:09 lenticularis39

I've fixed the issue in Firefox (which is apparently caused by the fetch event not being registered at the point of the fetch request in the iframe).

lenticularis39 avatar Sep 02 '20 07:09 lenticularis39

This is apparently still buggy in Firefox - marking as draft for now.

lenticularis39 avatar Sep 21 '20 07:09 lenticularis39

Since this is still a draft, I'll take this off my UI review queue for now. Judging from the screenshots, it looks like a good approach though.

andreasn avatar Oct 07 '20 15:10 andreasn

Dropped the idea of downloading through a service worker due to continuing problems in Firefox, the new solution uses channel redirection (only locally, not the controversial remote redirection that might be rejected in Cockpit).

This means it's now also blocked on cockpit-project/cockpit#14641 (like #590).

lenticularis39 avatar Jan 27 '21 13:01 lenticularis39