Repository navigation
Recover Azure App Service agents after overlapping restarts #12899
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
Open
Lewis-E
wants to merge
30
commits into
master
Choose a base branch
from
lewis.lewis/svls-9057-aas-agent-supervision
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
e7c76c0
Log AAS agent supervisor lifecycle at the default level
Lewis-E 548da50
Back off AAS agent restarts instead of giving up
Lewis-E 949028c
Health check and restart the AAS agent this tracer started
Lewis-E 3b5b539
Treat a busy AAS agent pipe as present
Lewis-E 85c2e77
Check that the AAS trace agent answers on its pipe
Lewis-E 6cd7eed
Test how ProcessSupervisor supervises the AAS agent
Lewis-E 2d02d24
Name the AAS agent pipe health checks by what they check
Lewis-E 15a9d15
Stop the AAS agent with a single TerminateProcess
Lewis-E 0bcc245
Fix AAS agent supervisor review findings
Lewis-E 10502c0
Test the Java 9+ child process PID lookup
Lewis-E e81efaa
Update internal-api/src/main/java/datadog/trace/util/PidHelper.java
Lewis-E 66ea5ef
Update internal-api/src/main/java/datadog/trace/util/ProcessSuperviso…
Lewis-E 3a66484
Fix the PidHelper imports and remove the unused PID function
Lewis-E d4604f1
Count AAS agent failures in one place
Lewis-E d1e37be
Test the child PID lookup through PidHelper
Lewis-E 3be4b0a
Fail the AAS trace agent check on a pipe that stays busy
Lewis-E a1cc028
Name the AAS supervisor's catch-all log line for what it covers
Lewis-E 2783ac5
Log why an AAS trace agent health check request failed
Lewis-E 73e3e55
Force-stop a supervised process that is still running after destroy()
Lewis-E 30cdef1
Send AAS trace agent health check requests on one reused thread
Lewis-E 0d6687f
Test the AAS trace agent check's timeout and late answers on any OS
Lewis-E c30290b
Forget AAS agent failures only after an adopted agent stays healthy
Lewis-E 45d6be2
Forget AAS agent failures through one helper
Lewis-E cbf0f41
Count AAS agent uptime only while it passes its health checks
Lewis-E ea73362
Count AAS agent failures in a row only in FaultBackoff
Lewis-E 4a06e8d
Mark ProcessSupervisor.FaultBackoff as visible for testing
Lewis-E b79da99
Document the AAS supervisor's new fields with Javadoc
Lewis-E 9ce41d0
Document how ProcessSupervisor uses its health check
Lewis-E 2785408
Stop the AAS trace agent health check thread when the supervisor stops
Lewis-E 5907ed2
Quiet the AAS supervisor's stop lines with its other lifecycle lines
Lewis-E File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
communication/src/test/java/datadog/communication/ddagent/NamedPipeHealthCheckTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package datadog.communication.ddagent; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import datadog.trace.test.util.PollingConditions; | ||
| import java.io.IOException; | ||
| import java.util.concurrent.Callable; | ||
| import java.util.concurrent.CountDownLatch; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.Timeout; | ||
|
|
||
| /** The timeout and late-answer handling of the trace agent check, without a named pipe. */ | ||
| class NamedPipeHealthCheckTest { | ||
|
|
||
| private final ExternalAgentLauncher.NamedPipeHealthCheck healthCheck = | ||
| new ExternalAgentLauncher.NamedPipeHealthCheck("test-pipe", true); | ||
| private final CountDownLatch release = new CountDownLatch(1); | ||
|
|
||
| @AfterEach | ||
| void releaseBlockedRequests() { | ||
| release.countDown(); | ||
| } | ||
|
|
||
| @Test | ||
| void countsTheResultOfARequestThatFinishesInTime() throws InterruptedException { | ||
| assertTrue(healthCheck.agentResponds(() -> true)); | ||
| assertFalse(healthCheck.agentResponds(() -> false)); | ||
| assertFalse( | ||
| healthCheck.agentResponds(() -> { | ||
| throw new IOException("broken pipe"); | ||
| })); | ||
| } | ||
|
|
||
| @Test | ||
| void countsALateAnswerAtTheNextCheck() throws InterruptedException { | ||
| assertFalse(healthCheck.agentResponds(answersOnceReleased(true))); | ||
| release.countDown(); | ||
|
|
||
| AtomicInteger newRequests = new AtomicInteger(); | ||
| new PollingConditions(5) | ||
| .eventually(() -> assertTrue(healthCheck.agentResponds(counting(newRequests, false)))); | ||
| assertEquals(0, newRequests.get()); | ||
| } | ||
|
|
||
| @Test | ||
| void sendsANewRequestAfterALateFailure() throws InterruptedException { | ||
| assertFalse(healthCheck.agentResponds(answersOnceReleased(false))); | ||
| release.countDown(); | ||
|
|
||
| AtomicInteger newRequests = new AtomicInteger(); | ||
| new PollingConditions(5) | ||
| .eventually(() -> assertTrue(healthCheck.agentResponds(counting(newRequests, true)))); | ||
| assertEquals(1, newRequests.get()); | ||
| } | ||
|
|
||
| @Test | ||
| @Timeout(10) // waiting on the pending request would block the supervisor thread | ||
| void sendsNoNewRequestWhileOneIsStillWaiting() throws InterruptedException { | ||
| assertFalse(healthCheck.agentResponds(answersOnceReleased(true))); | ||
|
|
||
| AtomicInteger newRequests = new AtomicInteger(); | ||
| assertFalse(healthCheck.agentResponds(counting(newRequests, true))); | ||
| assertEquals(0, newRequests.get()); | ||
| } | ||
|
|
||
| /** A request that answers only after the test releases it, so the first check times out. */ | ||
| private Callable<Boolean> answersOnceReleased(boolean answer) { | ||
| return () -> { | ||
| release.await(); | ||
| return answer; | ||
| }; | ||
| } | ||
|
|
||
| private static Callable<Boolean> counting(AtomicInteger requests, boolean answer) { | ||
| return () -> { | ||
| requests.incrementAndGet(); | ||
| return answer; | ||
| }; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.