-
Notifications
You must be signed in to change notification settings - Fork 40
buildelement: Add the digest-environment config property #1991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
75aafc6
e5059e2
d38563d
614dc37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -219,6 +219,7 @@ def configure(self, node): | |
| def configure_dependencies(self, dependencies): | ||
|
|
||
| self.__layout = {} # pylint: disable=attribute-defined-outside-init | ||
| self.__digest_environment = {} # pylint: disable=attribute-defined-outside-init | ||
|
|
||
| # FIXME: Currently this forcefully validates configurations | ||
| # for all BuildElement subclasses so they are unable to | ||
|
|
@@ -227,9 +228,18 @@ def configure_dependencies(self, dependencies): | |
| for dep in dependencies: | ||
| # Determine the location to stage each element, default is "/" | ||
| location = "/" | ||
|
|
||
| if dep.config: | ||
| dep.config.validate_keys(["location"]) | ||
| location = dep.config.get_str("location") | ||
| dep.config.validate_keys(["digest-environment", "location"]) | ||
|
|
||
| location = dep.config.get_str("location", "/") | ||
|
|
||
| digest_var_name = dep.config.get_str("digest-environment", None) | ||
|
|
||
| if digest_var_name is not None: | ||
| element_list = self.__digest_environment.setdefault(digest_var_name, []) | ||
| element_list.append(dep.element) | ||
|
|
||
| try: | ||
| element_list = self.__layout[location] | ||
| except KeyError: | ||
|
|
@@ -285,10 +295,17 @@ def configure_sandbox(self, sandbox): | |
| command_dir = build_root | ||
| sandbox.set_work_directory(command_dir) | ||
|
|
||
| def stage(self, sandbox): | ||
| # Setup environment | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to move this from |
||
| sandbox.set_environment(self.get_environment()) | ||
| env = self.get_environment() | ||
|
|
||
| def stage(self, sandbox): | ||
| for digest_variable, element_list in self.__digest_environment.items(): | ||
| dummy_sandbox = sandbox.create_sub_sandbox() | ||
| self.stage_dependency_artifacts(dummy_sandbox, element_list) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case that we are staging elements in In the case that we have resulting overlaps in the resulting staged trees, I am worried that the resulting CAS digest may differ depending on the order in which the dependencies are declared in the buildstream Also there is a concern that overlaps may not turn out to be the same as when staging the element's overall dependencies. I think abderrahim also noted the sandbox staging seems a bit weird, or could be done nicer. I don't believe it should be algorithmically necessary to do the actual staging in order to calculate what the resulting CAS digest would be, probably there should be a way to support this better in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I find that statement weird given that I would also argue that if this is true, then it is orthogonal to the changes in this pull request. There is no difference between and in the current code, except for the fact that the former stages in a subdirectory of the build sandbox and the latter stages in a dummy sandbox.
Well, it depends. Currently an element plugin has no way to create a I think the difference we need to consider between the two approaches is whether or not to consider the dependencies? i.e. if I depend on gcc, is your expectation that this only gets the digest of the gcc artifact or should it be gcc and its runtime dependencies?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abderrahim writes:
Right, this text could be clarified further, this function says:
Which is not false, it does stage all of the specified element and it does so in staging order, however if you look at what the code does, it does not do any toplevel sorting of the input element sequence.
I think you are missing my meaning with your example. So here is my hypothesis; given your e.g.: What I am saying, is that with this implementation, the value of Configuration 1Here we stage element depends:
- a.bst
- b.bst
config:
digest-environment: DEPENDENCIES_CAS_DIGEST
- c.bst
config:
digest-environment: DEPENDENCIES_CAS_DIGESTConfiguration 2Here we do the same as configuration 1, except that depends:
- a.bst
- c.bst
config:
digest-environment: DEPENDENCIES_CAS_DIGEST
- b.bst
config:
digest-environment: DEPENDENCIES_CAS_DIGESTA closer lookThe body of with self._overlap_collector.session(action, path):
for dep in self.dependencies(selection):
dep._stage_artifact(sandbox, path=path, include=include, exclude=exclude, orphans=orphans, owner=self)And, looking at This means that the overall deterministic staging order of element Arguably this algorithm in And so I come back to your original argument:
I have a point of contention here. I have not yet looked at whether the Prove me wrong :)There may be other ways that I am wrong about this bug, but I can think of one possibility: It is possible that in the It would however be good to add a test with this merge request, asserting that we get the same CAS digest environment variable using both orderings of element
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree with this. I was just pointing out that if this behaviour is non-deterministic, then it's a pitfall that also applies to all plugins that make use of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe even worth regarding this a bug (design flaw) that should have its own ticket. |
||
| digest = dummy_sandbox.get_virtual_directory()._get_digest() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The linter complains here because What would be the best way forward?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would cast work if you know here that you're actually dealing with specific subtype? |
||
| env[digest_variable] = "{}/{}".format(digest.hash, digest.size_bytes) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another issue I discovered when testing with remote execution: If using this with recc/bazel (#1751), for setting a remote execution platform property (e.g. chrootRootDigest) then we also need to upload it to the remote execution CAS. |
||
|
|
||
| sandbox.set_environment(env) | ||
|
|
||
| # First stage it all | ||
| # | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.