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

[SYNTH-16456] Postpone reporting results on 404 #1480

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Drarig29
Copy link
Contributor

@Drarig29 Drarig29 commented Oct 24, 2024

What and why?

There is sometimes some latency between batches and the poll results endpoint. When this happens, the poll results endpoint may return a 404 error because some queried results cannot be found, so the request ends up returning nothing.

Currently, we retry 3 times on 404 errors for that endpoint, and if the request never succeeds, datadog-ci quits and the CI fails.

How?

  • Extend our concept of incomplete results to also take care of results that have a 404: the reporting is postponed, then the incomplete results are fetched in next polling cycles.
  • We backup polling results in case the last polling cycle encounters a 404, because this last polling cycle has to fetch all results and we'll probably have fetched and reported most results already.
  • Like before, incomplete results may still be incomplete at the end of the batch: in that case, the result is reported without a server result and the following log is printed: The information for result {resultId} of test {publicId} was incomplete at the end of the batch.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)

@Drarig29 Drarig29 added the synthetics Related to [synthetics] label Oct 24, 2024
@Drarig29 Drarig29 marked this pull request as ready for review October 24, 2024 14:22
@Drarig29 Drarig29 requested review from a team as code owners October 24, 2024 14:22
isNonFinal: isNonFinalResult(resultInBatch),
location: getLocation(resultInBatch.location, test),
passed: hasResultPassed(resultInBatch, false, hasTimedOut, options),
result: {} as ServerResult,
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't need this, could we rather make it optional?

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'm afraid of how it could break customer's code. I'll check internally (web-ui and CI integrations)

@@ -268,6 +274,31 @@ const getResultFromBatch = (
}
}

const getResultWithoutPollResult = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the similarity between this function and the return statement from the above, could we merge the two, and add only the difference if pollResult is not available?

const resultFromBatch = {
    executionRule: resultInBatch.execution_rule,
    initialResultId: resultInBatch.initial_result_id,
    isNonFinal: isNonFinalResult(resultInBatch),
    location: getLocation(resultInBatch.location, test),
    passed: hasResultPassed(resultInBatch, isUnhealthy, hasTimedOut, options),
    resultId: getResultIdOrLinkedResultId(resultInBatch),
    retries: resultInBatch.retries || 0,
    maxRetries: resultInBatch.max_retries || 0,
    selectiveRerun: resultInBatch.selective_rerun,
    timedOut: hasTimedOut,
}

if (pollResult) {
  return {
    ...resultFromBatch,
    result: {
      ...pollResult.result,
      ...(safeDeadlineReached ? {
        failure: new BatchTimeoutRunawayError().toJson()
        passed: false
        } : timedOutRetry || hasTimedOut ? {
          failure: new {code: 'TIMEOUT', message: 'The batch timed out before receiving the result.'}
          passed: false
        } : {})
    },
    test: deepExtend({}, test, pollResult),
    timestamp: pollResult.timestamp
  }
} else {
  return {
    ...resultFromBatch,
    test: deepExtend({}, test),
    timestamp: Date.now()
  }
}

This code might not be the best solution, but will hopefully give you an idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

This way would make it more concise, but i'm not sure if having the two functions is not actually clearer and easier to understand 🤔

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 prefer the 2 functions as well tbh 😁

Copy link
Contributor

@teodor2312 teodor2312 left a comment

Choose a reason for hiding this comment

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

Apart from the question the Etienne has raised LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
synthetics Related to [synthetics]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants