Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/container/externalbuilder/externalbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,14 @@ func (d *Detector) Build(ccid string, mdBytes []byte, codeStream io.Reader) (*In
durableReleaseDir := filepath.Join(durablePath, "release")
err = CopyDir(logger, buildContext.ReleaseDir, durableReleaseDir)
if err != nil {
os.RemoveAll(durablePath)
return nil, errors.WithMessagef(err, "could not move or copy build context release to persistent location '%s'", durablePath)
}

durableBldDir := filepath.Join(durablePath, "bld")
err = CopyDir(logger, buildContext.BldDir, durableBldDir)
if err != nil {
os.RemoveAll(durablePath)
return nil, errors.WithMessagef(err, "could not move or copy build context bld to persistent location '%s'", durablePath)
}

Expand Down
21 changes: 21 additions & 0 deletions core/container/externalbuilder/externalbuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,27 @@ var _ = Describe("externalbuilder", func() {
Expect(err).To(MatchError("could not create dir 'path/to/nowhere/fake-package-id' to persist build output: mkdir path/to/nowhere/fake-package-id: no such file or directory"))
})
})

Context("when the build output cannot be copied to the durable path", func() {
BeforeEach(func() {
detector.Builders = externalbuilder.CreateBuilders([]peer.ExternalBuilder{
{Path: "testdata/symlinkbuilder", Name: "symlinkbuilder"},
}, "mspid")
})

It("removes the partial build output", func() {
_, err := detector.Build("fake-package-id", md, codePackage)
Expect(err).To(MatchError(ContainSubstring("could not move or copy build context bld to persistent location")))
Expect(filepath.Join(durablePath, "fake-package-id")).NotTo(BeAnExistingFile())

Expect(codePackage.Close()).To(Succeed())
codePackage, err = os.Open("testdata/normal_archive.tar.gz")
Expect(err).NotTo(HaveOccurred())
instance, err := detector.Build("fake-package-id", md, codePackage)
Expect(err).To(MatchError(ContainSubstring("could not move or copy build context bld to persistent location")))
Expect(instance).To(BeNil())
})
})
})

Describe("CachedBuild", func() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

ln -s /etc/hosts "$3/absolute-link"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if grep -q "fake-metadata" "$2/metadata.json" ; then
exit 0
fi

exit 1