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: deprecate bootstrap option --monitor and add a new option --without-monitor to disable monitors. #1512

Merged
merged 11 commits into from
Aug 11, 2021

Conversation

LittleFall
Copy link
Contributor

@LittleFall LittleFall commented Aug 9, 2021

What problem does this PR solve?

What --monitor Start prometheus and grafana component means is unclear, tiup playground nightly and tiup playground nightly --monitor has no difference.

What is changed and how it works?

  1. deprecate option --monitor, after this pr, if you add this, it still work but will report Flag --monitor has been deprecated, Please use --without-monitor to control whether to disable monitor.
  2. add option --without-monitor, in help messagae: --without-monitor Don't start prometheus and grafana component . by the way, help message won't show --mointor anymore.
  3. when the two option occurs at the same time, the last occured will work.

Check List

Tests

  • Integration test

Related changes

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

Release notes:

deprecate bootstrap option --monitor and add a new option --without-monitor to disable monitors.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 9, 2021

[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 submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2021
@ti-chi-bot ti-chi-bot requested a review from lucklove August 9, 2021 08:07
@ti-chi-bot ti-chi-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 9, 2021
@LittleFall LittleFall changed the title playground: clear description of bootstrap option. playground: clear the description of bootstrap option. Aug 9, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2021
@LittleFall LittleFall changed the title playground: clear the description of bootstrap option. playground: clear the description of bootstrap option --monitor. Aug 9, 2021
@LittleFall
Copy link
Contributor Author

/cc @tisonkun

@ti-chi-bot ti-chi-bot requested a review from tisonkun August 9, 2021 08:21
Copy link
Contributor

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

Rest LGTM.

components/playground/main.go Outdated Show resolved Hide resolved
@AstroProfundis AstroProfundis added the component/playground Issues about the tiup-playground component label Aug 9, 2021
@AstroProfundis
Copy link
Contributor

I think it's better figure out why

case withMonitor:
is not working in this scenario and fix it.

@LittleFall
Copy link
Contributor Author

hi @tisonkun @AstroProfundis, I've investigated why --monitor false is useless, and the conclusion is:

rootCmd.Flags().Bool(withMonitor, false, "Start prometheus and grafana component")

will create a pflag.Flag with NoOptDefVal is true. here is the code:

flag.NoOptDefVal = "true"

and when pflag parsing out command arguments, it won't accept pattern --flag arg when flag has NoOptDefVal. here is the code:

	if len(split) == 2 {
		// '--flag=arg'
		value = split[1]
	} else if flag.NoOptDefVal != "" {
		// '--flag' (arg was optional)
		value = flag.NoOptDefVal
	} else if len(a) > 0 {
		// '--flag arg'
		value = a[0]
		a = a[1:]
	} else {
		// '--flag' (arg was required)
		err = f.failf("flag needs an argument: %s", s)
		return
	}

@LittleFall
Copy link
Contributor Author

LittleFall commented Aug 10, 2021

A simple fix is set NoOptDefVal of flag Monitor to empty like this:

rootCmd.Flags().Bool(withMonitor, false, "Start prometheus and grafana component")
rootCmd.Flags().Lookup(withMonitor).NoOptDefVal = ""

but this will introduce a compatible issue:

Before patch (NoOptDefVal="true") After patch (NoOptDefVal="")
(Default) enable monitor enable monitor
--monitor=true enable monitor enable monitor
--monitor true enable monitor enable monitor
--monitor=false Disable monitor Disable monitor
--monitor false enable monitor Disable monitor
--monitor enable monitor Error: flag needs an argument: --monitor

what do you think about this?

@codecov-commenter
Copy link

codecov-commenter commented Aug 10, 2021

Codecov Report

Merging #1512 (35d2814) into master (e59979e) will increase coverage by 4.54%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1512      +/-   ##
==========================================
+ Coverage   26.27%   30.82%   +4.54%     
==========================================
  Files         267      279      +12     
  Lines       24041    24536     +495     
==========================================
+ Hits         6317     7562    +1245     
+ Misses      16901    15976     -925     
- Partials      823      998     +175     
Flag Coverage Δ
integrate 21.86% <33.33%> (+5.82%) ⬆️
playground 13.73% <33.33%> (?)
tiup 16.04% <ø> (ø)
unittest 22.83% <0.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
components/playground/main.go 46.25% <33.33%> (+43.84%) ⬆️
...onents/playground/instance/tiflash_proxy_config.go 83.33% <0.00%> (ø)
components/playground/instance/tidb.go 83.78% <0.00%> (ø)
components/playground/instance/ticdc.go 0.00% <0.00%> (ø)
components/playground/instance/pump.go 0.00% <0.00%> (ø)
components/playground/instance/process.go 84.90% <0.00%> (ø)
components/playground/instance/pd.go 75.00% <0.00%> (ø)
components/playground/instance/tikv_config.go 100.00% <0.00%> (ø)
components/playground/instance/tiflash.go 61.98% <0.00%> (ø)
components/playground/instance/tikv.go 67.85% <0.00%> (ø)
... and 21 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 e59979e...35d2814. Read the comment docs.

@LittleFall
Copy link
Contributor Author

another thing is that after this patch, the help message will be like
--monitor Whether to start prometheus and grafana component (default true)
we can't make it to be
--monitor bool Whether to start prometheus and grafana component (default true)

because it's written in pflag code here

	name = flag.Value.Type()
	switch name {
	case "bool":
		name = ""
	case "float64":
		name = "float"
	case "int64":
		name = "int"
	case "uint64":
		name = "uint"
	case "stringSlice":
		name = "strings"
	case "intSlice":
		name = "ints"
	case "uintSlice":
		name = "uints"
	case "boolSlice":
		name = "bools"
	}

@LittleFall LittleFall requested a review from tisonkun August 10, 2021 12:09
@LittleFall LittleFall changed the title playground: clear the description of bootstrap option --monitor. playground: clear the description and behavior of bootstrap option --monitor. Aug 10, 2021
Copy link
Contributor

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

I think it is as complex as before...

@AstroProfundis
Copy link
Contributor

AstroProfundis commented Aug 11, 2021

Ummmmmm, I'd agree that change this argument to --disable-monitor/--without-monitor/--no-monitor and set it default to true might be easier.

@LittleFall LittleFall changed the title playground: clear the description and behavior of bootstrap option --monitor. playground: change bootstrap option --monitor to --no-monitor Aug 11, 2021
Copy link
Contributor

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

I'd prefer disable- or without-.

BTW, what about user facing interface changes? Previous settings based on --monitor will break.

@ti-chi-bot ti-chi-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 11, 2021
@LittleFall LittleFall changed the title playground: change bootstrap option --monitor to --no-monitor playground: change bootstrap option --monitor to --without-monitor Aug 11, 2021
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 11, 2021
@AstroProfundis AstroProfundis added this to the v1.6.0 milestone Aug 11, 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: cb4257b

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 11, 2021
@LittleFall LittleFall changed the title playground: change bootstrap option --monitor to --without-monitor playground: deprecate bootstap option --monitor and add a new option --without-monitor to disable monitors. Aug 11, 2021
@LittleFall LittleFall changed the title playground: deprecate bootstap option --monitor and add a new option --without-monitor to disable monitors. playground: deprecate bootstrap option --monitor and add a new option --without-monitor to disable monitors. Aug 11, 2021
@LittleFall LittleFall requested a review from tisonkun August 11, 2021 08:26
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Aug 11, 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: 4b9381c

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 11, 2021
@ti-chi-bot ti-chi-bot merged commit 5ef4728 into pingcap:master Aug 11, 2021
@LittleFall LittleFall deleted the clear branch August 11, 2021 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/playground Issues about the tiup-playground component size/S Denotes a PR that changes 10-29 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.

5 participants