2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-30 22:05:21 +00:00

Merge branch 'master' into aravindhr/update-group-history

This commit is contained in:
Nicholas Spadaccino
2023-02-14 15:16:38 -05:00
committed by GitHub
19 changed files with 98 additions and 34 deletions

View File

@@ -39,6 +39,7 @@ import vinyldns.core.queue.{CommandMessage, MessageCount, MessageQueue}
import scala.concurrent.duration._ import scala.concurrent.duration._
import vinyldns.core.notifier.AllNotifiers import vinyldns.core.notifier.AllNotifiers
import java.io.{PrintWriter, StringWriter}
object CommandHandler { object CommandHandler {
@@ -94,7 +95,9 @@ object CommandHandler {
) )
.parJoin(maxOpen) .parJoin(maxOpen)
.handleErrorWith { error => .handleErrorWith { error =>
logger.error("Encountered unexpected error in main flow", error) val errorMessage = new StringWriter
error.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"Encountered unexpected error in main flow. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
// just continue, the flow should never stop unless explicitly told to do so // just continue, the flow should never stop unless explicitly told to do so
flow() flow()
@@ -123,7 +126,9 @@ object CommandHandler {
.handleErrorWith { error => .handleErrorWith { error =>
// on error, we make sure we still continue; should only stop when the app stops // on error, we make sure we still continue; should only stop when the app stops
// or processing is disabled // or processing is disabled
logger.error("Encountered error polling message queue", error) val errorMessage = new StringWriter
error.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"Encountered error polling message queue. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
// just keep going on the stream // just keep going on the stream
pollingStream() pollingStream()
@@ -182,7 +187,9 @@ object CommandHandler {
.attempt .attempt
.map { .map {
case Left(e) => case Left(e) =>
logger.warn(s"Failed processing message need to retry; $message", e) val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
logger.warn(s"Failed processing message need to retry; $message. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
RetryMessage(message) RetryMessage(message)
case Right(ok) => ok case Right(ok) => ok
} }

View File

@@ -28,7 +28,7 @@ import vinyldns.core.domain.backend.{Backend, BackendResponse}
import vinyldns.core.domain.record.RecordType.RecordType import vinyldns.core.domain.record.RecordType.RecordType
import vinyldns.core.domain.record.{RecordSet, RecordSetChange, RecordSetChangeType, RecordType} import vinyldns.core.domain.record.{RecordSet, RecordSetChange, RecordSetChangeType, RecordType}
import vinyldns.core.domain.zone.{Algorithm, Zone, ZoneConnection} import vinyldns.core.domain.zone.{Algorithm, Zone, ZoneConnection}
import java.io.{PrintWriter, StringWriter}
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
object DnsProtocol { object DnsProtocol {
@@ -213,8 +213,16 @@ class DnsBackend(val id: String, val resolver: DNS.SimpleResolver, val xfrInfo:
resp <- toDnsResponse(resp) resp <- toDnsResponse(resp)
} yield resp } yield resp
val receivedResponse = result match {
case Right(value) => value.toString.replaceAll("\n",";").replaceAll("\t"," ")
case Left(e) =>
val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")
}
logger.info( logger.info(
s"DnsConnection.send - Sending DNS Message ${obscuredDnsMessage(msg).toString}\n...received response $result" s"DnsConnection.send - Sending DNS Message ${obscuredDnsMessage(msg).toString.replaceAll("\n",";").replaceAll("\t"," ")}. Received response: $receivedResponse"
) )
result result
@@ -234,10 +242,10 @@ class DnsBackend(val id: String, val resolver: DNS.SimpleResolver, val xfrInfo:
// so if we can parse the error into an rcode, then we need to handle it properly; otherwise, we can try again // so if we can parse the error into an rcode, then we need to handle it properly; otherwise, we can try again
// The DNS.Rcode.value function will return -1 if the error cannot be parsed into an integer // The DNS.Rcode.value function will return -1 if the error cannot be parsed into an integer
if (DNS.Rcode.value(query.error) >= 0) { if (DNS.Rcode.value(query.error) >= 0) {
logger.info(s"Received TRY_AGAIN from DNS lookup; converting error: ${query.error}") logger.warn(s"Received TRY_AGAIN from DNS lookup; converting error: ${query.error.replaceAll("\n",";")}")
fromDnsRcodeToError(DNS.Rcode.value(query.error), query.error) fromDnsRcodeToError(DNS.Rcode.value(query.error), query.error)
} else { } else {
logger.warn(s"Unparseable error code returned from DNS: ${query.error}") logger.warn(s"Unparseable error code returned from DNS: ${query.error.replaceAll("\n",";")}")
Left(TryAgain(query.error)) Left(TryAgain(query.error))
} }

View File

@@ -29,6 +29,7 @@ import vinyldns.core.domain.record._
import vinyldns.core.domain.zone._ import vinyldns.core.domain.zone._
import vinyldns.core.route.Monitored import vinyldns.core.route.Monitored
import vinyldns.mysql.TransactionProvider import vinyldns.mysql.TransactionProvider
import java.io.{PrintWriter, StringWriter}
object ZoneSyncHandler extends DnsConversions with Monitored with TransactionProvider { object ZoneSyncHandler extends DnsConversions with Monitored with TransactionProvider {
@@ -169,9 +170,10 @@ object ZoneSyncHandler extends DnsConversions with Monitored with TransactionPro
} }
}.attempt.map { }.attempt.map {
case Left(e: Throwable) => case Left(e: Throwable) =>
val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
logger.error( logger.error(
s"Encountered error syncing ; zoneName='${zoneChange.zone.name}'; zoneChange='${zoneChange.id}'", s"Encountered error syncing ; zoneName='${zoneChange.zone.name}'; zoneChange='${zoneChange.id}'. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}"
e
) )
// We want to just move back to an active status, do not update latest sync // We want to just move back to an active status, do not update latest sync
zoneChange.copy( zoneChange.copy(

View File

@@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory
import vinyldns.api.route.VinylDNSJsonProtocol import vinyldns.api.route.VinylDNSJsonProtocol
import vinyldns.core.domain.batch.BatchChange import vinyldns.core.domain.batch.BatchChange
import vinyldns.core.notifier.{Notification, Notifier} import vinyldns.core.notifier.{Notification, Notifier}
import java.io.{PrintWriter, StringWriter}
class SnsNotifier(config: SnsNotifierConfig, sns: AmazonSNS) class SnsNotifier(config: SnsNotifierConfig, sns: AmazonSNS)
extends Notifier extends Notifier
@@ -52,6 +53,8 @@ class SnsNotifier(config: SnsNotifierConfig, sns: AmazonSNS)
sns.publish(request) sns.publish(request)
logger.info(s"Sending batch change success; batchChange='${bc.id}'") logger.info(s"Sending batch change success; batchChange='${bc.id}'")
}.handleErrorWith { e => }.handleErrorWith { e =>
IO(logger.error(s"Failed sending batch change; batchChange='${bc.id}'", e)) val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
IO(logger.error(s"Failed sending batch change; batchChange='${bc.id}'. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}"))
}.void }.void
} }

View File

@@ -84,6 +84,18 @@ trait DnsJsonProtocol extends JsonValidation {
(js \ "id").default[String](UUID.randomUUID.toString), (js \ "id").default[String](UUID.randomUUID.toString),
(js \ "singleBatchChangeIds").default[List[String]](List()) (js \ "singleBatchChangeIds").default[List[String]](List())
).mapN(RecordSetChange.apply) ).mapN(RecordSetChange.apply)
override def toJson(rs: RecordSetChange): JValue =
("zone" -> Extraction.decompose(rs.zone)) ~
("recordSet" -> Extraction.decompose(rs.recordSet)) ~
("userId" -> rs.userId) ~
("changeType" -> Extraction.decompose(rs.changeType)) ~
("status" -> Extraction.decompose(rs.status)) ~
("created" -> Extraction.decompose(rs.created)) ~
("systemMessage" -> rs.systemMessage) ~
("updates" -> Extraction.decompose(rs.updates)) ~
("id" -> rs.id) ~
("singleBatchChangeIds" -> Extraction.decompose(rs.singleBatchChangeIds))
} }
case object CreateZoneInputSerializer extends ValidationSerializer[CreateZoneInput] { case object CreateZoneInputSerializer extends ValidationSerializer[CreateZoneInput] {

View File

@@ -18,6 +18,7 @@ package vinyldns.core.health
import cats.effect.IO import cats.effect.IO
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.io.{PrintWriter, StringWriter}
object HealthCheck { object HealthCheck {
@@ -31,7 +32,9 @@ object HealthCheck {
def asHealthCheck(caller: Class[_]): HealthCheck = def asHealthCheck(caller: Class[_]): HealthCheck =
io.map { io.map {
case Left(err) => case Left(err) =>
logger.error(s"HealthCheck for ${caller.getCanonicalName} Failed", err) val errorMessage = new StringWriter
err.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"HealthCheck for ${caller.getCanonicalName} failed. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
val msg = Option(err.getMessage).getOrElse("no message from error") val msg = Option(err.getMessage).getOrElse("no message from error")
Left( Left(
HealthCheckError(s"${caller.getCanonicalName} health check failed with msg='${msg}'") HealthCheckError(s"${caller.getCanonicalName} health check failed with msg='${msg}'")

View File

@@ -20,6 +20,7 @@ import cats.effect.{ContextShift, IO}
import cats.implicits._ import cats.implicits._
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import vinyldns.core.route.Monitored import vinyldns.core.route.Monitored
import java.io.{PrintWriter, StringWriter}
final case class AllNotifiers(notifiers: List[Notifier])(implicit val cs: ContextShift[IO]) final case class AllNotifiers(notifiers: List[Notifier])(implicit val cs: ContextShift[IO])
extends Monitored { extends Monitored {
@@ -34,8 +35,10 @@ final case class AllNotifiers(notifiers: List[Notifier])(implicit val cs: Contex
def notify(notifier: Notifier, notification: Notification[_]): IO[Unit] = def notify(notifier: Notifier, notification: Notification[_]): IO[Unit] =
monitor(notifier.getClass.getSimpleName) { monitor(notifier.getClass.getSimpleName) {
notifier.notify(notification).handleErrorWith { e => notifier.notify(notification).handleErrorWith { e =>
val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
IO { IO {
logger.error(s"Notifier ${notifier.getClass.getSimpleName} failed.", e) logger.error(s"Notifier ${notifier.getClass.getSimpleName} failed. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
} }
} }
} }

View File

@@ -20,7 +20,7 @@ import cats.effect._
import nl.grons.metrics.scala.{Histogram, Meter, MetricName} import nl.grons.metrics.scala.{Histogram, Meter, MetricName}
import org.slf4j.{Logger, LoggerFactory} import org.slf4j.{Logger, LoggerFactory}
import vinyldns.core.Instrumented import vinyldns.core.Instrumented
import java.io.{PrintWriter, StringWriter}
import scala.collection._ import scala.collection._
trait Monitored { trait Monitored {
@@ -52,7 +52,9 @@ trait Monitored {
IO(t) IO(t)
case Left(e) => case Left(e) =>
logger.error(s"Finished $id; success=false; duration=$duration seconds", e) val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"Finished $id; success=false; duration=$duration seconds. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
IO.raiseError(e) IO.raiseError(e)
} }
} }

View File

@@ -20,7 +20,7 @@ import cats.implicits._
import fs2._ import fs2._
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import vinyldns.core.route.Monitored import vinyldns.core.route.Monitored
import java.io.{PrintWriter, StringWriter}
import scala.concurrent.duration.FiniteDuration import scala.concurrent.duration.FiniteDuration
// Interface for all Tasks that need to be run // Interface for all Tasks that need to be run
@@ -91,7 +91,9 @@ object TaskScheduler extends Monitored {
def runOnceSafely(task: Task): IO[Unit] = def runOnceSafely(task: Task): IO[Unit] =
monitor(s"task.${task.name}") { monitor(s"task.${task.name}") {
claimTask().bracket(runTask)(releaseTask).handleError { error => claimTask().bracket(runTask)(releaseTask).handleError { error =>
logger.error(s"""Unexpected error running task; taskName="${task.name}" """, error) val errorMessage = new StringWriter
error.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"""Unexpected error running task; taskName="${task.name}". Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")} """)
} }
} }

View File

@@ -116,7 +116,7 @@ class MonitorSpec
val msgCaptor = ArgumentCaptor.forClass(classOf[String]) val msgCaptor = ArgumentCaptor.forClass(classOf[String])
val errorCaptor = ArgumentCaptor.forClass(classOf[String]) val errorCaptor = ArgumentCaptor.forClass(classOf[String])
verify(traitTest.logger, times(1)).info(msgCaptor.capture()) verify(traitTest.logger, times(1)).info(msgCaptor.capture())
verify(traitTest.logger, times(1)).error(errorCaptor.capture(), any(classOf[Throwable])) verify(traitTest.logger, times(1)).error(errorCaptor.capture())
msgCaptor.getValue shouldBe "Starting timeSomethingBad" msgCaptor.getValue shouldBe "Starting timeSomethingBad"
errorCaptor.getValue should include("Finished timeSomethingBad; success=false; duration=") errorCaptor.getValue should include("Finished timeSomethingBad; success=false; duration=")

View File

@@ -19,7 +19,7 @@ package vinyldns.mysql
import cats.effect.IO import cats.effect.IO
import org.slf4j.{Logger, LoggerFactory} import org.slf4j.{Logger, LoggerFactory}
import scalikejdbc.{ConnectionPool, DB} import scalikejdbc.{ConnectionPool, DB}
import java.io.{PrintWriter, StringWriter}
import java.sql.SQLException import java.sql.SQLException
import java.util.UUID import java.util.UUID
@@ -52,7 +52,9 @@ trait TransactionProvider {
result result
} catch { } catch {
case e: Throwable => case e: Throwable =>
logger.error(s"Encountered error executing function within a database transaction ($txId). Rolling back transaction.", e) val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"Encountered error executing function within a database transaction ($txId). Rolling back transaction. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
db.rollbackIfActive() db.rollbackIfActive()
throw e throw e
} finally { } finally {

View File

@@ -34,6 +34,7 @@ import vinyldns.mysql.queue.MessageType.{
RecordChangeMessageType, RecordChangeMessageType,
ZoneChangeMessageType ZoneChangeMessageType
} }
import java.io.{PrintWriter, StringWriter}
import vinyldns.proto.VinylDNSProto import vinyldns.proto.VinylDNSProto
import java.time.temporal.ChronoUnit import java.time.temporal.ChronoUnit
import scala.concurrent.duration._ import scala.concurrent.duration._
@@ -210,7 +211,9 @@ class MySqlMessageQueue(maxRetries: Int)
// Errors could not be deserialized, have an invalid type, or exceeded retries // Errors could not be deserialized, have an invalid type, or exceeded retries
val errors = claimed.collect { val errors = claimed.collect {
case Left((e, id)) => case Left((e, id)) =>
logger.error(s"Encountered error for message with id $id", e) val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"Encountered error for message with id $id. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
id id
} }

View File

@@ -29,6 +29,7 @@ import vinyldns.core.repository._
import vinyldns.core.health.HealthCheck._ import vinyldns.core.health.HealthCheck._
import vinyldns.mysql.{HikariCloser, MySqlConnectionConfig, MySqlDataSourceSettings} import vinyldns.mysql.{HikariCloser, MySqlConnectionConfig, MySqlDataSourceSettings}
import vinyldns.mysql.MySqlConnector._ import vinyldns.mysql.MySqlConnector._
import java.io.{PrintWriter, StringWriter}
class MySqlDataStoreProvider extends DataStoreProvider { class MySqlDataStoreProvider extends DataStoreProvider {
@@ -99,7 +100,11 @@ class MySqlDataStoreProvider extends DataStoreProvider {
private def shutdown(): IO[Unit] = private def shutdown(): IO[Unit] =
IO(DBs.close()) IO(DBs.close())
.handleError(e => logger.error(s"Exception occurred while shutting down", e)) .handleError{ e =>
val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"Exception occurred while shutting down. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
}
private final val HEALTH_CHECK = private final val HEALTH_CHECK =
sql""" sql"""

View File

@@ -28,8 +28,8 @@ import vinyldns.core.domain.record.NameSort.{ASC, NameSort}
import vinyldns.core.domain.record.RecordType.RecordType import vinyldns.core.domain.record.RecordType.RecordType
import vinyldns.mysql.repository.MySqlRecordSetRepository.{PagingKey, fromRecordType, toFQDN} import vinyldns.mysql.repository.MySqlRecordSetRepository.{PagingKey, fromRecordType, toFQDN}
import vinyldns.proto.VinylDNSProto import vinyldns.proto.VinylDNSProto
import java.io.{PrintWriter, StringWriter}
import scala.util.{Try, Success, Failure} import scala.util.{Failure, Success, Try}
class MySqlRecordSetCacheRepository class MySqlRecordSetCacheRepository
extends RecordSetCacheRepository extends RecordSetCacheRepository
@@ -139,7 +139,9 @@ class MySqlRecordSetCacheRepository
} }
logger.info(s"Deleted $numDeleted records from zone $zoneName (zone id: $zone_id)") logger.info(s"Deleted $numDeleted records from zone $zoneName (zone id: $zone_id)")
}.handleErrorWith { error => }.handleErrorWith { error =>
logger.error(s"Failed deleting records from zone $zoneName (zone id: $zone_id)", error) val errorMessage = new StringWriter
error.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"Failed deleting records from zone $zoneName (zone id: $zone_id). Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
IO.raiseError(error) IO.raiseError(error)
} }
} }

View File

@@ -26,7 +26,7 @@ import vinyldns.core.domain.record._
import vinyldns.core.protobuf.ProtobufConversions import vinyldns.core.protobuf.ProtobufConversions
import vinyldns.core.route.Monitored import vinyldns.core.route.Monitored
import vinyldns.proto.VinylDNSProto import vinyldns.proto.VinylDNSProto
import java.io.{PrintWriter, StringWriter}
import scala.util.Try import scala.util.Try
class MySqlRecordSetRepository extends RecordSetRepository with Monitored { class MySqlRecordSetRepository extends RecordSetRepository with Monitored {
@@ -380,7 +380,9 @@ class MySqlRecordSetRepository extends RecordSetRepository with Monitored {
} }
logger.debug(s"Deleted $numDeleted records from zone $zoneName (zone id: $zoneId)") logger.debug(s"Deleted $numDeleted records from zone $zoneName (zone id: $zoneId)")
}.handleErrorWith { error => }.handleErrorWith { error =>
logger.error(s"Failed deleting records from zone $zoneName (zone id: $zoneId)", error) val errorMessage = new StringWriter
error.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"Failed deleting records from zone $zoneName (zone id: $zoneId). Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
IO.raiseError(error) IO.raiseError(error)
} }
} }

View File

@@ -27,7 +27,7 @@ import javax.naming.directory._
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import vinyldns.core.domain.membership.User import vinyldns.core.domain.membership.User
import vinyldns.core.health.HealthCheck._ import vinyldns.core.health.HealthCheck._
import java.io.{PrintWriter, StringWriter}
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
import scala.util.{Failure, Success, Try} import scala.util.{Failure, Success, Try}
@@ -134,9 +134,10 @@ object LdapAuthenticator {
else Left(UserDoesNotExistException(s"[$lookupUserName] LDAP entity does not exist")) else Left(UserDoesNotExistException(s"[$lookupUserName] LDAP entity does not exist"))
} catch { } catch {
case unexpectedError: Throwable => case unexpectedError: Throwable =>
val errorMessage = new StringWriter
unexpectedError.printStackTrace(new PrintWriter(errorMessage))
logger.error( logger.error(
s"LDAP Unexpected Error searching for user; userName='$lookupUserName'", s"LDAP Unexpected Error searching for user; userName='$lookupUserName'. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}"
unexpectedError
) )
Left(LdapServiceException(unexpectedError.getMessage)) Left(LdapServiceException(unexpectedError.getMessage))
} finally { } finally {

View File

@@ -46,6 +46,7 @@ import scala.concurrent.ExecutionContext
import scala.util.{Failure, Success, Try} import scala.util.{Failure, Success, Try}
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
import pureconfig.ConfigSource import pureconfig.ConfigSource
import java.io.{PrintWriter, StringWriter}
object OidcAuthenticator { object OidcAuthenticator {
final case class OidcConfig( final case class OidcConfig(
@@ -186,7 +187,9 @@ class OidcAuthenticator @Inject() (wsClient: WSClient, configuration: Configurat
val claimsSet = Try(JWTClaimsSet.parse(jwtClaimsSetString)) match { val claimsSet = Try(JWTClaimsSet.parse(jwtClaimsSetString)) match {
case Success(s) => Some(s) case Success(s) => Some(s)
case Failure(e) => case Failure(e) =>
logger.error(s"oidc session token parse error: ${e.getMessage}") val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"oidc session token parse error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
None None
} }
@@ -260,7 +263,9 @@ class OidcAuthenticator @Inject() (wsClient: WSClient, configuration: Configurat
Either Either
.fromTry(Try(t)) .fromTry(Try(t))
.leftMap { err => .leftMap { err =>
logger.error(s"Unexpected error in OIDC flow: ${err.getMessage}") val errorMessage = new StringWriter
err.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"Unexpected error in OIDC flow: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
ErrorResponse(500, err.getMessage) ErrorResponse(500, err.getMessage)
} }
} }

View File

@@ -39,7 +39,7 @@ import vinyldns.sqs.queue.SqsMessageType.{
SqsRecordSetChangeMessage, SqsRecordSetChangeMessage,
SqsZoneChangeMessage SqsZoneChangeMessage
} }
import java.io.{PrintWriter, StringWriter}
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
import scala.concurrent.duration.FiniteDuration import scala.concurrent.duration.FiniteDuration
@@ -105,7 +105,9 @@ class SqsMessageQueue(val queueUrl: String, val client: AmazonSQSAsync)
// This is tricky, we need to attempt to parse the message. If we cannot, delete it; otherwise return ok // This is tricky, we need to attempt to parse the message. If we cannot, delete it; otherwise return ok
IO(SqsMessage.parseSqsMessage(message)).flatMap { IO(SqsMessage.parseSqsMessage(message)).flatMap {
case Left(e) => case Left(e) =>
logger.error(s"Failed handling message with id '${message.getMessageId}'", e) val errorMessage = new StringWriter
e.printStackTrace(new PrintWriter(errorMessage))
logger.error(s"Failed handling message with id '${message.getMessageId}'. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}")
delete(message.getReceiptHandle).as(Left(e)) delete(message.getReceiptHandle).as(Left(e))
case Right(ok) => IO.pure(Right(ok)) case Right(ok) => IO.pure(Right(ok))
} }

View File

@@ -1 +1 @@
version in ThisBuild := "0.17.0" version in ThisBuild := "0.17.2"