Merge pull request #10284 from ningmingxiao/sync

support to syncfs after pull by using diff plugin
This commit is contained in:
Fu Wei 2024-08-05 00:58:13 +00:00 committed by GitHub
commit 45d8917089
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View File

@ -42,6 +42,10 @@ type config struct {
// correct output, allowing any ordering to be used to prefer
// more optimimal implementations.
Order []string `toml:"default"`
// sync_fs is an experimental setting. It's to force sync
// filesystem during unpacking to ensure that data integrity.
// It is effective for all containerd client.
SyncFs bool `toml:"sync_fs"`
}
type differ interface {
@ -62,7 +66,7 @@ func init() {
if err != nil {
return nil, err
}
syncFs := ic.Config.(*config).SyncFs
orderedNames := ic.Config.(*config).Order
ordered := make([]differ, len(orderedNames))
for i, n := range orderedNames {
@ -79,6 +83,7 @@ func init() {
return &local{
differs: ordered,
syncfs: syncFs,
}, nil
},
})
@ -86,6 +91,7 @@ func init() {
type local struct {
differs []differ
syncfs bool
}
var _ diffapi.DiffClient = &local{}
@ -106,6 +112,9 @@ func (l *local) Apply(ctx context.Context, er *diffapi.ApplyRequest, _ ...grpc.C
}
opts = append(opts, diff.WithPayloads(payloads))
}
if l.syncfs {
er.SyncFs = true
}
opts = append(opts, diff.WithSyncFs(er.SyncFs))
for _, differ := range l.differs {

View File

@ -19,5 +19,6 @@
package diff
var defaultDifferConfig = &config{
Order: []string{"walking"},
Order: []string{"walking"},
SyncFs: false,
}

View File

@ -17,5 +17,6 @@
package diff
var defaultDifferConfig = &config{
Order: []string{"windows", "windows-lcow"},
Order: []string{"windows", "windows-lcow"},
SyncFs: false,
}