pingcap / pingcap/tiup

panic: can't get a free port

Open
#1,881 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted type/bug
Dominant language
Go
Stars
466
Forks
338
Avg merge
3d 7h
Merged PRs (30d)
8

Description

the error is not friendly when --host does not exist

172.16.7.122@1root:~# tiup playground v4.0.14 --host 172.15.4.111
tiup is checking updates for component playground ...
A new version of playground is available:
The latest version: v1.9.5
Local installed version:
Update current component: tiup update playground
Update all components: tiup update --all

The component playground version is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/playground-v1.9.5-linux-amd64.tar.gz 6.91 MiB / 6.91 MiB 100.00% 2.85 MiB/s
Starting component playground: /root/.tiup/components/playground/v1.9.5/tiup-playground /root/.tiup/components/playground/v1.9.5/tiup-playground v4.0.14 --host 172.15.4.111
panic: can't get a free port

goroutine 1 [running]:
github.com/pingcap/tiup/pkg/utils.MustGetFreePort(...)
github.com/pingcap/tiup/pkg/utils/freeport.go:42
github.com/pingcap/tiup/components/playground/instance.NewPDInstance({0x0, 0x0}, {0xc000120880, 0x1d}, {0x7ffd8c35b492, 0x0}, {0x0, 0x0}, 0x0)
github.com/pingcap/tiup/components/playground/instance/pd.go:43 +0x19d
main.(*Playground).addInstance(0xc0000fd400, {0xfe8d8d, 0x7f1564dfc270}, {{0x0, 0x0}, {0x0, 0x0}, 0x1, {0x0, 0x0}, ...})
github.com/pingcap/tiup/components/playground/playground.go:639 +0x325
main.(*Playground).bootCluster(0xc0000fd400, {0x115be50, 0xc0002bdce0}, 0x1, 0x18fe200)
github.com/pingcap/tiup/components/playground/playground.go:809 +0x725
main.execute.func3(0xc0000cbb80, {0xc0002bc300, 0x1, 0x3})
github.com/pingcap/tiup/components/playground/main.go:289 +0x875
github.com/spf13/cobra.(*Command).execute(0xc0000cbb80, {0xc0000d0050, 0x3, 0x3})
github.com/spf13/cobra@v1.3.0/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000cbb80)
github.com/spf13/cobra@v1.3.0/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.3.0/command.go:902
main.execute()
github.com/pingcap/tiup/components/playground/main.go:354 +0x1059
main.main()
github.com/pingcap/tiup/components/playground/main.go:631 +0x3f
172.16.7.122@2root:~#

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with tiup playground v4.0.14 --host 172.15.4.111. Start with pkg/utils/freeport.go:42 and components/playground/instance/pd.go:43, then trace the call through components/playground/playground.go. Done means an invalid --host no longer produces an unfriendly panic and instead reports a useful error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.