facebookincubator / antlir Goto Github PK
View Code? Open in Web Editor NEWANother Linux Image buildeR
Home Page: https://facebookincubator.github.io/antlir/docs/
License: MIT License
ANother Linux Image buildeR
Home Page: https://facebookincubator.github.io/antlir/docs/
License: MIT License
antlir/bzl/shape.bzl
implements a type checker in starlark (the limited flavor of python that is used by buck). As part of this goal, it also includes a python code generator to enable type-checking serialized shape instances at runtime when they are loaded by python scripts.
Unfortunately, the code generator today does not play very nicely with Python type checkers (specifically we have been using Pyre).
If a shape type is nested inside of another shape type, we are not able to annotate the nested type with Pyre.
As an example, if you have:
type_a = shape.shape(...)
type_y = shape.shape(
...
z = shape.list(type_a)
)
Then you export an instance of type_y
into a Python file, you cannot annotate type_a
, as it's a member of the generated class for type_y
with a hidden type name.
Options here are to explore Pyre to find something that works, or change the shape codegenning in a way that makes readable class names for all nested types as well such that they could be imported.
The existing unit tests for shape.bzl
are pretty good, and you can run them with buck test //antlir/bzl/tests/shapes/...
. The generated code can be found in buck-out
, at something like these paths buck-out/gen/antlir/bzl/tests/shapes/test-shape#binary,link-tree/antlir/bzl/tests/shapes/*.py
. The pyre docs should have good instructions for getting set up, including instructions for getting it setup with buck integration
Have you considered extracting the rpm feature as their own library?
https://github.com/facebookincubator/fs_image/tree/master/fs_image/rpm
these would be quite useful of their own, even outside Buck/Bazel
buck test
has provisions for running with a custom test runner (see https://buck.build/files-and-dirs/buckconfig.html#test.external_runner)
A custom test runner would give us a lot of control over how tests are run
$(nproc)
at a time)buck
itself provides.type
to determine how to execute the test.jest-junit
is probably the best documented)Features can be added in stages, the bare minimum for the first revision is a test runner that implements Python unit tests, and outputs a single pass/fail for the test target based on the return code obtained from just running the pex.
buck test
as described in the docs)--run-disabled
flagThis dir is non-standard and not really useful outside of the FB infra. Let's not have it implemented by default for all containers here.
The installation section of the documentation is missing few important details which will help a new contributor to get started quickly with the setup. These include:
rpm2cpio
, zstd
as dependenciesbuck
as root usersudo
, this requires adding the user to the sudoers file, so that password is not required on every invocation, else the build will fail.I am interested to work on adding these details to the documentation.
Disregard- clicked the wrong project when creating this one.
The documentation on image.genrule_layer
provides the following example:
image.layer(
name = '_setup_foo',
parent_layer = '...',
features = [
# `genrule_layer` runs as `nobody` by default
image.ensure_subdirs_exist('/', 'output', user='nobody'),
image.install(':foo', '/output/_temp_foo'),
],
)
image.genrule_layer(
name = '_translate_foo',
parent_layer = ':setup',
cmd = ['/bin/sh', '-c', 'tr a-z A-Z < /output/_temp_foo > /output/FOO'],
)
image.layer(
name = 'foo',
parent_layer = ':_translate_foo',
# Clean up temporary state
features = [image.remove_path('/output/_temp_foo')],
)
However, this is broken in more than one way:
genrule_layer
rule is missing two required arguments: rule_type
and antlir_rule
remove_path
should be just remove
:_setup_foo
instead of :setup
:foo
, since it is installed in _setup_foo
. I assume this would be some file in the host system that is installed in the image and used as the input to the genrule_layer.Let me know if I got something wrong. Will be creating a PR to fix this soon.
Use the branch oss_snapshot
(where a working build appliance exists). The target fails with the following stack trace:
Building: finished in 1.7 sec (100%) 56/56 jobs, 1 updated
Total time: 3.0 sec
Command failed with exit code 1.
command: [/bin/bash, -e, /home/ls/work/fs_image/buck-out/tmp/genrule-4304085449718242770.sh]
stderr: + binary_path=(/usr/bin/python3 /home/ls/work/fs_image/buck-out/gen/fs_image/subvolume-version.pex)
++ /usr/bin/python3 /home/ls/work/fs_image/buck-out/gen/fs_image/subvolume-version.pex
+ subvolume_ver=JQ6eCm4.H80.-oc
+ subvolume_wrapper_dir=create_ops-from-dir:JQ6eCm4.H80.-oc
+ mkdir /home/ls/work/fs_image/buck-out/bin/fs_image/compiler/test_images/create_ops-from-dir__/out
+ echo '{}'
+ /usr/bin/python3 /home/ls/work/fs_image/buck-out/gen/fs_image/layer-mount-config.pex //fs_image/compiler/test_images:create_ops-from-dir
+ layer_json=/home/ls/work/fs_image/buck-out/bin/fs_image/compiler/test_images/create_ops-from-dir__/out/layer.json
++ readlink -f /home/ls/work/fs_image/buck-out/gen/../../buck-out/.volume-refcount-hardlinks/
+ refcounts_dir=/home/ls/work/fs_image/buck-out/.volume-refcount-hardlinks
+ /usr/bin/python3 /home/ls/work/fs_image/buck-out/gen/fs_image/subvolume-garbage-collector.pex --refcounts-dir /home/ls/work/fs_image/buck-out/.volume-refcount-hardlinks --subvolumes-dir /home/ls/work/fs_image/buck-image-out/volume/targets --new-subvolume-wrapper-dir create_ops-from-dir:JQ6eCm4.H80.-oc --new-subvolume-json /home/ls/work/fs_image/buck-out/bin/fs_image/compiler/test_images/create_ops-from-dir__/out/layer.json
Deleting create_ops-from-dir:JQ6dx8Q.GnY.fY7U since its refcount has 1 links
Delete subvolume (no-commit): '/home/ls/work/fs_image/buck-image-out/volume/targets/create_ops-from-dir:JQ6dx8Q.GnY.fY7U/create_ops'
+ /usr/bin/python3 -Es /home/ls/work/fs_image/buck-out/gen/fs_image/compiler.pex --artifacts-may-require-repo --subvolumes-dir /home/ls/work/fs_image/buck-image-out/volume/targets --subvolume-rel-path create_ops-from-dir:JQ6eCm4.H80.-oc/create_ops --build-appliance-json /home/ls/work/fs_image/buck-out/gen/appliance/build_appliance/layer/layer.json --rpm-installer dnf --allowed-host-mount-target=//appliance:host_build_appliance --child-layer-target //fs_image/compiler/test_images:create_ops-from-dir --child-feature-json /dev/fd/62 --child-dependencies //fs_image/compiler/test_images:create_ops-dir /home/ls/work/fs_image/buck-out/gen/fs_image/compiler/test_images/create_ops-dir/create_opscreate_ops-dir
++ echo '{"features":[{"receive_sendstreams":[{"source":{"content_hash":null,"generator":null,"generator_args":[],"layer":null,"path":"sendstream","source":{"__BUCK_TARGET":"//fs_image/compiler/test_images:create_ops-dir"}}}],"target":"//fs_image/compiler/test_images:create_ops-from-dir"}],"target":"//fs_image/compiler/test_images:create_ops-from-dir"}'
At subvol create_ops
ERROR: lsetxattr hello security.selinux=user_u:object_r:base_t failed: Invalid argument
Traceback (most recent call last):
File "<string>", line 37, in <module>
File "<string>", line 35, in __run
File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/ls/work/fs_image/buck-out/gen/fs_image/compiler#link-tree/fs_image/compiler/compiler.py", line 197, in <module>
build_image(args).to_json_file(sys.stdout)
File "/home/ls/work/fs_image/buck-out/gen/fs_image/compiler#link-tree/fs_image/compiler/compiler.py", line 167, in build_image
builder(subvol)
File "/home/ls/work/fs_image/buck-out/gen/fs_image/compiler#link-tree/fs_image/compiler/items/make_subvol.py", line 85, in builder
pass
File "/usr/lib64/python3.7/contextlib.py", line 119, in __exit__
next(self.gen)
File "/home/ls/work/fs_image/buck-out/gen/fs_image/compiler#link-tree/fs_image/subvol_utils.py", line 715, in receive
yield
File "/usr/lib64/python3.7/contextlib.py", line 119, in __exit__
next(self.gen)
File "/home/ls/work/fs_image/buck-out/gen/fs_image/compiler#link-tree/fs_image/subvol_utils.py", line 222, in popen_as_root
check_popen_returncode(pr)
File "/home/ls/work/fs_image/buck-out/gen/fs_image/compiler#link-tree/fs_image/common.py", line 73, in check_popen_returncode
returncode=proc.returncode, cmd=proc.args,
subprocess.CalledProcessError: Command '['sudo', 'TMP=', '--', 'btrfs', 'receive', b'/proc/8151/fd/6']' returned non-zero exit status 1.
When running <genrule>.
When building rule //fs_image/compiler/test_images:create_ops-from-dir.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.