Skip to content

[BUG] discover: panic occurs when using --cluster-uri #54

@synackd

Description

@synackd

Describe the bug
When using --cluster-uri to specify a cluster URI via the command line during static discovery, a panic occurs.

$ ./ochami discover static -f yaml -d @nodes.yaml --discovery-version 1 --cluster-uri https://demo.openchami.cluster
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xa2c25f]

goroutine 1 [running]:
github.com/OpenCHAMI/ochami/cmd.getBaseURI(0x11c7fe0, {0xc087ff, 0x3})
        /home/exouser/ochami/cmd/lib.go:349 +0x43f
github.com/OpenCHAMI/ochami/cmd.getBaseURISMD(...)
        /home/exouser/ochami/cmd/lib.go:286
github.com/OpenCHAMI/ochami/cmd.init.func75(0x11c7fe0, {0xc08bbf?, 0x4?, 0xc08b4f?})
        /home/exouser/ochami/cmd/discover-static.go:56 +0x37
github.com/spf13/cobra.(*Command).execute(0x11c7fe0, {0xc0003ca600, 0x8, 0x8})
        /home/exouser/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1019 +0xa91
github.com/spf13/cobra.(*Command).ExecuteC(0x11c9320)
        /home/exouser/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1148 +0x46f
github.com/spf13/cobra.(*Command).Execute(...)
        /home/exouser/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1071
github.com/OpenCHAMI/ochami/cmd.Execute()
        /home/exouser/ochami/cmd/root.go:68 +0x1e
main.main()
        /home/exouser/ochami/main.go:8 +0xf

To Reproduce
Steps to reproduce the behavior:

  1. Start with blank SMD and blank ochami config.
  2. Create a nodes.yaml.
  3. ochami discover static -f yaml -d @nodes.yaml --cluster-uri <cluster_base_uri>
  4. Observe panic above.

Expected behavior
--cluster-uri should correctly pass the base URI to ochami discover static and not panic.

Additional context
The issue is occurring in this block:

ochami/cmd/lib.go

Lines 338 to 352 in caf429e

if cmd.Flag("cluster-uri").Changed || (cmd.Flag("uri") != nil && cmd.Flag("uri").Changed) {
log.Logger.Debug().Msg("using base URI passed on command line")
ccc := config.ConfigClusterConfig{URI: cmd.Flag("cluster-uri").Value.String()}
switch serviceName {
case config.ServiceBSS:
ccc.BSS.URI = cmd.Flag("uri").Value.String()
case config.ServiceCloudInit:
ccc.CloudInit.URI = cmd.Flag("uri").Value.String()
case config.ServicePCS:
ccc.PCS.URI = cmd.Flag("uri").Value.String()
case config.ServiceSMD:
ccc.SMD.URI = cmd.Flag("uri").Value.String()
default:
return "", fmt.Errorf("unknown service %q specified when generating base URI", serviceName)
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions