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:
@@ -39,6 +39,7 @@ import vinyldns.core.queue.{CommandMessage, MessageCount, MessageQueue}
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import vinyldns.core.notifier.AllNotifiers
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
|
||||
object CommandHandler {
|
||||
|
||||
@@ -94,7 +95,9 @@ object CommandHandler {
|
||||
)
|
||||
.parJoin(maxOpen)
|
||||
.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
|
||||
flow()
|
||||
@@ -123,7 +126,9 @@ object CommandHandler {
|
||||
.handleErrorWith { error =>
|
||||
// on error, we make sure we still continue; should only stop when the app stops
|
||||
// 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
|
||||
pollingStream()
|
||||
@@ -182,7 +187,9 @@ object CommandHandler {
|
||||
.attempt
|
||||
.map {
|
||||
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)
|
||||
case Right(ok) => ok
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ import vinyldns.core.domain.backend.{Backend, BackendResponse}
|
||||
import vinyldns.core.domain.record.RecordType.RecordType
|
||||
import vinyldns.core.domain.record.{RecordSet, RecordSetChange, RecordSetChangeType, RecordType}
|
||||
import vinyldns.core.domain.zone.{Algorithm, Zone, ZoneConnection}
|
||||
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
object DnsProtocol {
|
||||
@@ -213,8 +213,16 @@ class DnsBackend(val id: String, val resolver: DNS.SimpleResolver, val xfrInfo:
|
||||
resp <- toDnsResponse(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(
|
||||
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
|
||||
@@ -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
|
||||
// The DNS.Rcode.value function will return -1 if the error cannot be parsed into an integer
|
||||
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)
|
||||
} 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))
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,7 @@ import vinyldns.core.domain.record._
|
||||
import vinyldns.core.domain.zone._
|
||||
import vinyldns.core.route.Monitored
|
||||
import vinyldns.mysql.TransactionProvider
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
|
||||
object ZoneSyncHandler extends DnsConversions with Monitored with TransactionProvider {
|
||||
|
||||
@@ -169,9 +170,10 @@ object ZoneSyncHandler extends DnsConversions with Monitored with TransactionPro
|
||||
}
|
||||
}.attempt.map {
|
||||
case Left(e: Throwable) =>
|
||||
val errorMessage = new StringWriter
|
||||
e.printStackTrace(new PrintWriter(errorMessage))
|
||||
logger.error(
|
||||
s"Encountered error syncing ; zoneName='${zoneChange.zone.name}'; zoneChange='${zoneChange.id}'",
|
||||
e
|
||||
s"Encountered error syncing ; zoneName='${zoneChange.zone.name}'; zoneChange='${zoneChange.id}'. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}"
|
||||
)
|
||||
// We want to just move back to an active status, do not update latest sync
|
||||
zoneChange.copy(
|
||||
|
@@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory
|
||||
import vinyldns.api.route.VinylDNSJsonProtocol
|
||||
import vinyldns.core.domain.batch.BatchChange
|
||||
import vinyldns.core.notifier.{Notification, Notifier}
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
|
||||
class SnsNotifier(config: SnsNotifierConfig, sns: AmazonSNS)
|
||||
extends Notifier
|
||||
@@ -52,6 +53,8 @@ class SnsNotifier(config: SnsNotifierConfig, sns: AmazonSNS)
|
||||
sns.publish(request)
|
||||
logger.info(s"Sending batch change success; batchChange='${bc.id}'")
|
||||
}.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
|
||||
}
|
||||
|
@@ -84,6 +84,18 @@ trait DnsJsonProtocol extends JsonValidation {
|
||||
(js \ "id").default[String](UUID.randomUUID.toString),
|
||||
(js \ "singleBatchChangeIds").default[List[String]](List())
|
||||
).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] {
|
||||
|
@@ -18,6 +18,7 @@ package vinyldns.core.health
|
||||
|
||||
import cats.effect.IO
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
|
||||
object HealthCheck {
|
||||
|
||||
@@ -31,7 +32,9 @@ object HealthCheck {
|
||||
def asHealthCheck(caller: Class[_]): HealthCheck =
|
||||
io.map {
|
||||
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")
|
||||
Left(
|
||||
HealthCheckError(s"${caller.getCanonicalName} health check failed with msg='${msg}'")
|
||||
|
@@ -20,6 +20,7 @@ import cats.effect.{ContextShift, IO}
|
||||
import cats.implicits._
|
||||
import org.slf4j.LoggerFactory
|
||||
import vinyldns.core.route.Monitored
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
|
||||
final case class AllNotifiers(notifiers: List[Notifier])(implicit val cs: ContextShift[IO])
|
||||
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] =
|
||||
monitor(notifier.getClass.getSimpleName) {
|
||||
notifier.notify(notification).handleErrorWith { e =>
|
||||
val errorMessage = new StringWriter
|
||||
e.printStackTrace(new PrintWriter(errorMessage))
|
||||
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"," ")}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ import cats.effect._
|
||||
import nl.grons.metrics.scala.{Histogram, Meter, MetricName}
|
||||
import org.slf4j.{Logger, LoggerFactory}
|
||||
import vinyldns.core.Instrumented
|
||||
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
import scala.collection._
|
||||
|
||||
trait Monitored {
|
||||
@@ -52,7 +52,9 @@ trait Monitored {
|
||||
IO(t)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ import cats.implicits._
|
||||
import fs2._
|
||||
import org.slf4j.LoggerFactory
|
||||
import vinyldns.core.route.Monitored
|
||||
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
import scala.concurrent.duration.FiniteDuration
|
||||
|
||||
// Interface for all Tasks that need to be run
|
||||
@@ -91,7 +91,9 @@ object TaskScheduler extends Monitored {
|
||||
def runOnceSafely(task: Task): IO[Unit] =
|
||||
monitor(s"task.${task.name}") {
|
||||
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"," ")} """)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -116,7 +116,7 @@ class MonitorSpec
|
||||
val msgCaptor = ArgumentCaptor.forClass(classOf[String])
|
||||
val errorCaptor = ArgumentCaptor.forClass(classOf[String])
|
||||
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"
|
||||
errorCaptor.getValue should include("Finished timeSomethingBad; success=false; duration=")
|
||||
|
@@ -19,7 +19,7 @@ package vinyldns.mysql
|
||||
import cats.effect.IO
|
||||
import org.slf4j.{Logger, LoggerFactory}
|
||||
import scalikejdbc.{ConnectionPool, DB}
|
||||
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
import java.sql.SQLException
|
||||
import java.util.UUID
|
||||
|
||||
@@ -52,7 +52,9 @@ trait TransactionProvider {
|
||||
result
|
||||
} catch {
|
||||
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()
|
||||
throw e
|
||||
} finally {
|
||||
|
@@ -34,6 +34,7 @@ import vinyldns.mysql.queue.MessageType.{
|
||||
RecordChangeMessageType,
|
||||
ZoneChangeMessageType
|
||||
}
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
import vinyldns.proto.VinylDNSProto
|
||||
import java.time.temporal.ChronoUnit
|
||||
import scala.concurrent.duration._
|
||||
@@ -210,7 +211,9 @@ class MySqlMessageQueue(maxRetries: Int)
|
||||
// Errors could not be deserialized, have an invalid type, or exceeded retries
|
||||
val errors = claimed.collect {
|
||||
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
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,7 @@ import vinyldns.core.repository._
|
||||
import vinyldns.core.health.HealthCheck._
|
||||
import vinyldns.mysql.{HikariCloser, MySqlConnectionConfig, MySqlDataSourceSettings}
|
||||
import vinyldns.mysql.MySqlConnector._
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
|
||||
class MySqlDataStoreProvider extends DataStoreProvider {
|
||||
|
||||
@@ -99,7 +100,11 @@ class MySqlDataStoreProvider extends DataStoreProvider {
|
||||
|
||||
private def shutdown(): IO[Unit] =
|
||||
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 =
|
||||
sql"""
|
||||
|
@@ -28,8 +28,8 @@ import vinyldns.core.domain.record.NameSort.{ASC, NameSort}
|
||||
import vinyldns.core.domain.record.RecordType.RecordType
|
||||
import vinyldns.mysql.repository.MySqlRecordSetRepository.{PagingKey, fromRecordType, toFQDN}
|
||||
import vinyldns.proto.VinylDNSProto
|
||||
|
||||
import scala.util.{Try, Success, Failure}
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
import scala.util.{Failure, Success, Try}
|
||||
|
||||
class MySqlRecordSetCacheRepository
|
||||
extends RecordSetCacheRepository
|
||||
@@ -139,7 +139,9 @@ class MySqlRecordSetCacheRepository
|
||||
}
|
||||
logger.info(s"Deleted $numDeleted records from zone $zoneName (zone id: $zone_id)")
|
||||
}.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)
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import vinyldns.core.domain.record._
|
||||
import vinyldns.core.protobuf.ProtobufConversions
|
||||
import vinyldns.core.route.Monitored
|
||||
import vinyldns.proto.VinylDNSProto
|
||||
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
import scala.util.Try
|
||||
|
||||
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)")
|
||||
}.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)
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ import javax.naming.directory._
|
||||
import org.slf4j.LoggerFactory
|
||||
import vinyldns.core.domain.membership.User
|
||||
import vinyldns.core.health.HealthCheck._
|
||||
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.util.{Failure, Success, Try}
|
||||
|
||||
@@ -134,9 +134,10 @@ object LdapAuthenticator {
|
||||
else Left(UserDoesNotExistException(s"[$lookupUserName] LDAP entity does not exist"))
|
||||
} catch {
|
||||
case unexpectedError: Throwable =>
|
||||
val errorMessage = new StringWriter
|
||||
unexpectedError.printStackTrace(new PrintWriter(errorMessage))
|
||||
logger.error(
|
||||
s"LDAP Unexpected Error searching for user; userName='$lookupUserName'",
|
||||
unexpectedError
|
||||
s"LDAP Unexpected Error searching for user; userName='$lookupUserName'. Error: ${errorMessage.toString.replaceAll("\n",";").replaceAll("\t"," ")}"
|
||||
)
|
||||
Left(LdapServiceException(unexpectedError.getMessage))
|
||||
} finally {
|
||||
|
@@ -46,6 +46,7 @@ import scala.concurrent.ExecutionContext
|
||||
import scala.util.{Failure, Success, Try}
|
||||
import scala.collection.JavaConverters._
|
||||
import pureconfig.ConfigSource
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
|
||||
object OidcAuthenticator {
|
||||
final case class OidcConfig(
|
||||
@@ -186,7 +187,9 @@ class OidcAuthenticator @Inject() (wsClient: WSClient, configuration: Configurat
|
||||
val claimsSet = Try(JWTClaimsSet.parse(jwtClaimsSetString)) match {
|
||||
case Success(s) => Some(s)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -260,7 +263,9 @@ class OidcAuthenticator @Inject() (wsClient: WSClient, configuration: Configurat
|
||||
Either
|
||||
.fromTry(Try(t))
|
||||
.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)
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ import vinyldns.sqs.queue.SqsMessageType.{
|
||||
SqsRecordSetChangeMessage,
|
||||
SqsZoneChangeMessage
|
||||
}
|
||||
|
||||
import java.io.{PrintWriter, StringWriter}
|
||||
import scala.collection.JavaConverters._
|
||||
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
|
||||
IO(SqsMessage.parseSqsMessage(message)).flatMap {
|
||||
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))
|
||||
case Right(ok) => IO.pure(Right(ok))
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
version in ThisBuild := "0.17.0"
|
||||
version in ThisBuild := "0.17.2"
|
||||
|
Reference in New Issue
Block a user