lib/artifactory/cleaner/discovery_worker.rb in artifactory-cleaner-1.0.2 vs lib/artifactory/cleaner/discovery_worker.rb in artifactory-cleaner-1.0.3

- old
+ new

@@ -80,13 +80,14 @@ ## # pop from the incoming queue, process, push result to outgoing def process(payload) @working = true begin - @queues.outgoing.push discover_artifact_from payload + @queues.outgoing.push(discover_artifact_from(payload)) rescue => ex - return ex # TODO: Should this be pushed to the outgoing queue instead? + STDERR.puts "[Error] Exception in thread: #{ex.full_message}" + @queues.outgoing.push(ex) ensure @working = false end end @@ -96,23 +97,25 @@ # this method makes HTTP calls to the Artifactory API def discover_artifact_from(artifact_info, retries = 10) artifact = nil while retries > 0 begin + #STDERR.puts "[DEBUG] thread discover_artifact_from #{artifact_info["uri"]} start" retries -= 1 artifact = Artifactory::Cleaner::DiscoveredArtifact.from_url(artifact_info["uri"], client: @artifactory_client) artifact.last_downloaded = Time.parse(artifact_info["lastDownloaded"]) unless artifact_info["lastDownloaded"].to_s.empty? + #STDERR.puts "[DEBUG] thread discover_artifact_from #{artifact_info["uri"]} end" return artifact rescue Net::OpenTimeout, Artifactory::Error::ConnectionError => err artifact = err if retries log "[WARN] Connection Failure attempting to reach Artifactory API: #{err}; Retrying in 10 seconds" sleep 10 end rescue Artifactory::Error::HTTPError => err artifact = err if err.code == 404 - log "[WARN] HTTP 404 Not Found fetching: #{artifact["uri"]}" + log "[WARN] HTTP 404 Not Found fetching: #{artifact_info["uri"]}" return nil else retries = min(retries, 1) log "[ERROR] HTTP Error while fetching an artifact from a usage search: #{err}; #{retries ? 'Will' : 'Will not'} retry" end \ No newline at end of file