vendor: sort imports to prevent vendoring race condition#40875
Merged
thaJeztah merged 1 commit intomoby:masterfrom Apr 30, 2020
Merged
vendor: sort imports to prevent vendoring race condition#40875thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah merged 1 commit intomoby:masterfrom
Conversation
If both a "versioned" and "non-versioned" version of a dependency exists in vendor.conf, the "longest" path should be cloned last, otherwise the versioned dependency may be deleted when cloning its non-versioned variant. For example, with the following vendor.conf: github.com/coreos/go-systemd/v22 v22.0.0 github.com/coreos/go-systemd v17 Running vndr would; 1. recursively delete "vendor/src/github.com/coreos/go-systemd/v22: 2. start cloning "github.com/coreos/go-systemd/v22" 3. recursively delete "vendor/src/github.com/coreos/go-systemd" 4. start cloning "github.com/coreos/go-systemd" This would lead to a conflicting situation; step 3. will remove the dependency that was previously cloned (or in the process of being cloned). This patch sorts the dependencies by import-path, cloning the shortest import paths first, which should prevent the race condition. Signed-off-by: Sebastiaan van Stijn <[email protected]>
AkihiroSuda
approved these changes
Apr 29, 2020
Member
Author
|
bringing this one in to unblock #40873 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If both a "versioned" and "non-versioned" version of a dependency
exists in vendor.conf, the "longest" path should be cloned last,
otherwise the versioned dependency may be deleted when cloning its
non-versioned variant.
For example, with the following vendor.conf:
Running vndr would;
This would lead to a conflicting situation; step 3. will remove
the dependency that was previously cloned (or in the process
of being cloned).
This patch sorts the dependencies by import-path, cloning the
shortest import paths first, which should prevent the race condition.
This should address the issue seen in #40873 (comment)