From 7100c360b31dfd1b9f4413eb2df3db3f229a5e26 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 7 Sep 2021 12:42:43 +1000 Subject: [PATCH] filesystem: add file syncs The "does the size on disk match the manifest" size checks in I70a7bb5f73d1dddc540e96529784bb8c9bb0b9e3 appear to having a false-positive on some changes. One example job I found failed with Manifest has invalid size for layer sha256:9815a275e5d0f93566302aeb58a49bf71b121debe1a291cf0f64278fe97ec9b5 (size:203129434 actual:185016320) but when I went to look at the file on disk (quite some time later), it was correct $ ls -l ./_local/blobs/sha256:9815a275e5d0f93566302aeb58a49bf71b121debe1a291cf0f64278fe97ec9b5 -rw-r--r-- 1 root root 203129433 Sep 7 01:53 data (well, off by one byte, but that's the problem worked-around by the original change). I think what happened here is that is that when we're getting into multi-hundred megabyte layers there's plenty of chance for the writes to join the upload chunks to have not flushed by the time we check it when the manifest is uploaded. Add some flush and sync points after upload and concatentation writes to avoid this. Change-Id: I46606287d41fa6745de7c8bfb31c6b0d28e32957 --- zuul_registry/filesystem.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zuul_registry/filesystem.py b/zuul_registry/filesystem.py index 6cdb102..cedc76f 100644 --- a/zuul_registry/filesystem.py +++ b/zuul_registry/filesystem.py @@ -52,6 +52,8 @@ class FilesystemDriver(storageutils.StorageDriver): else: for chunk in data: f.write(chunk) + f.flush() + os.fsync(f.fileno()) def get_object(self, path): path = os.path.join(self.root, path) @@ -117,6 +119,8 @@ class FilesystemDriver(storageutils.StorageDriver): if not d: break outf.write(d) + outf.flush() + os.fsync(outf.fileno()) for chunk in chunks: chunk_path = os.path.join(self.root, chunk['path']) os.unlink(chunk_path)