Skip to content
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

Never prune seed packages from build #295

Merged
merged 3 commits into from May 2, 2019

Conversation

ccollins476ad
Copy link
Contributor

NOTE: This PR includes #293 (another split image fix). That one should be merged before this.

This is a fix for split images.

During dependency resolution, newt executes a phase called "imposter pruning." A package is an imposter if it is in the dependency graph by virtue of its own syscfg defines and overrides. For example, say we have a package foo:

    pkg.name: foo
    syscfg.defs:
        FOO_SETTING:
            value: 1

Then we have a BSP package:

    pkg.name: my_bsp
    pkg.deps.FOO_SETTING:
        - foo

If this is the only dependency on foo, then foo is an imposter. It should be removed from the graph, and its syscfg defines and overrides should be deleted.

This commit changes this procedure slightly. Now, only non-seed-packages are subject to imposter pruning. This change is necessary due to the way newt builds split images. A split image consits of two parts: 1) loader, and 2) application. The loader is self-contained, whereas the application is allowed to depend on packages in the loader. When newt builds the application, it considers all the packages in the loader to be seed packages for the application. Since all these packages are guaranteed to be present (they are already built in to the loader), they must not be pruned.

The fix is to never prune seed packages. While this fix specifically addresses split images, conceptually it makes sense to never prune seed packages for non-split builds as well. If the project.yml file points to a package, that package should be included, even if newt thinks it is not needed.

In a split build, three rounds of dependency resolution occur:
1. Master set (all packages in the build)
2. Loader set
3. App set

Each round produces new ResolvePackage objects.  Conceptually, this is
wrong, since the loader set and app set are meant to share packages, not
duplicate them.  This was causing a problem during API resolution: the
Resolution object maps API names to *ResolvePackage, with the package
pointers coming from the master set.  During rounds 2 and 3, lookups in
this map yield packages that don't exist in the current working set,
resulting in this error:

```
Error: Unexpected unsatisfied API: foo; required by: bar
```
This is a fix for split images.

During dependency resolution, newt executes a phase called "imposter
pruning."  A package is an imposter if it is in the dependency graph by
virtue of its own syscfg defines and overrides.  For example, say we
have a package `foo`:

```
    pkg.name: foo
    syscfg.defs:
        FOO_SETTING:
            value: 1
```

Then we have a BSP package:

```
    pkg.name: my_bsp
    pkg.deps.FOO_SETTING:
        - foo
```

If this is the only dependency on `foo`, then `foo` is an imposter.  It
should be removed from the graph, and its syscfg defines and overrides
should be deleted.

This commit changes this procedure slightly.  Now, only
*non-seed-packages* are subject to imposter pruning.  This change is
necessary due to the way newt builds split images.  A split image
consits of two parts: 1) loader, and 2) application.  The loader is
self-contained, whereas the application is allowed to depend on packages
in the loader.  When newt builds the application, it considers all the
packages in the loader to be seed packages for the application.  Since
all these packages are guaranteed to be present (they are already built
in to the loader), they must not be pruned.

The fix is to never prune seed packages.  While this fix specifically
addresses split images, conceptually it makes sense to never prune seed
packages for non-split builds as well.  If the `project.yml` file points
to a package, that package should be included, even if newt thinks it is
not needed.
Copy link
Member

@utzig utzig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ccollins476ad ccollins476ad merged commit ee3fd08 into apache:master May 2, 2019
@ccollins476ad ccollins476ad deleted the no-prune-seed branch May 2, 2019 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants