Skip to content

Commit

Permalink
[antlir2][prebuilt] fix subvol_symlink on fbpkg layers and userspace …
Browse files Browse the repository at this point in the history
…sendstreams

Summary:
This was being set to `None` which prevented incremental sendstreams based on
`fbpkg` layers from actually being incremental.

Also add a test that `incremental_parent` is never lost if its set.

Test Plan:
```
❯ buck2 build --show-output fbcode//metalos/metald:metalos.metald--incremental-sendstream
Buck UI: https://www.internalfb.com/buck2/418e74a3-a60b-4e2e-8dec-43910ebbab7a
Network: Up: 0B  Down: 0B  (reSessionID-9b256f52-376a-48f1-a343-3afa06db84c1)
Jobs completed: 16486. Time elapsed: 28.9s.
Cache hits: 0%. Commands: 1 (cached: 0, remote: 0, local: 1)
BUILD SUCCEEDED
fbcode//metalos/metald:metalos.metald--incremental-sendstream buck-out/v2/gen/fbcode/18038f740d6221a4/metalos/metald/__metalos.metald--incremental-sendstream__/image.sendstream
```

```name="first command is incremental snapshot"
❯ btrfs receive --dump -f buck-out/v2/gen/fbcode/18038f740d6221a4/metalos/metald/__metalos.metald--incremental-sendstream__/image.sendstream | he
ad -1
snapshot        ./volume                        uuid=818ec2c7-d084-4d4d-a4d1-cdc2da132847 transid=1172566 parent_uuid=1e0ec63d-c5de-0e40-a7a0-a7dd520af4ad parent_transid=1172552
```

```name="delta is small"
❯ ls -lh buck-out/v2/gen/fbcode/18038f740d6221a4/metalos/metald/__metalos.metald--incremental-sendstream__/image.sendstream
-rw-r--r-- 1 vmagro users 6.7M Sep 23 11:07 buck-out/v2/gen/fbcode/18038f740d6221a4/metalos/metald/__metalos.metald--incremental-sendstream__/image.sendstream
```

Reviewed By: aijayadams

Differential Revision: D63270880

fbshipit-source-id: 2501979c2e2fd7f885d7e9471aed0e30f2abfbc9
  • Loading branch information
vmagro authored and facebook-github-bot committed Sep 24, 2024
1 parent d739a9c commit 441c9bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions antlir/antlir2/bzl/image/prebuilt.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
label = ctx.label,
facts_db = facts_db,
contents = contents,
subvol_symlink = contents.subvol_symlink,
mounts = [],
flavor = ctx.attrs.flavor,
),
Expand Down
8 changes: 6 additions & 2 deletions antlir/antlir2/bzl/package/sendstream.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
if not userspace:
subvol_symlink = ctx.actions.declare_output("subvol_symlink")
else:
subvol_symlink = None
subvol_symlink = ctx.attrs.layer[LayerInfo].subvol_symlink

if ctx.attrs.incremental_parent:
incremental_parent_layer = _find_incremental_parent(
Expand Down Expand Up @@ -64,6 +64,10 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
incremental_parent = ctx.attrs.incremental_parent[SendstreamInfo].layer[LayerInfo].subvol_symlink
else:
incremental_parent = ctx.attrs.incremental_parent[SendstreamInfo].subvol_symlink
if incremental_parent == None:
fail("failed to get subvol_symlink from incremental_parent, cannot proceed: {}".format(
ctx.attrs.incremental_parent[SendstreamInfo],
))
else:
incremental_parent = None

Expand All @@ -72,7 +76,7 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
{"sendstream": {
"compression_level": ctx.attrs.compression_level,
"incremental_parent": incremental_parent,
"subvol_symlink": subvol_symlink.as_output() if subvol_symlink else None,
"subvol_symlink": subvol_symlink.as_output() if not userspace else None,
"userspace": userspace,
"volume_name": ctx.attrs.volume_name,
}},
Expand Down

0 comments on commit 441c9bd

Please sign in to comment.