-
Notifications
You must be signed in to change notification settings - Fork 135
added support for --listen-metrics-url parameter #160
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. I understand the commands that are listed here. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: suhrud-kumar 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 |
Hi @suhrud-kumar. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
I want to make sure I understand what you mean here. When you say"make this optional," are you saying "make the use of a separate metrics endpoint optional?" By optional, I mean: If the |
@@ -235,4 +236,5 @@ func init() { | |||
joinCmd.PersistentFlags().StringVar(&etcdAdmConfig.InstallDir, "install-dir", constants.DefaultInstallDir, "install directory") | |||
joinCmd.PersistentFlags().StringArrayVar(&etcdAdmConfig.EtcdDiskPriorities, "disk-priorities", constants.DefaultEtcdDiskPriorities, "Setting etcd disk priority") | |||
joinCmd.PersistentFlags().BoolVar(&etcdAdmConfig.Retry, "retry", true, "Enable or disable backoff retry when join etcd member to cluster") | |||
joinCmd.PersistentFlags().Var(util.URLValue{URL: &etcdAdmConfig.AdditionalMetricsURL}, "listen-metrics-url", "URL to expose additional /metrics endpoint without TLS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the user passes in a string that isn't a valid URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use url.ParseRequestURI() function in URLValue Set function to parse it into a valid URL, if not it returns an error.
[root@ip-172-31-17-207 tmp]# ./etcdadm init --listen-metrics-url http//1.1.1.1
Error: invalid argument "http//1.1.1.1" for "--listen-metrics-url" flag: parse http//1.1.1.1: invalid URI for request
[root@ip-172-31-17-207 tmp]# ./etcdadm init --listen-metrics-url 1.1.1.1
Error: invalid argument "1.1.1.1" for "--listen-metrics-url" flag: parse 1.1.1.1: invalid URI for request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining. I overlooked the use of .Var
.
The UX looks good! (Do you think it would be nice if the error gives an example of a valid URI?)
@@ -0,0 +1,49 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the Set
and Type
receivers used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set is used to set argument passed to the assigned variable.
Since URLValue is an implementation of Value interface in pflag, all three functions are required - https://godoc.org/github.com/spf13/pflag#Value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I missed this.
Yes, thats what I meant. Just to clarify, with current implementation we have below two options etcdadm init -> additional http /metrics endpoint on http://<etcd-client-ip>:defaultport but we don't have an option to disable this. Initially I wanted to design something like below etcdadm init -> no additional http /metrics endpoint Since etcdadm is for making etcd operations simple, I think we can accommodate this design consideration. |
I signed it |
I favor this, because etcdadm typically uses etcd defaults, and by default, etcd does not enable a separate http metrics endpoint. I think you can use https://godoc.org/github.com/spf13/pflag#FlagSet.Changed to tell between |
Yes, that is what I wanted to implement at first. But since this is the only flag that uses this, it could somewhat mess up existing code structure.
pflag would throw an error if there is no argument or no default value for a flag (probably only for non-boolean flags) [root@ip-172-31-16-230 tmp]# ./etcdadm init --snapshot [root@ip-172-31-16-230 tmp]# ./etcdadm init --listen-metrics-url So we have to use this https://github.com/spf13/pflag#setting-no-option-default-values-for-flags So, init function looks like
and additional method in apis/config.go pkg
Let me know if you are okay with this and I can push it. Also, I think I found a bug (?) in pflag NoOptDefVal func, it doesn't work in all cases, will open a issue with them. |
Looks like this is an expected behaviour with pflag - spf13/pflag#134 So, if we use NoOptDefVal for this param |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closed this PR. 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. |
support for #157
@dlipovetsky
Added new flag --listen-metrics-url
I can't seem to make this optional without messing up with existing code structure. Let me know if I need to make any changes