Skip to content

Commit

Permalink
Handle case where the applictaion is stopped without other telemetry …
Browse files Browse the repository at this point in the history
…sent

This lead down to a path where the Stop action was actually enqueued without being ever causing a removal of the Application instances.

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
  • Loading branch information
bwoebi committed Nov 15, 2024
1 parent 9ffc56b commit ae035cb
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions sidecar/src/service/sidecar_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,27 @@ impl SidecarInterface for SidecarServer {
queue_id: QueueId,
actions: Vec<SidecarAction>,
) -> Self::EnqueueActionsFut {
fn is_stop_actions(actions: &[SidecarAction]) -> bool {
actions.len() != 1
|| !matches!(
actions[0],
SidecarAction::Telemetry(TelemetryActions::Lifecycle(LifecycleAction::Stop))
)
}

let rt_info = self.get_runtime(&instance_id);
let mut applications = rt_info.lock_applications();
match applications.entry(queue_id) {
Entry::Occupied(mut entry) => {
let value = entry.get_mut();
match value.app_or_actions {
AppOrQueue::Inactive => {
value.app_or_actions =
AppOrQueue::Queue(EnqueuedTelemetryData::processed(actions));
if is_stop_actions(&actions) {
entry.remove();
} else {
value.app_or_actions =
AppOrQueue::Queue(EnqueuedTelemetryData::processed(actions));
}
}
AppOrQueue::Queue(ref mut data) => {
data.process(actions);
Expand Down Expand Up @@ -491,14 +503,7 @@ impl SidecarInterface for SidecarServer {
}
}
Entry::Vacant(entry) => {
if actions.len() != 1
|| !matches!(
actions[0],
SidecarAction::Telemetry(TelemetryActions::Lifecycle(
LifecycleAction::Stop
))
)
{
if is_stop_actions(&actions) {
entry.insert(ActiveApplication {
app_or_actions: AppOrQueue::Queue(EnqueuedTelemetryData::processed(
actions,
Expand Down

0 comments on commit ae035cb

Please sign in to comment.