support to syncfs after pull by using diff plugin
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
This commit is contained in:
		| @@ -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 { | ||||
|   | ||||
| @@ -19,5 +19,6 @@ | ||||
| package diff | ||||
|  | ||||
| var defaultDifferConfig = &config{ | ||||
| 	Order: []string{"walking"}, | ||||
| 	Order:  []string{"walking"}, | ||||
| 	SyncFs: false, | ||||
| } | ||||
|   | ||||
| @@ -17,5 +17,6 @@ | ||||
| package diff | ||||
|  | ||||
| var defaultDifferConfig = &config{ | ||||
| 	Order: []string{"windows", "windows-lcow"}, | ||||
| 	Order:  []string{"windows", "windows-lcow"}, | ||||
| 	SyncFs: false, | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ningmingxiao
					ningmingxiao