public inbox for ddns@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Catch "no route to host" errors
@ 2015-06-23 22:34 Michael Tremer
  2015-06-23 22:34 ` [PATCH 2/2] Soft-fail on network errors Michael Tremer
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Tremer @ 2015-06-23 22:34 UTC (permalink / raw)
  To: ddns

[-- Attachment #1: Type: text/plain, Size: 1185 bytes --]

When there is no route to a target host, we will throw
a DDNSNetworkError so that this error can be handled afterwards.

Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
---
 src/ddns/errors.py | 7 +++++++
 src/ddns/system.py | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/src/ddns/errors.py b/src/ddns/errors.py
index 293b4eb..26bc18e 100644
--- a/src/ddns/errors.py
+++ b/src/ddns/errors.py
@@ -109,6 +109,13 @@ class DDNSNetworkUnreachableError(DDNSNetworkError):
 	reason = N_("Network unreachable")
 
 
+class DDNSNoRouteToHostError(DDNSNetworkError):
+	"""
+		Thrown when there is no route to a host.
+	"""
+	reason = N_("No route to host")
+
+
 class DDNSNotFound(DDNSError):
 	"""
 		Thrown when the called URL has not been found
diff --git a/src/ddns/system.py b/src/ddns/system.py
index 8415579..6a21af8 100644
--- a/src/ddns/system.py
+++ b/src/ddns/system.py
@@ -211,6 +211,10 @@ class DDNSSystem(object):
 				elif e.reason.errno == 111:
 					raise DDNSConnectionRefusedError
 
+				# No route to host
+				elif e.reason.errno == 113:
+					raise DDNSNoRouteToHostError(req.host)
+
 			# Raise all other unhandled exceptions.
 			raise
 
-- 
1.8.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] Soft-fail on network errors
  2015-06-23 22:34 [PATCH 1/2] Catch "no route to host" errors Michael Tremer
@ 2015-06-23 22:34 ` Michael Tremer
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Tremer @ 2015-06-23 22:34 UTC (permalink / raw)
  To: ddns

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

When an update could not be performed because of a network
error (host unreachable/no route to host) we should not
log an error to the database and hold off updates for a
long time.

Those errors are usually caused by local configuration
errors and the servers of the providers should not be
bothered with update requests as those won't reach them
any way.

The client will try to resend the update at the next
update call.

Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
---
 src/ddns/providers.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/ddns/providers.py b/src/ddns/providers.py
index 28b765b..fc1fb82 100644
--- a/src/ddns/providers.py
+++ b/src/ddns/providers.py
@@ -161,6 +161,12 @@ class DDNSProvider(object):
 		try:
 			self.update()
 
+		# Catch network errors early, because we do not want to log
+		# them to the database. They are usually temporary and caused
+		# by the client side, so that we will retry quickly.
+		except DDNSNetworkError as e:
+			raise
+
 		# In case of any errors, log the failed request and
 		# raise the exception.
 		except DDNSError as e:
-- 
1.8.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-23 22:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-23 22:34 [PATCH 1/2] Catch "no route to host" errors Michael Tremer
2015-06-23 22:34 ` [PATCH 2/2] Soft-fail on network errors Michael Tremer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox