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

🐛 Handle missing containerless-deps #349

Merged
merged 3 commits into from
Oct 2, 2024

Conversation

aufi
Copy link
Member

@aufi aufi commented Oct 2, 2024

Missing container-kantra-deps setup caused kantra analyze-bin command failure (details below). Appears when someone skips README step cloning and moving https://github.com/eemcmullan/containerless-kantra-deps.git to ~/.kantra

Adding check and error message to fail nicely.

Related to: #338

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xb8c330]

goroutine 1 [running]:
github.com/konveyor-ecosystem/kantra/cmd.(*analyzeBinCommand).walkRuleFilesForLabels.walkRuleSets.func1({0xc0000434c0, 0x1e}, {0x0?, 0x0?}, {0xf049e0, 0xc00026f0b0})
	/home/.../go/src/github.com/konveyor/kantra/cmd/util.go:37 +0x30
path/filepath.WalkDir({0xc0000434c0, 0x1e}, 0xc00020fa08)
	/usr/lib/golang/src/path/filepath/path.go:531 +0x9c
github.com/konveyor-ecosystem/kantra/cmd.(*analyzeBinCommand).walkRuleFilesForLabels(0x7f7c626c24e8?, {0xdb3b53, 0x12})
	/home/.../go/src/github.com/konveyor/kantra/cmd/analyze-bin.go:433 +0xc5
github.com/konveyor-ecosystem/kantra/cmd.(*analyzeBinCommand).fetchLabels(0xc000196b00, {0xe?, 0x1?}, 0x14?, 0x0?, {0xf04740, 0xc00026f080})
	/home/.../go/src/github.com/konveyor/kantra/cmd/analyze-bin.go:418 +0x4d
github.com/konveyor-ecosystem/kantra/cmd.(*analyzeBinCommand).Validate(0xc000196b00, {0xf0d608, 0xc0000bb3b0})
	/home/.../go/src/github.com/konveyor/kantra/cmd/analyze-bin.go:315 +0x22f
github.com/konveyor-ecosystem/kantra/cmd.NewAnalyzeBinCmd.func1(0xc000284f08, {0xc00029e060?, 0x4?, 0xda66ad?})
	/home/.../go/src/github.com/konveyor/kantra/cmd/analyze-bin.go:95 +0x192
github.com/spf13/cobra.(*Command).execute(0xc000284f08, {0xc00029e000, 0x6, 0x6})
	/home/.../go/pkg/mod/github.com/spf13/[email protected]/command.go:970 +0xa44
github.com/spf13/cobra.(*Command).ExecuteC(0x152ec00)
	/home/.../go/pkg/mod/github.com/spf13/[email protected]/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/home/.../go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
github.com/spf13/cobra.(*Command).ExecuteContext(...)
	/home/.../go/pkg/mod/github.com/spf13/[email protected]/command.go:1034
github.com/konveyor-ecosystem/kantra/cmd.Execute()
	/home/.../go/src/github.com/konveyor/kantra/cmd/root.go:67 +0x10c
main.main()
	/home/.../go/src/github.com/konveyor/kantra/main.go:8 +0xf

Missing container-kantra-deps setup caused kantra analyze-bin command
segfault. Adding check and error message to fail nicely.

Related to: konveyor#338

Signed-off-by: Marek Aufart <[email protected]>
cmd/analyze-bin.go Outdated Show resolved Hide resolved
path := filepath.Join(b.homeKantraDir, RulesetsLocation)
path := filepath.Join(b.homeKantraDir, "rulesets")
if _, err := os.Stat(path); os.IsNotExist(err) {
b.log.Error(err, "cannot find ruleset, ensure containerless-kantra-deps are in place")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets change this to specifically mention that we can't find the rulesets directory. Then add validation for the other deps

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will make this logic more specific and move most of it to the command validation function.

requiredDirs := []string{b.homeKantraDir, filepath.Join(b.homeKantraDir, "rulesets"), filepath.Join(b.homeKantraDir, JavaBundlesLocation), filepath.Join(b.homeKantraDir, JDTLSBinLocation)}
for _, path := range requiredDirs {
if _, err := os.Stat(path); os.IsNotExist(err) {
b.log.Error(err, "cannot open required path, ensure that container-less dependencies are installed")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example error messages for missing rulesets:

ERRO[0000] cannot open required path, ensure that container-less dependencies are installed  error="stat /home/.../.kantra/rulesets: no such file or directory"

@eemcmullan
Copy link
Collaborator

Thank you!

@eemcmullan eemcmullan merged commit 9f8a286 into konveyor:main Oct 2, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants