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

Added support for hot reload of UI config #1688

Merged
merged 1 commit into from
Aug 8, 2019
Merged

Added support for hot reload of UI config #1688

merged 1 commit into from
Aug 8, 2019

Conversation

jpkrohling
Copy link
Contributor

Signed-off-by: Juraci Paixão Kröhling juraci@kroehling.de

Which problem is this PR solving?

  • As seen on Update of spec.ui has no effect on jaegerUI jaeger-operator#533, changing the UI configuration requires the Jaeger Query to be stopped and started again. As the file is sent as is inside the HTML that is requested by the browser, it's safe to simply watch the file for changes and replace the internal indexHTML property.

@codecov
Copy link

codecov bot commented Jul 25, 2019

Codecov Report

Merging #1688 into master will decrease coverage by 0.15%.
The diff coverage is 70.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1688      +/-   ##
==========================================
- Coverage   98.51%   98.36%   -0.16%     
==========================================
  Files         193      193              
  Lines        9314     9358      +44     
==========================================
+ Hits         9176     9205      +29     
- Misses        110      119       +9     
- Partials       28       34       +6
Impacted Files Coverage Δ
cmd/query/app/static_handler.go 86.84% <70.58%> (-13.16%) ⬇️

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 aa76cf0...7cf6945. Read the comment docs.

@jpkrohling
Copy link
Contributor Author

The code coverage is lower than the usual because of the logging of errors related to file system problems, which are hard to reproduce in unit tests.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

there was another ticket to support watching of the sampling strategies file. I am not sure if there's code that we can reuse though.

cmd/query/app/static_handler.go Show resolved Hide resolved
cmd/query/app/static_handler.go Outdated Show resolved Hide resolved
cmd/query/app/static_handler.go Outdated Show resolved Hide resolved
cmd/query/app/static_handler.go Show resolved Hide resolved
}
defer watcher.Close()

done := make(chan bool)
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure why this is needed, there's no external signaling into this chan

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was mainly to keep the function from returning, as it would then call watcher.Close(), but I figured I could just not close the watcher and it would have the same effect.

cmd/query/app/static_handler.go Show resolved Hide resolved
cmd/query/app/static_handler_test.go Outdated Show resolved Hide resolved
Copy link
Contributor Author

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

PR updated

}
defer watcher.Close()

done := make(chan bool)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was mainly to keep the function from returning, as it would then call watcher.Close(), but I figured I could just not close the watcher and it would have the same effect.

cmd/query/app/static_handler.go Outdated Show resolved Hide resolved
cmd/query/app/static_handler.go Show resolved Hide resolved
cmd/query/app/static_handler_test.go Outdated Show resolved Hide resolved
@jpkrohling jpkrohling changed the title Added support for hot reload of UI config WIP - Added support for hot reload of UI config Jul 26, 2019
@jpkrohling
Copy link
Contributor Author

Marking this as WIP, as this PR alone would not solve the original problem from jaegertracing/jaeger-operator#533.

@jpkrohling jpkrohling changed the title WIP - Added support for hot reload of UI config Added support for hot reload of UI config Aug 1, 2019
@@ -72,7 +73,6 @@ func TestRegisterStaticHandler(t *testing.T) {
BasePath: testCase.basePath,
UIConfig: "fixture/ui-config.json",
})
assert.Empty(t, buf.String(), "no logs during construction")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this assertion, as I believe there's value in adding a log message stating that the config file specified via CLI is being watched.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

What is the use case for reloading UI config? I.e. what kind of things would people want to change there dynamically?

The file watching behavior would be quite useful for the sampling strategies config, I believe we even have a ticket for that.

cmd/query/app/static_handler.go Outdated Show resolved Hide resolved
cmd/query/app/static_handler.go Outdated Show resolved Hide resolved
@jpkrohling
Copy link
Contributor Author

What is the use case for reloading UI config? I.e. what kind of things would people want to change there dynamically?

@mwieczorek faced this on jaegertracing/jaeger-operator#533 . I don't expect this file to be changed that often, and most instances would probably never change, but for the cases where it does change, we'd have to kill the Jaeger Query component to have the config file re-read. We could watch for a SIGHUP and reload accordingly, but that wouldn't solve his problem, as there's no SIGHUP in Kubernetes :-)

The file watching behavior would be quite useful for the sampling strategies config, I believe we even have a ticket for that.

+1, I can work on that next, but I think that one involves more work than just reloading the config file and updating a single atomic field.

@yurishkuro
Copy link
Member

I don't expect this file to be changed that often, and most instances would probably never change, but for the cases where it does change

Right, so that was my point, is it worth adding all this code (and future maintenance) for such a marginal use case? The UI config is not really that dynamic, I can't think of any items there that must be changed in place. Feels like a redeploy / restart is a perfectly valid solution.

@mwieczorek
Copy link

The UI config is not really that dynamic, I can't think of any items there that must be changed in place. Feels like a redeploy / restart is a perfectly valid solution.

I'll add my comment as I created the issue jaegertracing/jaeger-operator#533
Indeed changes in the ui-config are not often. In my case, it's related to links generated on span tags. From time to time I'd like to add new or modify existing one. All the changes are pushed by automated pipeline, so right now I have to restart pods after the change of Jaeger CR. I thought it could be handled by the operator (detect if there's change in ui-config part of CR spec and then somehow restart the pods).
@jpkrohling suggested it can be handled directly in jaeger.

Anyway: if the change introduces too much burden - I can just live with additional pipeline steps which will handle the restarts.

@objectiser
Copy link
Contributor

@yurishkuro If a similar approach is of interest for sampling strategies, then wouldn't it be better for Jaeger to have a consistent approach to reloading configs?

@yurishkuro
Copy link
Member

@objectiser it would be much better if there was a shared component, yet all of the new code here is embedded directly into the handler. But I don't mind merging it.

@jpkrohling
Copy link
Contributor Author

The watcher part can be refactored when we add a similar support for the sampling strategy config file.

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
@jpkrohling jpkrohling merged commit 98fd69a into jaegertracing:master Aug 8, 2019
@jpkrohling
Copy link
Contributor Author

I'm merging this, with the promise that I'll refactor this code to suite multiple consumers of the logic, once I send a PR allowing a similar feature for the sampling strategies configuration.

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.

4 participants