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

Prevent the cache from sending “Build in progress” events. #4038

Merged
merged 2 commits into from
May 4, 2020
Merged
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
7 changes: 4 additions & 3 deletions integration/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ func TestCacheAPITriggers(t *testing.T) {
t.Skip("skipping kind integration test")
}

// Run skaffold build first to cache artifacts.
// Run skaffold build first to fail quickly on a build failure
skaffold.Build().InDir("examples/getting-started").RunOrFail(t)

ns, _ := SetupNamespace(t)

rpcAddr := randomPort()
skaffold.Dev("--rpc-port", rpcAddr).InDir("examples/getting-started").InNs(ns.Name).RunBackground(t)

// Disable caching to ensure we get a "build in progress" event each time.
skaffold.Dev("--cache-artifacts=false", "--rpc-port", rpcAddr).InDir("examples/getting-started").InNs(ns.Name).RunBackground(t)
dgageot marked this conversation as resolved.
Show resolved Hide resolved

// Ensure we see a build triggered in the event log
_, entries := apiEvents(t, rpcAddr)
Expand Down
3 changes: 2 additions & 1 deletion integration/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ func setupSkaffoldWithArgs(t *testing.T, args ...string) {
// start a skaffold dev loop on an example
ns, _ := SetupNamespace(t)

skaffold.Dev(args...).InDir("testdata/dev").InNs(ns.Name).RunBackground(t)
// Disable caching to ensure we get a "build in progress" event each time.
skaffold.Dev(append([]string{"--cache-artifacts=false"}, args...)...).InDir("testdata/dev").InNs(ns.Name).RunBackground(t)

t.Cleanup(func() {
Run(t, "testdata/dev", "rm", "foo")
Expand Down
7 changes: 0 additions & 7 deletions pkg/skaffold/build/cache/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,9 @@ import (

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/tag"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/event"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
)

var (
// For testing
buildInProgress = event.BuildInProgress
)

func (c *cache) lookupArtifacts(ctx context.Context, tags tag.ImageTags, artifacts []*latest.Artifact) []cacheDetails {
details := make([]cacheDetails, len(artifacts))

Expand All @@ -41,7 +35,6 @@ func (c *cache) lookupArtifacts(ctx context.Context, tags tag.ImageTags, artifac

i := i
go func() {
buildInProgress(artifacts[i].ImageName)
details[i] = c.lookup(ctx, artifacts[i], tags[artifacts[i].ImageName])
wg.Done()
}()
Expand Down
3 changes: 0 additions & 3 deletions pkg/skaffold/build/cache/lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ func TestLookupLocal(t *testing.T) {
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
t.Override(&buildInProgress, func(string) {})

cache := &cache{
imagesAreLocal: true,
artifactCache: test.cache,
Expand Down Expand Up @@ -188,7 +186,6 @@ func TestLookupRemote(t *testing.T) {
return "", errors.New("unknown remote tag")
}
})
t.Override(&buildInProgress, func(string) {})

cache := &cache{
imagesAreLocal: false,
Expand Down
7 changes: 0 additions & 7 deletions pkg/skaffold/build/cache/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,9 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/tag"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/event"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
)

var (
// For testing
buildComplete = event.BuildComplete
)

func (c *cache) Build(ctx context.Context, out io.Writer, tags tag.ImageTags, artifacts []*latest.Artifact, buildAndTest BuildAndTestFn) ([]build.Artifact, error) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
Expand Down Expand Up @@ -94,7 +88,6 @@ func (c *cache) Build(ctx context.Context, out io.Writer, tags tag.ImageTags, ar
}

// Image is already built
buildComplete(artifact.ImageName)
entry := c.artifactCache[result.Hash()]
tag := tags[artifact.ImageName]

Expand Down
6 changes: 0 additions & 6 deletions pkg/skaffold/build/cache/retrieve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ func (t stubAuth) GetAllAuthConfigs() (map[string]types.AuthConfig, error) { ret

func TestCacheBuildLocal(t *testing.T) {
testutil.Run(t, "", func(t *testutil.T) {
t.Override(&buildComplete, func(string) {})
t.Override(&buildInProgress, func(string) {})

tmpDir := t.NewTempDir().
Write("dep1", "content1").
Write("dep2", "content2").
Expand Down Expand Up @@ -176,9 +173,6 @@ func TestCacheBuildLocal(t *testing.T) {

func TestCacheBuildRemote(t *testing.T) {
testutil.Run(t, "", func(t *testutil.T) {
t.Override(&buildComplete, func(string) {})
t.Override(&buildInProgress, func(string) {})

tmpDir := t.NewTempDir().
Write("dep1", "content1").
Write("dep2", "content2").
Expand Down