Skip to content

panic: runtime error: index out of range [0] with length 0 #7774

@sjoerd222888

Description

@sjoerd222888

Expected behavior

Skaffold is able to build the container image locally, push it and deploy it

Actual behavior

Skaffold crashes:

% skaffold run -p dev
Generating tags...
- gcr.io/███████ -> gcr.io/███████:███████
Checking cache...
- gcr.io/███████: Found. Tagging
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/cache.needsRemoteTagging.Tag({{0x140013ca900, 0x40}, {0x14001181090, 0x46}, {0x140011800f0, 0x47}}, {0x105a2fd18, 0x14000f3d7a0}, 0x14001079780, {0x140010b6e40})
      /private/tmp/skaffold-20220624-80169-j89lh6/pkg/skaffold/build/cache/details.go:94 +0x218
github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/cache.(*cache).Build(0x14001079780, {0x105a2fc70, 0x140001b2340}, {0x1059de580, 0x14000d04960}, 0x14000de5f80, {0x14000e1bc48, 0x1, 0x1}, {0x140010b6e40}, ...)
      /private/tmp/skaffold-20220624-80169-j89lh6/pkg/skaffold/build/cache/retrieve.go:85 +0xd04
github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner.(*Builder).Build(0x140005d7380, {0x105a2fd18, 0x14000de5ec0}, {0x1059de580, 0x14000d04960}, {0x14000e1bc48, 0x1, 0x1})
      /private/tmp/skaffold-20220624-80169-j89lh6/pkg/skaffold/runner/build.go:105 +0x8fc
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.doRun.func1({0x105a76820, 0x140005d7380}, {0x14001077150, 0x1, 0x1})
      /private/tmp/skaffold-20220624-80169-j89lh6/cmd/skaffold/app/cmd/run.go:45 +0x108
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.withRunner({0x105a2fc70, 0x140004b2240}, {0x1059de580, 0x14000aa07d0}, 0x1400061d540)
      /private/tmp/skaffold-20220624-80169-j89lh6/cmd/skaffold/app/cmd/runner.go:55 +0x184
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.doRun({0x105a2fc70, 0x140004b2240}, {0x1059de580, 0x14000aa07d0})
      /private/tmp/skaffold-20220624-80169-j89lh6/cmd/skaffold/app/cmd/run.go:44 +0x98
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.(*builder).NoArgs.func1(0x140002262c0, {0x140000af200, 0x0, 0x2})
      /private/tmp/skaffold-20220624-80169-j89lh6/cmd/skaffold/app/cmd/commands.go:138 +0x9c
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.applyPostRunHooks.func1(0x140002262c0, {0x140000af200, 0x0, 0x2})
      /private/tmp/skaffold-20220624-80169-j89lh6/cmd/skaffold/app/cmd/commands.go:185 +0x5c
github.com/spf13/cobra.(*Command).execute(0x140002262c0, {0x140000af1e0, 0x2, 0x2})
      /Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x998
github.com/spf13/cobra.(*Command).ExecuteC(0x140003c9680)
      /Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x7b8
github.com/spf13/cobra.(*Command).ExecuteContextC(0x140003c9680, {0x105a2fc70, 0x140004b2240})
      /Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:911 +0x74
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app.Run({0x1059dd5e0, 0x140001a6008}, {0x1059dd5e0, 0x140001a6010})
      /private/tmp/skaffold-20220624-80169-j89lh6/cmd/skaffold/app/skaffold.go:50 +0x3e4
main.main()
      /private/tmp/skaffold-20220624-80169-j89lh6/cmd/skaffold/skaffold.go:49 +0x29c

Information

  • Skaffold version: v1.39.1
  • Operating system: macOS Montery Version 12.5
  • Installed via: Homebrew
  • Contents of skaffold.yaml:
apiVersion: skaffold/v2alpha3
kind: Config

build:
  artifacts:
    - image: gcr.io/███████
      jib:
        project: ███████
deploy:
  kustomize:
    paths:
      - "k8s/base"
# use `skaffold run -p dev` to activate a profile
# see https://skaffold.dev/docs/environment/profiles/
profiles:
  - name: dev
    deploy:
      kustomize:
        paths:
          - "k8s/gke_dev"

Steps to reproduce the behavior

Having a skaffold project with the configuration shown below.

Accidentally trying to run

skaffold run -p dev

against a (wrongly selected) kind cluster context. Skaffold fails as expected.
Then connect to the correct cluster (gke) using glcloud:

gcloud container clusters get-credentials █████████ --zone █████████ --project █████████

The run skaffold again

skaffold run -p dev

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't workingpriority/p1High impact feature/bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions