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: implement mode option for painter algorithm populating options #1365

Merged
merged 14 commits into from
May 18, 2021

Conversation

tisonkun
Copy link
Contributor

What problem does this PR solve?

This PR closes #1269

It introduces a mode option to switch default config set among tidb or tikv-slim and allow user populate more options based on the default set.

What is changed and how it works?

Now, we directly communicate with FlagSet and use Changed to see if user explicit sets a config flag.

And I implement the painter algorithm that

  1. layer 0: draw the version config
  2. layer 2: draw the default set based on mode option
  3. layer 3: draw the reset options configured by user

each layer overwrite options set in early layer.

Check List

Tests

  • Manual test (add detailed scripts or steps below)

I run

  • tiup playground
  • tiup playground --mode tidb
  • tiup playground --mode tikv-slim
  • tiup playground --mode unknown
  • tiup playground --db 0 --tiflash 0
  • tiup playground --mode tikv-slim --db 1 --tiflash 1

and all run as expected.

I'm willing to add some automatic test but help wanted. Also I think we can add tests after this pr merged instead of be too mean to a fruitful pull request.

Side effects

  • Increased code complexity

with increasing flexibility.

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Yes, we need to update the documentation. But where?

Implement `mode` option for painter algorithm populating options. `tidb` as the original defaults and `tikv-slim` for only pd, tikv, and monitor instances.

@CLAassistant
Copy link

CLAassistant commented May 15, 2021

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot requested review from lonng and lucklove May 15, 2021 16:27
@ti-chi-bot ti-chi-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 15, 2021
@tisonkun
Copy link
Contributor Author

/cc @iosmanthus @AstroProfundis

@ti-chi-bot
Copy link
Member

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

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

In response to this:

/cc @iosmanthus @AstroProfundis

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.

@codecov-commenter
Copy link

codecov-commenter commented May 15, 2021

Codecov Report

Merging #1365 (e2095c2) into master (3202e61) will increase coverage by 0.88%.
The diff coverage is 34.07%.

❗ Current head e2095c2 differs from pull request most recent head ef65ee7. Consider uploading reports for the commit ef65ee7 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1365      +/-   ##
==========================================
+ Coverage   25.38%   26.26%   +0.88%     
==========================================
  Files         265      275      +10     
  Lines       20464    20907     +443     
==========================================
+ Hits         5194     5491     +297     
- Misses      14473    14618     +145     
- Partials      797      798       +1     
Flag Coverage Δ
integrate 13.76% <34.07%> (-1.77%) ⬇️
playground 13.76% <34.07%> (?)
tiup ?
unittest 21.57% <0.00%> (-0.11%) ⬇️

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

Impacted Files Coverage Δ
components/playground/playground.go 48.29% <0.00%> (+48.29%) ⬆️
components/playground/main.go 46.36% <34.32%> (+42.85%) ⬆️
main.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/repository/utils/hash.go 0.00% <0.00%> (-81.82%) ⬇️
cmd/env.go 21.42% <0.00%> (-71.43%) ⬇️
pkg/repository/model/publish.go 0.00% <0.00%> (-71.43%) ⬇️
pkg/utils/args.go 0.00% <0.00%> (-50.00%) ⬇️
cmd/root.go 24.46% <0.00%> (-48.21%) ⬇️
pkg/repository/v1manifest/repo.go 0.00% <0.00%> (-44.80%) ⬇️
pkg/repository/model/model.go 0.00% <0.00%> (-44.71%) ⬇️
... and 54 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3202e61...ef65ee7. Read the comment docs.

Copy link
Contributor

@AstroProfundis AstroProfundis left a comment

Choose a reason for hiding this comment

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

You can use pflag.Flag.Visit() to determine if an argument is set by user, here's an example in tiup mirror sub command

cmd.Flags().Visit(func(f *pflag.Flag) {

components/playground/main.go Outdated Show resolved Hide resolved
@AstroProfundis AstroProfundis added category/usability Categorizes issue or PR as a usability enhancement. component/playground Issues about the tiup-playground component labels May 17, 2021
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
Copy link
Contributor Author

/cc @AstroProfundis @lucklove

I've updated the implementation as @AstroProfundis suggested, using Visit method. The PR is ready for review.

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • AstroProfundis

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 18, 2021
@AstroProfundis
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: ef65ee7

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 18, 2021
@ti-chi-bot ti-chi-bot merged commit b3667bf into pingcap:master May 18, 2021
@andylokandy
Copy link

Does this PR need to cherry-pick?

@tisonkun
Copy link
Contributor Author

Does this PR need to cherry-pick?

I have no idea but it just works for me using a nightly version.

@andylokandy
Copy link

andylokandy commented May 18, 2021

I think it is better to release it.

@lucklove
Copy link
Member

@andylokandy Will be released in v1.5.0

@andylokandy
Copy link

ok, i see. The release is spilt from master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category/usability Categorizes issue or PR as a usability enhancement. component/playground Issues about the tiup-playground component size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fruitful playground - tikv-slim mode
7 participants