2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-30 13:58:15 +00:00

parse, change and display single change failed message

This commit is contained in:
Aravindh-Raju
2024-02-08 15:02:48 +05:30
parent 17c937c0db
commit ffa09d88b2
3 changed files with 29 additions and 9 deletions

View File

@@ -35,6 +35,11 @@ object RecordSetChangeHandler extends TransactionProvider {
private implicit val cs: ContextShift[IO] =
IO.contextShift(scala.concurrent.ExecutionContext.global)
private val outOfSyncFailureMessage: String = "This record set is out of sync with the DNS backend; sync this zone before attempting to update this record set."
private val incompatibleRecordFailureMessage: String = "Incompatible record in DNS."
private val syncZoneMessage: String = "This record set is out of sync with the DNS backend. Sync this zone before attempting to update this record set."
private val recordConflictMessage: String = "Conflict due to the record being added having the same name as an NS record in the same zone."
final case class Requeue(change: RecordSetChange) extends Throwable
def apply(
@@ -167,7 +172,7 @@ object RecordSetChangeHandler extends TransactionProvider {
if (existingRecords.isEmpty) ReadyToApply(change)
else if (isDnsMatch(existingRecords, change.recordSet, change.zone.name))
AlreadyApplied(change)
else Failure(change, "Incompatible record in DNS.")
else Failure(change, incompatibleRecordFailureMessage)
case RecordSetChangeType.Update =>
if (isDnsMatch(existingRecords, change.recordSet, change.zone.name))
@@ -181,8 +186,7 @@ object RecordSetChangeHandler extends TransactionProvider {
else
Failure(
change,
"This record set is out of sync with the DNS backend; " +
"sync this zone before attempting to update this record set."
outOfSyncFailureMessage
)
}
@@ -388,11 +392,25 @@ object RecordSetChangeHandler extends TransactionProvider {
case AlreadyApplied(_) => Completed(change.successful)
case ReadyToApply(_) => Validated(change)
case Failure(_, message) =>
Completed(
change.failed(
s"""Failed validating update to DNS for change "${change.id}": "${change.recordSet.name}": """ + message
if(message == outOfSyncFailureMessage || message == incompatibleRecordFailureMessage){
Completed(
change.failed(
syncZoneMessage
)
)
)
} else if (message == "referral") {
Completed(
change.failed(
recordConflictMessage
)
)
} else {
Completed(
change.failed(
s"""Failed validating update to DNS for change "${change.id}": "${change.recordSet.name}": """ + message
)
)
}
case Retry(_) => Retrying(change)
}

View File

@@ -1593,8 +1593,7 @@ def test_update_fails_for_unapplied_unsynced_record_change(shared_zone_test_cont
]
update_response = client.update_recordset(update_rs, status=202)
response = client.wait_until_recordset_change_status(update_response, "Failed")
assert_that(response["systemMessage"], is_(f"Failed validating update to DNS for change \"{response['id']}\": \"{a_rs['name']}\": "
f"This record set is out of sync with the DNS backend; sync this zone before attempting to update this record set."))
assert_that(response["systemMessage"], is_(f"This record set is out of sync with the DNS backend. Sync this zone before attempting to update this record set."))
finally:
try:
delete_result = client.delete_recordset(zone["id"], create_rs["id"], status=202)

View File

@@ -194,6 +194,9 @@
&& change.status =='Complete'">
{{change.systemMessage}}
</div>
<div ng-if="(change.systemMessage != '' && change.systemMessage != undefined) && change.status =='Failed'">
{{change.systemMessage}}
</div>
</td>
</tr>
</tbody>