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

playground: Only add --comments when needed #2314

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

dveeden
Copy link
Contributor

@dveeden dveeden commented Nov 14, 2023

What problem does this PR solve?

From https://dev.mysql.com/doc/relnotes/mysql/8.1/en/news-8-1-0.html

Comments in the mysql client are now enabled by default. To disable them, start mysql with the --skip-comments option.

Our thanks to Daniël van Eeden for the contribution. (Bug #109972, Bug #35061087, WL #15597)

This means we can shorten the commandline to connect to TiDB if the client is newer than 8.1.0.

What is changed and how it works?

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)

Side effects

  • Increased code complexity

Release notes:

TiUP Playground now only prints `--comments` for older versions of MySQL Client.

@ti-chi-bot ti-chi-bot bot requested a review from srstack November 14, 2023 09:29
Copy link
Contributor

ti-chi-bot bot commented Nov 14, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kaaaaaaang for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 14, 2023
@dveeden
Copy link
Contributor Author

dveeden commented Nov 14, 2023

/cc @xhebox

Copy link
Contributor

ti-chi-bot bot commented Nov 14, 2023

@dveeden: GitHub didn't allow me to request PR reviews from the following users: xhebox.

Note that only pingcap members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @xhebox

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dveeden
Copy link
Contributor Author

dveeden commented Nov 14, 2023

/cc @nexustar

@ti-chi-bot ti-chi-bot bot requested a review from nexustar November 14, 2023 09:32
@dveeden
Copy link
Contributor Author

dveeden commented Nov 14, 2023

/retest

@kaaaaaaang
Copy link
Collaborator

maybe user run playground in an machine without mysql client?

@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2023

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (ced2d6d) 47.65% compared to head (db97f60) 50.73%.

❗ Current head db97f60 differs from pull request most recent head 3dc6fe2. Consider uploading reports for the commit 3dc6fe2 to get more accurate results

Files Patch % Lines
components/playground/playground.go 53.66% 14 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2314      +/-   ##
==========================================
+ Coverage   47.65%   50.73%   +3.08%     
==========================================
  Files         307      324      +17     
  Lines       33819    34748     +929     
==========================================
+ Hits        16116    17628    +1512     
+ Misses      15715    14940     -775     
- Partials     1988     2180     +192     
Flag Coverage Δ
playground 15.30% <53.66%> (?)
tiup 33.48% <ø> (ø)
unittest 22.30% <24.39%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dveeden
Copy link
Contributor Author

dveeden commented Nov 15, 2023

maybe user run playground in an machine without mysql client?

$ sudo mv /usr/bin/mysql /usr/bin/mysqlabc
$ ./bin/tiup-playground --tiproxy 1 --tiflash 0 v7.1.2
...
Connect TiDB:    mysql --comments --host 127.0.0.1 --port 4000 -u root
Connect TiProxy: mysql --comments --host 127.0.0.1 --port 6000 -u root
...

So if it can't execute the mysql command or if it fails to parse the version string it will output mysql --comments ....

The only risk is that the user might use SSH forwarding from another host or use another mysql client to connect. However playground is mostly used locally.

I now also notice that we use a mix between long (--comments, --host and --port) and short options (-u), which isn't very consistent.

Instead of mysql --comments --host 127.0.0.1 --port 4000 -u root we could use one of these:

  1. mysql --comments --host 127.0.0.1 --port 4000 --user root
  2. mysql -c -h 127.0.0.1 -P 4000 -u root

The long options are more descriptive, but the short options are more concise.

Not something we should do now, but I like how MySQL Shell is doing this:
mysqlsh --sql mysql://root@127.0.0.1:4000

@dveeden
Copy link
Contributor Author

dveeden commented Nov 15, 2023

@mjonss any input on this?

Copy link
Contributor

@mjonss mjonss left a comment

Choose a reason for hiding this comment

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

LGTM, but I assume some special handling for MariaDB is also needed?

components/playground/playground.go Outdated Show resolved Hide resolved
Comment on lines +1494 to +1496
if vMaj == 8 && vMin >= 1 { // 8.1.0 and newer
return "mysql"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is --comments default on on MariaDB CLI? From reading the knowledge base it does not look like it.

Also there is no harm in always using --comments, regardless of version, just not needed for MySQL CLI ver >= 8.1 right?

I wonder if parseMysqlCommand should also return the vendor, like MySQL or MariaDB?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--comments is not the default on MariaDB Client yet. (ref: https://mariadb.com/kb/en/mariadb-command-line-client/#-c-comments )

There is no real harm on using --comments but the commandline gets longer and more complex with this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I missed the vMaj == 8 which will not match any MariaDB versions.

Copy link
Contributor

ti-chi-bot bot commented Nov 29, 2023

@mjonss: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

LGTM, but I assume some special handling for MariaDB is also needed?

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dveeden
Copy link
Contributor Author

dveeden commented Nov 30, 2023

LGTM, but I assume some special handling for MariaDB is also needed?

No special handling for MariaDB is needed afaik. MariaDB strips comments by default in all versions so --comments is still needed. (ref: https://mariadb.com/kb/en/mariadb-command-line-client/#-c-comments )

Some commandline options in MariaDB are different (e.g. --ssl-mode), but I don't think we use any of these right now.

Actually.... in MariaDB the client is now bin/mariadb instead of bin/mysql. I think as a MySQL compatible database we should suggest/recommend a MySQL Client. Note that there is a bin/mysql in MariaDB, but that reports: "Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead"

@dveeden dveeden requested a review from mjonss November 30, 2023 08:17
Comment on lines +1494 to +1496
if vMaj == 8 && vMin >= 1 { // 8.1.0 and newer
return "mysql"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I missed the vMaj == 8 which will not match any MariaDB versions.

Copy link
Contributor

ti-chi-bot bot commented Dec 4, 2023

@mjonss: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot added the lgtm label Dec 11, 2023
@ti-chi-bot ti-chi-bot bot removed the lgtm label Dec 19, 2023
Copy link
Contributor

ti-chi-bot bot commented Dec 19, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-11 17:32:07.188212495 +0000 UTC m=+291018.225439436: ☑️ agreed by srstack.
  • 2023-12-19 06:14:53.353633702 +0000 UTC m=+941584.390860629: ✖️🔁 reset by breezewish.

Copy link
Contributor

ti-chi-bot bot commented Dec 19, 2023

New changes are detected. LGTM label has been removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants