Skip to content

Commit e44d3af

Browse files
authored
Merge pull request #3994 from abel-von/add-sync-for-commit
add sync syscall before get container diff when commit
2 parents de58809 + 24aa5e4 commit e44d3af

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

pkg/imgutil/commit/commit.go

+3
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ func Commit(ctx context.Context, client *containerd.Client, container containerd
173173
}
174174
defer done(ctx)
175175

176+
// Sync filesystem to make sure that all the data writes in container could be persisted to disk.
177+
Sync()
178+
176179
diffLayerDesc, diffID, err := createDiff(ctx, id, sn, client.ContentStore(), differ)
177180
if err != nil {
178181
return emptyDigest, fmt.Errorf("failed to export layer: %w", err)

pkg/imgutil/commit/commit_other.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//go:build !unix
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package commit
20+
21+
func Sync() {
22+
23+
}

pkg/imgutil/commit/commit_unix.go

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//go:build unix
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package commit
20+
21+
import "syscall"
22+
23+
func Sync() {
24+
syscall.Sync()
25+
}

0 commit comments

Comments
 (0)