Skip to content

Commit

Permalink
Merge pull request #32214 from vespa-engine/hmusum/return-empty-respo…
Browse files Browse the repository at this point in the history
…nse-if-not-getting-logs-for-3-minutes

Return empty log for 3 minutes (was 2 minutes) if not found
  • Loading branch information
olaaun authored Aug 21, 2024
2 parents bb47ac1 + 0b925dd commit b2f3e08
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ public class LogRetriever {
.socketTimeout(Timeout.ofSeconds(45))
.buildClient();

/**
* Fetches logs from the log server for a given application.
* An empty response will be returned if we are unable to fetch logs and
* the deployment is less than 3 minutes old
*/
@SuppressWarnings("deprecation")
public HttpResponse getLogs(HttpURL logServerUri, Optional<Instant> deployTime) {
HttpGet get = new HttpGet(logServerUri.asURI());
try {
return new ProxyResponse(httpClient.execute(get));
} catch (IOException e) {
// It takes some time before nodes are up after first-time deployment, return empty log for up to 2 minutes
// if getting logs fail
if (deployTime.isPresent() && Instant.now().isBefore(deployTime.get().plus(Duration.ofMinutes(2))))
if (deployTime.isPresent() && Instant.now().isBefore(deployTime.get().plus(Duration.ofMinutes(3))))
return new EmptyResponse();

throw new RuntimeException("Failed to get logs from " + logServerUri, e);
Expand Down

0 comments on commit b2f3e08

Please sign in to comment.