Skip to content

Commit

Permalink
Merge pull request containerd#10284 from ningmingxiao/sync
Browse files Browse the repository at this point in the history
support to syncfs after pull by using diff plugin
  • Loading branch information
fuweid authored Aug 5, 2024
2 parents 7a80448 + 0e4f210 commit 45d8917
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion plugins/services/diff/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -79,13 +83,15 @@ func init() {

return &local{
differs: ordered,
syncfs: syncFs,
}, nil
},
})
}

type local struct {
differs []differ
syncfs bool
}

var _ diffapi.DiffClient = &local{}
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion plugins/services/diff/service_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
package diff

var defaultDifferConfig = &config{
Order: []string{"walking"},
Order: []string{"walking"},
SyncFs: false,
}
3 changes: 2 additions & 1 deletion plugins/services/diff/service_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
package diff

var defaultDifferConfig = &config{
Order: []string{"windows", "windows-lcow"},
Order: []string{"windows", "windows-lcow"},
SyncFs: false,
}

0 comments on commit 45d8917

Please sign in to comment.