`tiup mirror init` while mirror set to empty directory creates broken mirror
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 466
- Forks
- 338
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 8
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
- What did you do?
If the mirror is set to an empty directory, and tiup mirror init is executed, a mirror is created with an invalid definition that cannot be used.
- What did you expect to see?
If the mirror is set to an empty directory, tiup mirror init should probably fail with an error.
- What did you see instead?
$ unset TIUP_HOME TIUP_MIRRORS
rm -rf tiup-mirror tiup-home
mkdir -p tiup-home/bin
curl -sSL https://tiup-mirrors.pingcap.com/root.json > tiup-home/bin/root.json
export TIUP_HOME=$PWD/tiup-home
$ /Users/kolbe/Devel/go/bin/tiup mirror init tiup-mirror
/Users/kolbe/Devel/go/bin/tiup mirror genkey
/Users/kolbe/Devel/go/bin/tiup mirror grant kolbe
Private key has been writeen to /Users/kolbe/tiup-home/keys/private.json
The --name is not specified, using kolbe as default
Error: introduce a fresher via the internet is not allowd, please set you mirror to a local one
$ export TIUP_MIRRORS=/Users/kolbe/tiup-mirror
$ /Users/kolbe/Devel/go/bin/tiup mirror grant kolbe
WARNING: both mirror config()
and TIUP_MIRRORS(/Users/kolbe/tiup-mirror) have been set.
Setting mirror to TIUP_MIRRORS(/Users/kolbe/tiup-mirror)
The --name is not specified, using kolbe as default
$ rm -r tiup-mirror
$ mkdir tiup-mirror
$ /Users/kolbe/Devel/go/bin/tiup mirror init tiup-mirror
$ /Users/kolbe/Devel/go/bin/tiup mirror publish tidb-server 5.0.0-master-nightly ~/Devel/git/pingcap/tidb/tidb-server.tgz bin/tidb-server
uploading /Users/kolbe/Devel/git/pingcap/tidb/tidb-server.tgz with 44467921 bytes, sha256: 9b34ccb9841629d114f2c3edc008a798daec9ceb3af03d7ab39b1ec7c2b2b5e1 ...
Error: read manifest from mirror(/Users/kolbe/tiup-mirror) failed: not enough signatures (0) for threshold 1 in timestamp.json
Here are the steps to resolve:
unset TIUP_MIRRORS
tiup mirror set https://tiup-mirrors.pingcap.com
remove your existing mirror directory
tiup mirror init
tiup mirror set
tiup mirror grant
tiup mirror publish
$ unset TIUP_MIRRORS
$ /Users/kolbe/Devel/go/bin/tiup mirror set https://tiup-mirrors.pingcap.com
WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json
You can revoke this by remove /Users/kolbe/tiup-home/bin/7b8e153f2e2d0928.root.json
Set mirror to https://tiup-mirrors.pingcap.com success
$ rm -r tiup-mirror/
$ /Users/kolbe/Devel/go/bin/tiup mirror init $PWD/tiup-mirror
$ /Users/kolbe/Devel/go/bin/tiup mirror set $PWD/tiup-mirror
Set mirror to /Users/kolbe/tiup-mirror success
$ /Users/kolbe/Devel/go/bin/tiup mirror grant kolbe
The --name is not specified, using kolbe as default
$ /Users/kolbe/Devel/go/bin/tiup mirror publish tidb-server 5.0.0-master-nightly ~/Devel/git/pingcap/tidb/tidb-server.tgz bin/tidb-server
uploading /Users/kolbe/Devel/git/pingcap/tidb/tidb-server.tgz with 44467921 bytes, sha256: 9b34ccb9841629d114f2c3edc008a798daec9ceb3af03d7ab39b1ec7c2b2b5e1 ...
Creating component tidb-server
- What version of TiUP are you using (
tiup --version)?
Built usinggo get github.com/pingcap/tiup.
$ /Users/kolbe/Devel/go/bin/tiup --version
1.4.1 tiup
Go Version: go1.16.3
Git Ref: Unknown
GitHash: Unknown```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with tiup mirror init pointed at an empty directory, then inspect the implementation of the tiup mirror init command and its mirror metadata handling. Done means initialization either creates a valid mirror or fails clearly before leaving a broken mirror that later causes the timestamp signature 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
- 42/100