From d52cbc19be7a8bb4937e52a57cf32ff2ea3bcb31 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Sun, 13 Oct 2019 01:51:59 +0900 Subject: [PATCH] snapshots/native: ignore xattr errors during CopyDir `secuity.*` xattrs cannot be copied in most cases For moby/buildkit#1189 Signed-off-by: Akihiro Suda --- snapshots/native/native.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/snapshots/native/native.go b/snapshots/native/native.go index 5532ea66d..aac26d37b 100644 --- a/snapshots/native/native.go +++ b/snapshots/native/native.go @@ -286,7 +286,15 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k if td != "" { if len(s.ParentIDs) > 0 { parent := o.getSnapshotDir(s.ParentIDs[0]) - if err := fs.CopyDir(td, parent); err != nil { + xattrErrorHandler := func(dst, src, xattrKey string, copyErr error) error { + // security.* xattr cannot be copied in most cases (moby/buildkit#1189) + log.G(ctx).WithError(copyErr).Debugf("failed to copy xattr %q", xattrKey) + return nil + } + copyDirOpts := []fs.CopyDirOpt{ + fs.WithXAttrErrorHandler(xattrErrorHandler), + } + if err := fs.CopyDir(td, parent, copyDirOpts...); err != nil { return nil, errors.Wrap(err, "copying of parent failed") } }