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

Fix: Skaffold reloads unchanged, existing image again into the cluster #4983

Merged
merged 1 commit into from
Nov 12, 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
8 changes: 7 additions & 1 deletion pkg/skaffold/runner/load_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"strings"
"time"

"github.com/docker/distribution/reference"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/kubectl"
Expand Down Expand Up @@ -66,7 +68,11 @@ func (r *SkaffoldRunner) loadImages(ctx context.Context, out io.Writer, artifact
return fmt.Errorf("unable to retrieve node's images: %w", err)
}
}
if util.StrSliceContains(knownImages, artifact.Tag) {
normalizedImageRef, err := reference.ParseNormalizedNamed(artifact.Tag)
if err != nil {
return err
}
if util.StrSliceContains(knownImages, normalizedImageRef.String()) {
color.Green.Fprintln(out, "Found")
continue
}
Expand Down
20 changes: 18 additions & 2 deletions pkg/skaffold/runner/load_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,17 @@ func TestLoadImagesInKindNodes(t *testing.T) {
built: []build.Artifact{{Tag: "tag1"}, {Tag: "tag2"}},
deployed: []build.Artifact{{Tag: "tag1"}, {Tag: "tag2"}},
commands: testutil.
CmdRunOut("kubectl --context kubecontext --namespace namespace get nodes -ojsonpath='{@.items[*].status.images[*].names[*]}'", "tag1").
CmdRunOut("kubectl --context kubecontext --namespace namespace get nodes -ojsonpath='{@.items[*].status.images[*].names[*]}'", "docker.io/library/tag1").
AndRunOut("kind load docker-image --name other-kind tag2", "output: image loaded"),
},
{
description: "no new images",
cluster: "kind",
built: []build.Artifact{{Tag: "tag0"}, {Tag: "docker.io/library/tag1"}, {Tag: "docker.io/tag2"}, {Tag: "gcr.io/test/tag3"}, {Tag: "someregistry.com/tag4"}},
deployed: []build.Artifact{{Tag: "tag0"}, {Tag: "docker.io/library/tag1"}, {Tag: "docker.io/tag2"}, {Tag: "gcr.io/test/tag3"}, {Tag: "someregistry.com/tag4"}},
commands: testutil.
CmdRunOut("kubectl --context kubecontext --namespace namespace get nodes -ojsonpath='{@.items[*].status.images[*].names[*]}'", "docker.io/library/tag0 docker.io/library/tag1 docker.io/library/tag2 gcr.io/test/tag3 someregistry.com/tag4"),
},
{
description: "inspect error",
built: []build.Artifact{{Tag: "tag"}},
Expand Down Expand Up @@ -122,9 +130,17 @@ func TestLoadImagesInK3dNodes(t *testing.T) {
built: []build.Artifact{{Tag: "tag1"}, {Tag: "tag2"}},
deployed: []build.Artifact{{Tag: "tag1"}, {Tag: "tag2"}},
commands: testutil.
CmdRunOut("kubectl --context kubecontext --namespace namespace get nodes -ojsonpath='{@.items[*].status.images[*].names[*]}'", "tag1").
CmdRunOut("kubectl --context kubecontext --namespace namespace get nodes -ojsonpath='{@.items[*].status.images[*].names[*]}'", "docker.io/library/tag1").
AndRunOut("k3d image import --cluster other-k3d tag2", "output: image loaded"),
},
{
description: "no new images",
cluster: "k3d",
built: []build.Artifact{{Tag: "tag0"}, {Tag: "docker.io/library/tag1"}, {Tag: "docker.io/tag2"}, {Tag: "gcr.io/test/tag3"}, {Tag: "someregistry.com/tag4"}},
deployed: []build.Artifact{{Tag: "tag0"}, {Tag: "docker.io/library/tag1"}, {Tag: "docker.io/tag2"}, {Tag: "gcr.io/test/tag3"}, {Tag: "someregistry.com/tag4"}},
commands: testutil.
CmdRunOut("kubectl --context kubecontext --namespace namespace get nodes -ojsonpath='{@.items[*].status.images[*].names[*]}'", "docker.io/library/tag0 docker.io/library/tag1 docker.io/library/tag2 gcr.io/test/tag3 someregistry.com/tag4"),
},
{
description: "inspect error",
built: []build.Artifact{{Tag: "tag"}},
Expand Down