Skip to content

Commit

Permalink
Temporarily make fetch always try aggregate if content is nil (#155)
Browse files Browse the repository at this point in the history
We get a lot of 406 errors from travis-api V2 when trying to fetch log
and I tracked it down to be a case when the remote log returns a nil
content (the error is wrong and it should be 404, but that's another
matter). This might happen when a log in the database has a NULL
content, but aggregated_at is still for some reason set to a value.

This commit is a hack in a way that if the diagnosis is right, we should
fix it wherever the aggregated_at is wrongly set with content still
being null. But it seems like the easiest solution at the moment.
  • Loading branch information
drogus committed Sep 25, 2017
1 parent 46a43e7 commit 8857369
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/travis/logs/services/fetch_log.rb
Expand Up @@ -44,12 +44,15 @@ def run(job_id: nil, id: nil, aggregate_on_demand: true)
result = database.log_for_id(id) if id
return nil if result.nil?

content = result[:content]
content = result[:content]
aggregated_at = result[:aggregated_at]

if aggregate_on_demand && result[:aggregated_at].nil?
if aggregate_on_demand && (aggregated_at.nil? || content.nil?)
content = [
content, database.aggregated_on_demand(result[:id])
].join('')

content = nil if content.strip.empty?
end

removed_by_id = result.delete(:removed_by)
Expand Down

0 comments on commit 8857369

Please sign in to comment.