Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Vendor verification #1912

Merged
merged 26 commits into from
Jul 11, 2018
Merged

Vendor verification #1912

merged 26 commits into from
Jul 11, 2018

Conversation

sdboyer
Copy link
Member

@sdboyer sdboyer commented Jun 28, 2018

What does this do / why do we need it?

This makes automated vendor verification a reality. There's a lot that goes along with that, but everything in this PR falls under that heading. The list is:

  1. There are fields in each Gopkg.lock [[project]] indicating the pruning rules that were applied for that project
  2. There's also a per-project digest field, which is computed on the basis of the pruned tree
  3. inputs-digest is completely gone, replaced by a system that directly computes whether the current lock satisfies the inputs, rather than relying on a coarse-grained, merge conflict-inducing hash digest
  4. input-imports was added to [solve-meta]; it is a list of all import and required from the input project
  5. When writing out vendor, only the subset of projects that actually need to be written are written. There are a buncha cases there:
    • version changed
    • revision changed
    • source changed
    • package set changed
    • pruning options changed
    • hash changed/missing from vendor (can only happen if somebody manually monkeyed with vendor)

It's annoying that we have to have input-imports. Without an explicit list, though, we can't determine if there are were any imports removed from the current project without having to fully explore the import graph for the whole project, in order to definitively find orphaned/unimported packages. That's costly - in particular, it would mean that in CI, we'd have to have a populated cache in order to perform basic sync checks. This is by far the better option, as it means that we can fully check sync between all three states (manifest/code, lock, vendor) without needing anything other than the states themselves. It's all self-contained.

Remaining TODOs:

  • Update current tests
  • Text output for verify.LockSatisfaction; these will be written out as an explanation for why dep is choosing to solve
  • Bunch more tests to check permutations of deltas to make sure the DeltaWriter is on point
  • Update docs
  • env var to allow using the old safewriter behavior, in the event of bugs (This is going to be prohibitively costly)

Couple notes about followup:

  • i'm gonna roll dep check in with this release, too, as it's almost trivial to implement overtop the foundation ofverify.LockSatisfaction. Separate PR, though. Will also roll dry run output into this.
  • The hashing algo needs to change to ignore symlinks. Also will be a follow-up PR, and i'll make the change without bumping the HashVersion, even though it will technically change the algorithm.
  • We'll want a field in Gopkg.toml to allow skipping vendor verification on a per-project basis. Follow-up PR.

What should your reviewer look out for in this PR?

Couldn't point to anything in particular; this is a long time coming, and there's a lot to it. If i had time to break it down further, i would, but we'll need to let there be a bit of a bumpy ride...

Which issue(s) does this PR fix?

fixes #121
fixes #1276
fixes #1496

@darkowlzz
Copy link
Collaborator

darkowlzz commented Jul 1, 2018

This is great. Went through the dep changes and it makes sense.
Couldn't go through all the GPS changes.

Since this removes inputs-digest, I've added #1496 to the fixes list.

@sdboyer
Copy link
Member Author

sdboyer commented Jul 1, 2018

@darkowlzz awesome, thank you!

sdboyer added 11 commits July 3, 2018 01:41
First steps towards a better in-sync checking system that does not rely
on a merge-conflict-prone explicit hash digest.
This mostly supplants the hash comparison-based checking, though it's
still in rough form.
This is the first step towards being able to a more expansive type - one
that carries the pruning and digest information - directly within the
existing Lock interface.
This is a start at isolating verification logic into a discrete package.
Not sure how far we'll be able to make this go without creating some
import loops.
THis includes changes across both dep and gps towards transparently
working with vendor trees that are both configurably pruned and
verifiable.
We're now relying entirely on real validation - no more hash digest
comparisons and meaningless conflicts!
Both of these subsystems make more sense in the verification package
than in gps itself.
This encompasses the first pass at the new, more abstracted diffing
system, and the DeltaWriter implementation on top of it. Tests are
needed, but cursory testing indicates that we successfully capture all
types of diffs and regenerate only the subset of projects that actually
need to be touched.
Also convert the SafeWriter to use LockDelta.
Add output to all of the information we assemble when checking if the
Lock satisfies the current input set.

Also some refactoring of the ctx.LoadProject() process to have fewer
partial states.
@sdboyer sdboyer force-pushed the verify-vendor branch 3 times, most recently from b17ee5f to 2478e99 Compare July 3, 2018 22:58
Tests are now almost completely working, after updating all the outputs
to the new lock format. There is also an assortment of other fixes in
here, mostly related to fixing nil pointer panics, that were uncovered
by fixing up these tests.
There was no real need to delineate between Lock and LockWithImports.
The old Lock had the InputsDigest concept, which was even less feasible
for theoretical implementations of Lock to have, so this can't possibly
be more harmful.
Also a bunch of docs for the verify package.
@sdboyer sdboyer changed the title [WIP] Vendor verification Vendor verification Jul 9, 2018
Some tests were complaining of a data race when writing to ctx.Out on a
vendor verification failure. It's not clear why those tests were
failing, but the complaint became a forcing function to refactor the
previously-sloppy use of a channel and os.Exit(1) within a goroutine to
encapsulation in a method on dep.Project.
@sdboyer
Copy link
Member Author

sdboyer commented Jul 11, 2018

OK, in we go!

@sdboyer sdboyer merged commit 5a7960a into golang:master Jul 11, 2018
@sdboyer sdboyer mentioned this pull request Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants