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

Return reload status from http endpoint (#1152) #1180

Merged
merged 2 commits into from
Jan 8, 2018

Conversation

stuartnelson3
Copy link
Contributor

No description provided.

@stuartnelson3 stuartnelson3 requested a review from brancz January 6, 2018 10:39
ui/web.go Outdated

reloadCh <- errc
if err := <-errc; err != nil {
http.Error(w, fmt.Sprintf("config file reload failed: %v", err), http.StatusInternalServerError)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure if it's necessary to provide the error via http, or it's enough to just say the reload failed. Open to opinions.

Copy link
Member

@brancz brancz left a comment

Choose a reason for hiding this comment

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

I'm wondering if this is information we generally want to return. Since these endpoints are unprotected I as an operator would want to have these endpoints reveal little about errors, but be exact in logging output. There are already metrics to indicated if and when the last reload was successful.

@brian-brazil what are your opinions on this?

errc := make(chan error)
defer close(errc)

reloadCh <- errc
Copy link
Member

Choose a reason for hiding this comment

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

I don't think passing around channels like this is appropriate here, it's only ever going to be a single error received from errc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Coincidentally, it seems prometheus is using this pattern: https://github.com/prometheus/prometheus/blob/master/web/web.go#L638-L644

Copy link
Member

Choose a reason for hiding this comment

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

I've been trying to think of a solution, but can't off the top of my head, so I think it's fine to go with it then.

ui/web.go Outdated
return
}

w.Write([]byte("config file reloaded"))
Copy link
Member

Choose a reason for hiding this comment

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

An empty 200 response is probably just as good. What does the Prometheus server do? I would out of consistency do the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same link from above: https://github.com/prometheus/prometheus/blob/master/web/web.go#L638-L644

Looks like we're only writing something on failure

@brian-brazil
Copy link
Contributor

I wouldn't worry about exposing information here, all sorts of information is available via the web interface already including the ability to create and delete alerts. The only thing that'd be a problem would be secrets, and it's a bug to expose those in logs too.

I think this feature is a good idea.

@brancz
Copy link
Member

brancz commented Jan 8, 2018

lgtm on green 👍

@stuartnelson3 stuartnelson3 merged commit 3c61fe3 into master Jan 8, 2018
@stuartnelson3 stuartnelson3 deleted the stn/reload-endpoint-status branch January 8, 2018 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants