Repository navigation
Conversation
After an external builder builds and releases a chaincode, Detector.Build creates the durable directory for the package, writes build-info.json and copies the release and bld directories into it. If one of the copies fails, for example because the build output has an absolute symlink, Build returned the error but left the directory and build-info.json behind. The next Build for the same package found build-info.json and returned the incomplete build as a cached instance, without running the builder again. Fixing the builder did not help until the directory was deleted by hand. Remove the durable directory when either copy fails, as Build already does when build-info.json cannot be written. Signed-off-by: Hamed Yousefi <hdyousefi@gmail.com>
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.
Type of change
Description
After an external builder runs
buildandrelease,Detector.Buildincore/container/externalbuilder/externalbuilder.gocreates the durable directory for the package, writesbuild-info.json, and then copies thereleaseandblddirectories into it withCopyDir.CopyDirrefuses some files, for example an absolute symlink, a symlink that points outside the directory, or a socket. When it fails, it removes its own destination, butBuildreturns without removing the durable directory.build-info.jsonstays, and if thebldcopy is the one that failed, the copiedreleasedirectory stays too. The earlier error paths inBuildalready remove the directory.On the next
Buildfor the same package,CachedBuildfindsbuild-info.jsonand returns the incomplete build as an instance, with no error, and the peer uses it to run the chaincode. Fixing the builder doesn't help, because the builder is not called again until someone deletes the directory underexternalbuilder/buildsby hand.This change removes the durable directory when either copy fails, the same way
Builddoes whenbuild-info.jsoncan't be written.Additional details
Tests:
testdata/symlinkbuilder, whosebuildleaves an absolute symlink in its output. It checks thatBuildfails, that the package directory is gone, and that a secondBuildfails the same way instead of returning a cached instance.BuildwithExpected an error, got nil.Ran:
go test -race ./core/container/externalbuilder/...passes.Related issues
Fixes #5635.