Skip to content

Central configuration implementation#497

Merged
SergeyKleyman merged 22 commits intoelastic:masterfrom
SergeyKleyman:Central_config
Sep 24, 2019
Merged

Central configuration implementation#497
SergeyKleyman merged 22 commits intoelastic:masterfrom
SergeyKleyman:Central_config

Conversation

@SergeyKleyman
Copy link
Copy Markdown
Contributor

@SergeyKleyman SergeyKleyman commented Sep 18, 2019

Note: This PR is temporarily in draft mode - see #497 (comment) for details.

Closes #352

It doesn't include automated tests - I've opened #496 to follow up.

@SergeyKleyman SergeyKleyman changed the title Implement remote (AKA central) configuration #352 Central configuration implementation Sep 18, 2019
@codecov-io
Copy link
Copy Markdown

codecov-io commented Sep 19, 2019

Codecov Report

Merging #497 into master will increase coverage by 3.09%.
The diff coverage is 63.32%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #497      +/-   ##
==========================================
+ Coverage   73.09%   76.19%   +3.09%     
==========================================
  Files          99       99              
  Lines        4115     3701     -414     
  Branches      859      672     -187     
==========================================
- Hits         3008     2820     -188     
+ Misses        871      631     -240     
- Partials      236      250      +14
Impacted Files Coverage Δ
src/Elastic.Apm/Logging/IApmLoggingExtensions.cs 86.27% <ø> (ø) ⬆️
src/Elastic.Apm/Config/ConfigConsts.cs 100% <ø> (ø) ⬆️
src/Elastic.Apm/Helpers/AgentSpinLock.cs 100% <100%> (+95.23%) ⬆️
...astic.Apm/Config/EnvironmentConfigurationReader.cs 96% <100%> (+6%) ⬆️
src/Elastic.Apm/Helpers/ExceptionUtils.cs 94.44% <100%> (+8.39%) ⬆️
src/Elastic.Apm/Model/Transaction.cs 94.77% <100%> (+3.39%) ⬆️
src/Elastic.Apm/Helpers/IAgentTimer.cs 100% <100%> (+100%) ⬆️
src/Elastic.Apm/Agent.cs 70.83% <100%> (-1.05%) ⬇️
src/Elastic.Apm/Helpers/ObjectExtensions.cs 100% <100%> (+20%) ⬆️
src/Elastic.Apm/Consts.cs 100% <100%> (ø) ⬆️
... and 41 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 4dd1751...4832607. Read the comment docs.

@SergeyKleyman
Copy link
Copy Markdown
Contributor Author

I'm still investigating why tests were hanging on CI's Linux environment. It doesn't happen in this PR after I introduced NoopCentralConfigFetcher to be used in the tests that don't test Central Configuration feature (which at the moment are all the tests since tests for Central Configuration feature were deferred to a future PR, see #496).
I'm going to use a temporary PR (#499) for experiments since the issue of hanging tests doesn't reproduce in my environment (which is Windows - it's not clear at the moment if it's a Linux vs Windows issue).
Let's consider this PR as a draft. I will remove draft status after I find the root cause. If the root cause is related to Central Configuration feature I'll add a fix.

@SergeyKleyman SergeyKleyman changed the title Central configuration implementation [DRAFT] Central configuration implementation Sep 19, 2019
@SergeyKleyman SergeyKleyman removed this from the 1.1 milestone Sep 24, 2019
@SergeyKleyman SergeyKleyman changed the title [DRAFT] Central configuration implementation Central configuration implementation Sep 24, 2019
@SergeyKleyman
Copy link
Copy Markdown
Contributor Author

After quite a few experiments I found quite a few issues (most are only relevant for test use cases so I'll submit fixes for them later as separate PRs) but the main root causes for tests hanging on Linux were:

  1. HttpClient's SendAsync under certain circumstances not respecting cancellation (even though it accepts CancellationToken). It seems that those problematic circumstances occur when there are multiple simultaneously running tests instantiate CentralConfigFetcher which tries to connect to APM Server using HttpClient.SendAsync(... GET request ...) although I didn't succeed in creating a minimal reproducing example (i.e., the using only HttpClient without any of Agent's code). I solved the issue by wrapping HttpClient.SendAsync into AwaitOrTimeout which is cancellable,
  2. CentralConfigFetcher's Dispose signalling cancellation to HttpClient's SendAsync. It turns out that CancellationTokenSource.Cancel invokes callbacks synchronously which in our cases caused deadlock because the thread calling CancellationTokenSource.Cancel after that tries to Join with the thread on which HttpClient.SendAsync is running that the first thread tries to cancel. Following the advice at the abov e link and wrapping CancellationTokenSource.Cancel into Task.Run solved the deadlock.

@SergeyKleyman SergeyKleyman merged commit 045a07b into elastic:master Sep 24, 2019
@SergeyKleyman SergeyKleyman deleted the Central_config branch September 24, 2019 17:33
@gregkalapos
Copy link
Copy Markdown
Contributor

Are we sure we merge all this 5000+ lines without review?

SergeyKleyman added a commit that referenced this pull request Oct 2, 2019
* Implement remote (AKA central) configuration #352

* Fix failing tests

* Fix failing tests part 2

* Improve logging

* Improve logging to find why tests hang on Linux

* Always log test start/finish

* Reduce style conventions violations to warning

* Temporarily increase log level for investigation

* Fix CentralConfig option parsing

* Make tests use NoopCentralConfigFetcher by default

* Revert TestingConfig's default log level back to ConsoleLogger.DefaultLogLevel

* Increase log level for central config rare events to Info

* Remove duplicate "thread started" log messages

* Update docs/configuration.asciidoc

Co-Authored-By: Brandon Morelli <bmorelli25@gmail.com>

* Change log level for `Central configuration contains not supported keys' to Info

* Fix issues causing tests to hang on Linux

* Comment out `nuget update` in msbuild.bat

* Add comment explaining why nuget update was commented out

* Make dbgName optional
gregkalapos added a commit that referenced this pull request Oct 12, 2019
The `.editorconfig` was changed in #497. That PR was about "Central Config Implementation". Let's revert the `.editorconfig` change and in case we really want to change it please do it in a separate PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement remote (AKA central) configuration

4 participants