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
Router stats-port=0 error #16621
Router stats-port=0 error #16621
Conversation
@knobunc PTAL |
STATS_PORT=0 when ROUTER_METRICS_TYPE=haproxy is not supported. Change STATS_PORT description, add ROUTER_METRICS_TYPE description. Fixes bug 1466133 https://bugzilla.redhat.com/show_bug.cgi?id=1466133 origin PR 16621 openshift/origin#16621
pkg/cmd/infra/router/template.go
Outdated
@@ -248,6 +248,9 @@ func (o *TemplateRouterOptions) Run() error { | |||
statsPort := o.StatsPort | |||
switch { | |||
case o.MetricsType == "haproxy": | |||
if statsPort == 0 { | |||
return fmt.Errorf("haproxy metrics requires a nonzero StatsPort") |
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.
non-zero
pkg/oc/admin/router/router.go
Outdated
@@ -64,10 +64,7 @@ var ( | |||
%[1]s %[2]s router-west --replicas=2 | |||
|
|||
# Use a different router image | |||
%[1]s %[2]s region-west --images=myrepo/somerouter:mytag | |||
|
|||
# Run the router with a hint to the underlying implementation to _not_ expose statistics. |
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 need to update this to say how to not expose stats.
We should make --stats-port work and it should make the stats come from the router controller. |
ea3ed93
to
6451486
Compare
@knobunc PTAL |
ROUTER_METRICS_TYPE: haproxy and stats_port: 0 is not a supported combination. |
The router should error out rather than let you get into this state. |
If you don't want to expose stats, you should be setting stats port to zero and clearing metrics_type |
@smarterclayton what is the relationship between healthz and stats. Shouldn't helathz always be supported whether or not we support stats? If so do we do that on the controller or haproxy? Are you saying that when stats are not wanted, healthz will be supported by haproxy? ROUTER_METRICS_TYPE is an internal environment variable (not controlled on the command line) and stats-port is from a command line arg (oc adm router). How does the admin create a router that doesn't support stats? |
ROUTER_METRICS_TYPE is a flag |
@smarterclayton the current changes start healthz but not metrics. So in the next change there is going to be no healthz without stats. |
Hold on... I want to use Are you advocating we add If we add @smarterclayton Thoughts? |
Or... perhaps we don't add Maybe if Is that reasonable? |
--expose-metrics and --metrics-image are deprecated and should not be
used. Those will be removed in the future.
…--metrics-type is a mutually exclusive flag for "stats mode". there are 2
modes - "haproxy metrics" and "no metrics". In the latter mode,
--stats-port may be set to zero.
I expect EVERY cluster to use haproxy metrics starting the moment we get
good stats metrics. It's not going to be optional much longer except for
total disablement. We will make it so that cluster credentials
authenticate to that, and the stats user and password is removed.
On Wed, Oct 4, 2017 at 11:19 AM, Ben Bennett ***@***.***> wrote:
Or... perhaps we don't add --metrics-type to oadm rotuer and we change
the meaning of --expose-metrics for router types of haproxy and use that
to determine whether to set ROUTER_METRICS_TYPE and change the default
for --expose-metrics to true.
Maybe if --metrics-image is set, then we set the ROUTER_METRICS_TYPE and
use the specified image for metrics.
Is that reasonable?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16621 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p6jDIkVWXahD-8BVpNF0XlfDmHNCks5so6HzgaJpZM4PpJau>
.
|
Actually, I just realized there is no way to use The short version is that And that won't work when the metrics type is |
So... can we take over |
We can't change the meaning of flags. We can only stop respecting them.
You need to set --metrics-type="" and --stats-port=0 to disable stats.
…On Wed, Oct 4, 2017 at 11:31 AM, Ben Bennett ***@***.***> wrote:
So... can we take over --expose-metrics and make it toggle whether we
expose metrics vs. just health checks? I really would rather not have to
set --type="" --stats-port=0 if I want to use the haproxy router, but
disable stats.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16621 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p6W68IE0gwuqUThBn-_MCSJK67xYks5so6TqgaJpZM4PpJau>
.
|
@knobunc @smarterclayton PTAL |
pkg/cmd/infra/router/template.go
Outdated
@@ -251,6 +251,9 @@ func (o *TemplateRouterOptions) Run() error { | |||
if len(o.StatsUsername) == 0 || len(o.StatsPassword) == 0 { | |||
glog.Warningf("Metrics were requested but no username or password has been provided - the metrics endpoint will not be accessible to prevent accidental security breaches") | |||
} | |||
if statsPort == 0 { | |||
return fmt.Errorf("When type is haprocy-router, STATS_PORT must not be 0") |
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.
lower case, typo, and not the right flag:
when --metrics-type is haproxy --stats-port may not be set to 0
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.
@smarterclayton This message comes up when you run oc adm router --stats-port=0
--metrics-type is an invalid 'oc adm router' parameter so message will just confuse the user.
Made the requested changes.
pkg/oc/admin/router/router.go
Outdated
@@ -279,7 +279,7 @@ func NewCmdRouter(f *clientcmd.Factory, parentName, name string, out, errout io. | |||
}, | |||
} | |||
|
|||
cmd.Flags().StringVar(&cfg.Type, "type", "haproxy-router", "The type of router to use - if you specify --images this flag may be ignored.") | |||
cmd.Flags().StringVar(&cfg.Type, "type", "haproxy-router", "The type of router to use, default is haproxy-router - if you specify --images this flag may be ignored.") |
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.
You don't need to describe defaults here, because the default is already printed when you run help
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.
OK
Ah, got it. |
pkg/oc/admin/router/router.go
Outdated
@@ -293,11 +293,11 @@ func NewCmdRouter(f *clientcmd.Factory, parentName, name string, out, errout io. | |||
cmd.Flags().StringVar(&cfg.DefaultCertificate, "default-cert", cfg.DefaultCertificate, "Optional path to a certificate file that be used as the default certificate. The file should contain the cert, key, and any CA certs necessary for the router to serve the certificate. Does not apply to external appliance based routers (e.g. F5)") | |||
cmd.Flags().StringVar(&cfg.Selector, "selector", cfg.Selector, "Selector used to filter nodes on deployment. Used to run routers on a specific set of nodes.") | |||
cmd.Flags().StringVar(&cfg.ServiceAccount, "service-account", cfg.ServiceAccount, "Name of the service account to use to run the router pod.") | |||
cmd.Flags().IntVar(&cfg.StatsPort, "stats-port", cfg.StatsPort, "If the underlying router implementation can provide statistics this is a hint to expose it on this port. Specify 0 if you want to turn off exposing the statistics.") | |||
cmd.Flags().IntVar(&cfg.StatsPort, "stats-port", cfg.StatsPort, "If the underlying router implementation can provide statistics this is a hint to expose it on this port. Specify type= and stats-port=0 to turn off exposing the statistics.") |
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.
Last sentence To disable all statistics, you must disable --metrics-type and set --stats-port to zero.
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.
@smarterclayton --metrics-type is not a valid option to "oc adm router". BTW: how do you set --metrics-type? Is it in the DC as an arg to the router controller?
Changed to suggested message.
pkg/oc/admin/router/router.go
Outdated
cmd.Flags().BoolVar(&cfg.ExposeMetrics, "expose-metrics", cfg.ExposeMetrics, "If true, attempts to run an extra container in the pod to expose metrics - the image will either be set depending on the router implementation or provided with --metrics-image. Not useful where comprehensive metrics are available through the stats-port (e.g. haproxy router)") | ||
cmd.Flags().StringVar(&cfg.MetricsImage, "metrics-image", cfg.MetricsImage, "If --expose-metrics is specified this is the image to use to run a sidecar container in the pod exposing metrics. If not set and --expose-metrics is true the image will depend on router implementation. Not useful where comprehensive metrics are available through the stats-port (e.g. haproxy router)") | ||
cmd.Flags().BoolVar(&cfg.ExposeMetrics, "expose-metrics", cfg.ExposeMetrics, "DEPRECATED If true, attempts to run an extra container in the pod to expose metrics - the image will either be set depending on the router implementation or provided with --metrics-image. Not useful where comprehensive metrics are available through the stats-port (e.g. haproxy router)") | ||
cmd.Flags().StringVar(&cfg.MetricsImage, "metrics-image", cfg.MetricsImage, "DEPRECATED If --expose-metrics is specified this is the image to use to run a sidecar container in the pod exposing metrics. If not set and --expose-metrics is true the image will depend on router implementation. Not useful where comprehensive metrics are available through the stats-port (e.g. haproxy router)") |
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.
This is not how flags are marked deprecated. There is an attribute on the flag to set it as deprecated.
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.
Deleted "DEPRECATED". This was not part of this bug. It will get fixed in another bug.
pkg/oc/admin/router/router.go
Outdated
@@ -683,6 +683,9 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write | |||
} | |||
// automatically start the internal metrics agent if we are handling a known type | |||
if cfg.Type == "haproxy-router" { | |||
if cfg.StatsPort == 0 { | |||
return fmt.Errorf("When --type is haproxy-router, --stats-port must not be 0") |
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.
This is incorrect, type has nothing to do with stats port.
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.
@smarterclayton This is your code:
db5b0fb pkg/cmd/admin/router/router.go (Clayton Coleman 2017-03-10 01:43:10 -0500 685) if cfg.Type == "haproxy-router" {
6e9c0ada pkg/oc/admin/router/router.go (Phil Cameron 2017-09-29 15:39:40 -0400 686) if cfg.StatsPort == 0 {
6e9c0ada pkg/oc/admin/router/router.go (Phil Cameron 2017-09-29 15:39:40 -0400 687) return fmt.Errorf("When --typ
e is haproxy-router, --stats-port must not be 0")
6e9c0ada pkg/oc/admin/router/router.go (Phil Cameron 2017-09-29 15:39:40 -0400 688) }
ff44d23 pkg/cmd/admin/router/router.go (Clayton Coleman 2017-06-20 21:38:36 -0400 689) env["ROUTER_LISTEN_ADDR"] = fmt.Sprin
tf("0.0.0.0:%d", cfg.StatsPort)
db5b0fb pkg/cmd/admin/router/router.go (Clayton Coleman 2017-03-10 01:43:10 -0500 690) env["ROUTER_METRICS_TYPE"] = "haproxy
"
db5b0fb pkg/cmd/admin/router/router.go (Clayton Coleman 2017-03-10 01:43:10 -0500 691) }
You use cfg.StatsPort to set up the ROUTER_LISTEN_ADDR - 0.0.0.0:0 is the error that causes the router to not come up.
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.
Sorry, wrong package. If stats-port is 0 AND type is haproxy-router, then in this code path you should avoid setting ROUTER_METRICS_TYPE and listen addr, not return this error. This is defaulting metrics on, and stats-port 0 would mean defaulting metrics off.
if cfg.Type == "haproxy-router" && cfg.StatsPort != 0 {
env["ROUTER_LISTEN_ADDR"] = fmt.Sprintf("0.0.0.0:%d", cfg.StatsPort)
env["ROUTER_METRICS_TYPE"] = "haproxy"
}
@smarterclayton could you please take a moment and address the questions that @knobunc and I have raised in the comments? I am not on the same page as you and would like to get there. What you have been saying is not how you coded this. |
stats-port=0 properly disables statistics. Fixes bug: 1466133 https://bugzilla.redhat.com/show_bug.cgi?id=1466133
@knobunc @smarterclayton We have come full circle, stats-port=0 disables router statistics. PTAL |
/lgtm |
/retest |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: knobunc, pecameron, smarterclayton The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
@pecameron: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. |
/retest Please review the full test history for this PR and help us cut down flakes. |
Automatic merge from submit-queue. |
When type=haproxy-router, stats-port must not be 0.
Fixes bug: 1466133
https://bugzilla.redhat.com/show_bug.cgi?id=1466133