2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-09-01 06:45:21 +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] = private implicit val cs: ContextShift[IO] =
IO.contextShift(scala.concurrent.ExecutionContext.global) 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 final case class Requeue(change: RecordSetChange) extends Throwable
def apply( def apply(
@@ -167,7 +172,7 @@ object RecordSetChangeHandler extends TransactionProvider {
if (existingRecords.isEmpty) ReadyToApply(change) if (existingRecords.isEmpty) ReadyToApply(change)
else if (isDnsMatch(existingRecords, change.recordSet, change.zone.name)) else if (isDnsMatch(existingRecords, change.recordSet, change.zone.name))
AlreadyApplied(change) AlreadyApplied(change)
else Failure(change, "Incompatible record in DNS.") else Failure(change, incompatibleRecordFailureMessage)
case RecordSetChangeType.Update => case RecordSetChangeType.Update =>
if (isDnsMatch(existingRecords, change.recordSet, change.zone.name)) if (isDnsMatch(existingRecords, change.recordSet, change.zone.name))
@@ -181,8 +186,7 @@ object RecordSetChangeHandler extends TransactionProvider {
else else
Failure( Failure(
change, change,
"This record set is out of sync with the DNS backend; " + outOfSyncFailureMessage
"sync this zone before attempting to update this record set."
) )
} }
@@ -388,11 +392,25 @@ object RecordSetChangeHandler extends TransactionProvider {
case AlreadyApplied(_) => Completed(change.successful) case AlreadyApplied(_) => Completed(change.successful)
case ReadyToApply(_) => Validated(change) case ReadyToApply(_) => Validated(change)
case Failure(_, message) => case Failure(_, message) =>
if(message == outOfSyncFailureMessage || message == incompatibleRecordFailureMessage){
Completed(
change.failed(
syncZoneMessage
)
)
} else if (message == "referral") {
Completed(
change.failed(
recordConflictMessage
)
)
} else {
Completed( Completed(
change.failed( change.failed(
s"""Failed validating update to DNS for change "${change.id}": "${change.recordSet.name}": """ + message s"""Failed validating update to DNS for change "${change.id}": "${change.recordSet.name}": """ + message
) )
) )
}
case Retry(_) => Retrying(change) 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) update_response = client.update_recordset(update_rs, status=202)
response = client.wait_until_recordset_change_status(update_response, "Failed") 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']}\": " 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."))
f"This record set is out of sync with the DNS backend; sync this zone before attempting to update this record set."))
finally: finally:
try: try:
delete_result = client.delete_recordset(zone["id"], create_rs["id"], status=202) delete_result = client.delete_recordset(zone["id"], create_rs["id"], status=202)

View File

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