pingcap / dumpling

Dumpling is a fast, easy-to-use tool written by Go for dumping data from the database(MySQL, TiDB...) to local/cloud(S3, GCP...) in multifarious formats(SQL, CSV...).
Apache License 2.0
280 stars 85 forks source link

`-h` and `--host` don't behave the same #312

Closed dveeden closed 2 years ago

dveeden commented 3 years ago

Bug Report

From the dumpling usage info:

  -h, --host string                       The host to connect to (default "127.0.0.1")

So I would expect -h and --host to do the same.

  1. What did you do? If possible, provide a recipe for reproducing the error.

tiup dumpling -h host and tiup dumpling --host host

  1. What did you expect to see?

The same output from both commands

  1. What did you see instead?

with -h:

flag needs an argument: 'h' in -h

This didn't happen with --host

  1. Versions of the cluster

    • Dumpling version (run dumpling -V):

      Release version: v5.1.0
      Git commit hash: 292cbe6c9da0f53a262332d7711dd6ba96567411
      Git branch:      heads/refs/tags/v5.1.0
      Build timestamp: 2021-06-24 07:09:21Z
      Go version:      go version go1.16.4 linux/amd64
lichunzhu commented 3 years ago

That's a tiup issue. Try:

tiup -- dumpling -h host
fubinzh commented 3 years ago

/severity minor

dveeden commented 3 years ago

So this is the same problem as https://github.com/pingcap/tiup/issues/1488 ?

lichunzhu commented 3 years ago

They are similar but are not totally the same.

dveeden commented 2 years ago

Looks like tiup -- dumpling doesn't work anymore.

[dvaneeden@dve-carbon ~]$ tiup -v
1.5.6 tiup
Go Version: go1.16.7
Git Ref: v1.5.6
GitHash: 1d1478dbec0d06ef5e909d3323331914538d4cb0
[dvaneeden@dve-carbon ~]$ tiup dumpling -u foo
Starting component `dumpling`: /home/dvaneeden/.tiup/components/dumpling/v5.2.1/dumpling -u foo
Release version: v5.2.1
Git commit hash: 4e012e54ce89fab9551e7ff58ebcffe57590244a
Git branch:      heads/refs/tags/v5.2.1
Build timestamp: 2021-09-08 02:31:43Z
Go version:      go version go1.16.4 linux/amd64

[2021/09/30 09:54:13.876 +02:00] [INFO] [versions.go:55] ["Welcome to dumpling"] ["Release Version"=v5.2.1] ["Git Commit Hash"=4e012e54ce89fab9551e7ff58ebcffe57590244a] ["Git Branch"=heads/refs/tags/v5.2.1] ["Build timestamp"="2021-09-08 02:31:43"] ["Go Version"="go version go1.16.4 linux/amd64"]

create dumper failed: sql: SELECT version(): Error 1045: Access denied for user 'foo'@'127.0.0.1' (using password: NO)
Error: run `/home/dvaneeden/.tiup/components/dumpling/v5.2.1/dumpling` (wd:/home/dvaneeden/.tiup/data/SkTl80D) failed: exit status 1
[dvaneeden@dve-carbon ~]$ tiup dumpling -- -u foo
Starting component `dumpling`: /home/dvaneeden/.tiup/components/dumpling/v5.2.1/dumpling -- -u foo
Release version: v5.2.1
Git commit hash: 4e012e54ce89fab9551e7ff58ebcffe57590244a
Git branch:      heads/refs/tags/v5.2.1
Build timestamp: 2021-09-08 02:31:43Z
Go version:      go version go1.16.4 linux/amd64

meet some unparsed arguments, please check again: [-u foo]
Error: run `/home/dvaneeden/.tiup/components/dumpling/v5.2.1/dumpling` (wd:/home/dvaneeden/.tiup/data/SkTlB5U) failed: exit status 1
dveeden commented 2 years ago

Looks like https://github.com/pingcap/tiup/pull/1549 might have caused tiup to pass the -- to the component it is calling

dveeden commented 2 years ago
diff --git a/pkg/exec/run.go b/pkg/exec/run.go
index 0d19614..4450da8 100644
--- a/pkg/exec/run.go
+++ b/pkg/exec/run.go
@@ -261,6 +261,12 @@ func launchComponent(ctx context.Context, component string, version utils.Versio
                instanceDir = env.LocalPath(localdata.DataParentDir, tag)
        }

+       if len(args) > 0 {
+               if args[0] == "--" {
+                       args = args[1:]
+               }
+       }
+
        params := &PrepareCommandParams{
                Ctx:         ctx,
                Component:   component,

This patch for tiup seems to restore the way -- works

chengshihard commented 2 years ago

That's a tiup issue. Try:

tiup -- dumpling -h host

thx is work for me

lichunzhu commented 2 years ago

Close this now because it's a tiup issue.