skaffold icon indicating copy to clipboard operation
skaffold copied to clipboard

Panic in interface conversion

Open tejal29 opened this issue 2 years ago • 2 comments

I was trying to run skaffold diagnose on a v1.37.2 on a skaffold.yaml and I ran into this error

panic: interface conversion: util.VersionedConfig is *v1.SkaffoldConfig, not *latest.SkaffoldConfig

goroutine 1 [running]:
github.com/GoogleContainerTools/skaffold/pkg/skaffold/parser.getConfigs({_, _}, {{0xc0001f03f0, 0x62}, {0x0, 0x0, 0x0}, {0xc000c08be0, 0x1, 0x1}, ...}, ...)
	/Users/tejaldesai/workspace/skaffold/pkg/skaffold/parser/config.go:137 +0x1025
github.com/GoogleContainerTools/skaffold/pkg/skaffold/parser.GetConfigSet({_, _}, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, ...})
	/Users/tejaldesai/workspace/skaffold/pkg/skaffold/parser/config.go:85 +0x19b
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.withFallbackConfig({_, _}, {_, _}, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...}, ...)
	/Users/tejaldesai/workspace/skaffold/cmd/skaffold/app/cmd/runner.go:109 +0xd5
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.runContext({_, _}, {_, _}, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
	/Users/tejaldesai/workspace/skaffold/cmd/skaffold/app/cmd/runner.go:82 +0xe5
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.createNewRunner({_, _}, {_, _}, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
	/Users/tejaldesai/workspace/skaffold/cmd/skaffold/app/cmd/runner.go:62 +0xfb
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.withRunner({0x76dbeb8, 0xc0004aa540}, {0x76bd5e0, 0xc000bd3360}, 0xc000c75568)
	/Users/tejaldesai/workspace/skaffold/cmd/skaffold/app/cmd/runner.go:50 +0xda
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.doBuild({0x76dbeb8, 0xc0004aa540}, {0x76bd5e0, 0xc000bd3360})
	/Users/tejaldesai/workspace/skaffold/cmd/skaffold/app/cmd/build.go:71 +0x156
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.(*builder).NoArgs.func1(0xc000b7f4a0, {0x5, 0x5, 0xc000c756a0})
	/Users/tejaldesai/workspace/skaffold/cmd/skaffold/app/cmd/commands.go:138 +0x9a
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd.applyPostRunHooks.func1(0xc000b2ab00, {0xc000c02300, 0x0, 0x3})
	/Users/tejaldesai/workspace/skaffold/cmd/skaffold/app/cmd/commands.go:185 +0x6e
github.com/spf13/cobra.(*Command).execute(0xc000b2ab00, {0xc000c022d0, 0x3, 0x3})
	/Users/tejaldesai/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0xaf0
github.com/spf13/cobra.(*Command).ExecuteC(0xc000b42000)
	/Users/tejaldesai/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x8b3
github.com/spf13/cobra.(*Command).ExecuteContextC(0xc000b42000, {0x76dbeb8, 0xc0004aa540})
	/Users/tejaldesai/go/pkg/mod/github.com/spf13/[email protected]/command.go:911 +0x8b
github.com/GoogleContainerTools/skaffold/cmd/skaffold/app.Run({0x76bc5c0, 0xc00019c008}, {0x76bc5c0, 0xc00019c010})
	/Users/tejaldesai/workspace/skaffold/cmd/skaffold/app/skaffold.go:50 +0x4a5
main.main()
	/Users/tejaldesai/workspace/skaffold/cmd/skaffold/skaffold.go:49 +0x2bd```


To reprodcue:
1.  git checkout v1.37.2 
2. LOCAL=true make
3. cat skaffold.yaml

apiVersion: skaffold/v2beta28 kind: Config build: artifacts: - image: leeroy-web-profiles context: leeroy-web-profiles - image: leeroy-app-profiles context: leeroy-app-profiles googleCloudBuild: projectId: tejal-gke1 deploy: kubectl: manifests: - leeroy-web-profiles/kubernetes/* profiles:

  • name: test deploy: kustomize: paths: - leeroy-app-profiles/kubernetes/test
  • name: staging deploy: kustomize: paths: - leeroy-app-profiles/kubernetes/staging
  • name: prod deploy: kustomize: paths: - leeroy-app-profiles/kubernetes/prod
4) Run skaffold diagnose

tejal29 avatar Jul 21 '22 21:07 tejal29

We should not let skaffold panic and have a better error message

tejal29 avatar Jul 21 '22 22:07 tejal29

Hi @tejal29 trying to reproduce this but the yaml file config you provided seems to be incorrect.

OladapoAjala avatar Aug 09 '22 20:08 OladapoAjala

Double checking if you are using skaffold v1.37.2 ? Also can you please include the error you are seeing?

tejal29 avatar Aug 10 '22 21:08 tejal29

image

I already setup v1.37.2. That's the error I get on running skaffold diagnose

I think I am missing a Dockerfile

OladapoAjala avatar Aug 10 '22 21:08 OladapoAjala

oh sorry. The example is on the cloud code tutorial i think. Let me check again.

Please, checkout out this folder https://github.com/GoogleCloudPlatform/cloud-deploy-tutorials/tree/main/tutorials/profiles/web-profiles and then copy paste the skaffold.yaml at https://github.com/GoogleCloudPlatform/cloud-deploy-tutorials/tree/main/tutorials/profiles/web-profiles

tejal29 avatar Aug 10 '22 22:08 tejal29

image

No errors @tejal29, I initially got an error before starting up minikube but after starting minikube, seems to work fine.

OladapoAjala avatar Aug 10 '22 22:08 OladapoAjala

got it. I think, the skaffold codebase, at many places we do an interface conversion which is not safe.

At times, you could see this error:

interface conversion: util.VersionedConfig is *v1.SkaffoldConfig, not *latest.SkaffoldConfig

We should find a way to avoid panicing. e.g. https://github.com/GoogleContainerTools/skaffold/blob/88a27ab9f81f337fa0fe4207aa829f632a01787e/pkg/skaffold/parser/config.go#L156

tejal29 avatar Aug 11 '22 00:08 tejal29

https://github.com/GoogleContainerTools/skaffold/pull/7770

Hi @tejal29 I have created a PR for this, let me know what you think before I try replicating this across other unsafe type assertions.

Thanks

OladapoAjala avatar Aug 11 '22 09:08 OladapoAjala