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

Panic if invalid component name is entered during odo create #2826

Closed
johnmcollier opened this issue Apr 6, 2020 · 3 comments · Fixed by #2839
Closed

Panic if invalid component name is entered during odo create #2826

johnmcollier opened this issue Apr 6, 2020 · 3 comments · Fixed by #2839
Assignees
Labels
area/devfile-spec Issues or PRs related to the Devfile specification and how odo handles and interprets it. kind/bug Categorizes issue or PR as related to a bug. priority/Medium Nice to have issue. Getting it done before priority changes would be great.
Projects

Comments

@johnmcollier
Copy link
Member

johnmcollier commented Apr 6, 2020

/kind bug

What versions of software are you using?

Operating System:
macOS

Output of odo version:
master

How did you run odo exactly?

I was trying to pull down the open liberty devfile and use it with a sample project. When I ran odo create openliberty, I got the following error:

Johns-MacBook-Pro-3:openLiberty johncollier$ odo create openliberty
 ✗  Checking if the specified component type is supported devfile component type [76119ns]

Please run 'odo catalog list components' for a list of supported devfile component types
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xd8 pc=0x22ed14e]

goroutine 1 [running]:
github.com/openshift/odo/pkg/config.(*LocalConfigInfo).ConfigFileExists(...)
	/Users/johncollier/go/src/github.com/openshift/odo/pkg/config/config.go:324
github.com/openshift/odo/pkg/odo/cli/component.(*CreateOptions).Complete(0xc0001b63c0, 0xc00090c240, 0x6, 0xc0004066c0, 0xc00055a5e0, 0x1, 0x1, 0x2, 0x288a1df)
	/Users/johncollier/go/src/github.com/openshift/odo/pkg/odo/cli/component/create.go:408 +0x67e
github.com/openshift/odo/pkg/odo/genericclioptions.GenericRun(0x2beb700, 0xc0001b63c0, 0xc0004066c0, 0xc00055a5e0, 0x1, 0x1)
	/Users/johncollier/go/src/github.com/openshift/odo/pkg/odo/genericclioptions/runnable.go:29 +0xb8
github.com/openshift/odo/pkg/odo/cli/component.NewCmdCreate.func1(0xc0004066c0, 0xc00055a5e0, 0x1, 0x1)
	/Users/johncollier/go/src/github.com/openshift/odo/pkg/odo/cli/component/create.go:709 +0x5e
github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).execute(0xc0004066c0, 0xc00055a5c0, 0x1, 0x1, 0xc0004066c0, 0xc00055a5c0)
	/Users/johncollier/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:702 +0x289
github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc00043bb00, 0x0, 0x0, 0x0)
	/Users/johncollier/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:783 +0x2ca
github.com/openshift/odo/vendor/github.com/spf13/cobra.(*Command).Execute(...)
	/Users/johncollier/go/src/github.com/openshift/odo/vendor/github.com/spf13/cobra/command.go:736
main.main()
	/Users/johncollier/go/src/github.com/openshift/odo/cmd/odo/odo.go:83 +0x5c8

But if I run odo create openLiberty, everything runs fine:

Johns-MacBook-Pro-3:openLiberty johncollier$ odo create openLiberty
 ✓  Checking if the specified component type is supported devfile component type [426344ns]
 ✓  Validating component [111322ns]

Please use `odo push` command to create the component with source deployed

/area devfile

@openshift-ci-robot openshift-ci-robot added kind/bug Categorizes issue or PR as related to a bug. area/devfile-spec Issues or PRs related to the Devfile specification and how odo handles and interprets it. priority/Medium Nice to have issue. Getting it done before priority changes would be great. labels Apr 6, 2020
@johnmcollier
Copy link
Member Author

johnmcollier commented Apr 6, 2020

I found the cause of the bug: When experimental is set to true, we're returning a partially created CLI context, one that doesn't have localConfiguration set:

https://github.com/openshift/odo/blob/master/pkg/odo/genericclioptions/context.go#L418-L432

In my opinion, we should not be mixing and matching the CLI contexts for odo-s2i and odo-devfile. This will lead to bugs and us including things in the context that aren't needed (such as the oc client when dealing with devfiles)

@GeekArthur
Copy link
Contributor

I am pretty sure the use case creating s2i component with experimental mode enabled works before, the root cause this PR #2762 causes the regression as it modifies the context creation function that is used by s2i component. With that changes, currently If user wants to create s2i component with experimental mode enabled, it goes to devfile context code path instead of s2i context code path. We should separate the context for s2i and devfile to fix this.

Thanks @johnmcollier points that out

@GeekArthur
Copy link
Contributor

FWIW, we call the context creation function here https://github.com/openshift/odo/blob/master/pkg/odo/cli/component/create.go#L396 during odo create

@elsony elsony added this to For consideration in Sprint 182 via automation Apr 7, 2020
@elsony elsony moved this from For consideration to To do in Sprint 182 Apr 7, 2020
Sprint 182 automation moved this from To do to Done Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devfile-spec Issues or PRs related to the Devfile specification and how odo handles and interprets it. kind/bug Categorizes issue or PR as related to a bug. priority/Medium Nice to have issue. Getting it done before priority changes would be great.
Projects
No open projects
Sprint 182
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants