Merge ~raharper/curtin:fix/curtin-pack-os-sync into curtin:master

Proposed by Ryan Harper
Status: Merged
Approved by: Scott Moser
Approved revision: 2dea778b4ba6a3c248a0c38657f3eea7073eead7
Merge reported by: Scott Moser
Merged at revision: bd40234f2b2618eb84de03892a7028b71164e2f5
Proposed branch: ~raharper/curtin:fix/curtin-pack-os-sync
Merge into: curtin:master
Diff against target: 24 lines (+4/-2)
1 file modified
helpers/shell-archive (+4/-2)
Reviewer Review Type Date Requested Status
Scott Moser (community) Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+341780@code.launchpad.net

Description of the change

helpers/shell-archive: drop use of tar --sparse flag

Do not use tar [-S, --sparse] flag: at least one filesystem (btrfs)
requires sync/fsync to ensure proper detection of sparse files.
curtin doesn't contain any sparse files so this does not affect payload
size and this works around bug 1757565.

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) wrote :

We use the sync binary as os.sync() in python3.3 and newer will flush all buffers, where as sync --file-system <path> will sync only the filesystem that is holding the path; this should reduce the impact on a multi-user system.

Additionally, os.sync() is not available in python2.7

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

Your fix here can only really be the same as 'sleep 1'.

We're not going around the VFS cache in any way here.

A write operation with file close and then a subsequent open and read operation is guaranteed that the read operation will get all the data written.

The operations don't have to make it to a backing disk to guarantee that.
A sync just guarantees that the data hits the disk.

I don't doubt that this "fixes" the issue, as I saw the same wierd behavior.

But I don't understand how the issue we're working around is not a severe kernel bug.

Essentially all we're doing is:

   cp file1 /tmp/file1
   tar -cvzf out.tar.gz /tmp/file1

Am I missing something here?

review: Needs Information
Revision history for this message
Ryan Harper (raharper) wrote :

On Tue, Mar 20, 2018 at 9:10 PM, Scott Moser <email address hidden> wrote:
> Review: Needs Information
>
> Your fix here can only really be the same as 'sleep 1'.
>
> We're not going around the VFS cache in any way here.
>
> A write operation with file close and then a subsequent open and read operation is guaranteed that the read operation will get all the data written.
>
> The operations don't have to make it to a backing disk to guarantee that.
> A sync just guarantees that the data hits the disk.
>
> I don't doubt that this "fixes" the issue, as I saw the same wierd behavior.
>
> But I don't understand how the issue we're working around is not a severe kernel bug.
>
> Essentially all we're doing is:
>
> cp file1 /tmp/file1
> tar -cvzf out.tar.gz /tmp/file1
>
> Am I missing something here?

Possibly a python bug then; I suspect if we remove use of shutil and
use cp; it will also just work.

I'll test that today.

> --
> https://code.launchpad.net/~raharper/curtin/+git/curtin/+merge/341780
> You are the owner of ~raharper/curtin:fix/curtin-pack-os-sync.

Revision history for this message
Ryan Harper (raharper) wrote :

Updated to drop use the tar -S (--sparse) flag, some filesystems, break sparse file detection heuristics (btrfs is the only known case); however curtin pack isn't archiving any sparse files anyhow so it's not needed and won't impact the size of the archive.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

I approve.
I dont *need* the comment in the code, but its fine.

Basically I think its fairly unlikely that anyone would ever think "we need --sparse on that tar!".

But this is fine.

Thanks!

Revision history for this message
Scott Moser (smoser) :
review: Approve
Revision history for this message
Scott Moser (smoser) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/curtin/commit/?id=bd40234f

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/helpers/shell-archive b/helpers/shell-archive
2index 3062e2a..5c6c1fd 100755
3--- a/helpers/shell-archive
4+++ b/helpers/shell-archive
5@@ -109,7 +109,8 @@ dump_bin() {
6
7 extract() {
8 mkdir "$2" || { error "failed to make '$2'"; return 1; }
9- dump_bin "$1" | tar -Sxzf - -C "$2"
10+ # Do not use tar [-S, --sparse] flag, see LP: #1757565
11+ dump_bin "$1" | tar -xzf - -C "$2"
12 }
13
14 main() {
15@@ -253,7 +254,8 @@ main() {
16 trap cleanup EXIT
17
18 local payload="${TEMP_D}/payload.tar.gz" md5=""
19- tar -C "$archive_d" -Sczf "${payload}" . ||
20+ # Do not use tar [-S, --sparse] flag, see LP: #1757565
21+ tar -C "$archive_d" -czf "${payload}" . ||
22 { error "failed to create archive from '${archive_d}'"; return 1; }
23
24 md5=$(md5sum < "$payload") ||

Subscribers

People subscribed via source and target branches