mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-26 00:35:19 -04:00
Report wipe progress every 30s for non terminal logging
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
3bb1ec96b1
commit
51d8bfddbe
2 changed files with 25 additions and 5 deletions
|
@ -12,8 +12,8 @@ sudo apt install libcryptsetup-dev
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
A small test programm is available in `test/main.go`.
|
A small test program is available in `test/main.go`.
|
||||||
To build the programm run:
|
To build the program run:
|
||||||
```shell
|
```shell
|
||||||
go build -o test/crypt ./test/
|
go build -o test/crypt ./test/
|
||||||
```
|
```
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
cryptsetup "github.com/martinjungblut/go-cryptsetup"
|
cryptsetup "github.com/martinjungblut/go-cryptsetup"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
|
@ -293,9 +294,28 @@ func performWipe(device DeviceMapper, volumeID, dek string) error {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No terminal available, disable callbacks to not fill up logs with large amount of progress updates
|
// No terminal available, limit callbacks to once every 30 seconds to not fill up logs with large amount of progress updates
|
||||||
klog.V(4).Info("Progress updates not available")
|
ticker := time.NewTicker(30 * time.Second)
|
||||||
progressCallback = nil
|
firstReq := make(chan struct{}, 1)
|
||||||
|
firstReq <- struct{}{}
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
logProgress := func(size, offset uint64) {
|
||||||
|
prog := (float64(offset) / float64(size)) * 100
|
||||||
|
klog.V(4).Infof("Wipe in progress: %.2f%%", prog)
|
||||||
|
}
|
||||||
|
|
||||||
|
progressCallback = func(size, offset uint64) int {
|
||||||
|
select {
|
||||||
|
case <-firstReq:
|
||||||
|
logProgress(size, offset)
|
||||||
|
case <-ticker.C:
|
||||||
|
logProgress(size, offset)
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wipe the device using the same options as used in cryptsetup: https://gitlab.com/cryptsetup/cryptsetup/-/blob/master/src/cryptsetup.c#L1178
|
// Wipe the device using the same options as used in cryptsetup: https://gitlab.com/cryptsetup/cryptsetup/-/blob/master/src/cryptsetup.c#L1178
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue