Skip to content

Commit

Permalink
Measure and log the time used to remove all child directories (uber-a…
Browse files Browse the repository at this point in the history
…rchive#335)

Cleanup step when moving between stages can take time, and this time is not being logged anywhere. This log will expose the time used to remove memfs files.
  • Loading branch information
Ahmed Magdy authored Jun 4, 2020
1 parent 4bd92f7 commit 4b7d347
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/snapshot/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os"
"path/filepath"
"strings"
"time"

"github.com/uber/makisu/lib/log"
"github.com/uber/makisu/lib/mountutils"
Expand Down Expand Up @@ -119,13 +120,15 @@ func removePathRecursive(p string, fi os.FileInfo, blacklist []string) bool {
// removeAllChildren recursively removes all of the files that it can under the given root.
// It skips paths in the given blacklist and continues when it fails to remove a file.
func removeAllChildren(srcRoot string, blacklist []string) error {
start := time.Now()
children, err := ioutil.ReadDir(srcRoot)
if err != nil {
return fmt.Errorf("failed to get children of %s: %s", srcRoot, err)
}
for _, child := range children {
removePathRecursive(filepath.Join(srcRoot, child.Name()), child, blacklist)
}
log.Infow(fmt.Sprintf("* Removed %d directories under %s", len(children), srcRoot), "duration", time.Since(start).Round(time.Millisecond))
return nil
}

Expand Down

0 comments on commit 4b7d347

Please sign in to comment.