1 From e3eb933336605515fe8cc9968a83a37b7df6b257 Mon Sep 17 00:00:00 2001
2 From: Michael Tremer <michael.tremer@ipfire.org>
3 Date: Thu, 19 Apr 2012 17:02:09 +0200
4 Subject: [PATCH 04/16] client/daemon: Don't make internal server errors fatal
5 for keepalives/updates.
7 Because sometime, the hub could have some hiccups, this is no
8 reason to kill the daemon. It should retry sending the request in a short
11 However, we should now about the error and so the last try would
14 po/pakfire.pot | 137 ++++++++++++++++++++----------------
15 python/pakfire/client/base.py | 43 +++++++----
16 python/pakfire/client/transport.py | 8 +++
17 python/pakfire/errors.py | 4 ++
18 4 files changed, 117 insertions(+), 75 deletions(-)
20 diff --git a/po/pakfire.pot b/po/pakfire.pot
21 index 10f4e2a..4fd12e7 100644
24 @@ -8,7 +8,7 @@ msgid ""
26 "Project-Id-Version: PACKAGE VERSION\n"
27 "Report-Msgid-Bugs-To: \n"
28 -"POT-Creation-Date: 2012-04-14 14:32+0200\n"
29 +"POT-Creation-Date: 2012-04-19 16:57+0200\n"
30 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
31 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
32 "Language-Team: LANGUAGE <LL@li.org>\n"
33 @@ -116,7 +116,7 @@ msgstr ""
35 #: ../python/pakfire/base.py:382 ../python/pakfire/base.py:450
36 #: ../python/pakfire/base.py:487 ../python/pakfire/base.py:546
37 -#: ../python/pakfire/base.py:567 ../python/pakfire/transaction.py:389
38 +#: ../python/pakfire/base.py:567 ../python/pakfire/transaction.py:396
42 @@ -416,7 +416,7 @@ msgstr ""
43 msgid "Give name of at least one package to check."
46 -#: ../python/pakfire/cli.py:348 ../python/pakfire/transaction.py:398
47 +#: ../python/pakfire/cli.py:348 ../python/pakfire/transaction.py:405
51 @@ -740,7 +740,7 @@ msgid "Job: %(name)s"
54 #: ../python/pakfire/cli.py:1078 ../python/pakfire/packages/base.py:107
55 -#: ../python/pakfire/transaction.py:397
56 +#: ../python/pakfire/transaction.py:404
60 @@ -777,140 +777,151 @@ msgstr ""
61 msgid "Pakfire daemon command line interface."
64 -#: ../python/pakfire/cli.py:1161
65 +#: ../python/pakfire/cli.py:1156
66 msgid "Pakfire key command line interface."
69 -#: ../python/pakfire/cli.py:1205 ../python/pakfire/cli.py:1215
70 +#: ../python/pakfire/cli.py:1200 ../python/pakfire/cli.py:1210
71 msgid "Import a key from file."
74 -#: ../python/pakfire/cli.py:1207
75 +#: ../python/pakfire/cli.py:1202
76 msgid "The real name of the owner of this key."
79 -#: ../python/pakfire/cli.py:1209
80 +#: ../python/pakfire/cli.py:1204
81 msgid "The email address of the owner of this key."
84 -#: ../python/pakfire/cli.py:1217
85 +#: ../python/pakfire/cli.py:1212
86 msgid "Filename of that key to import."
89 -#: ../python/pakfire/cli.py:1223
90 +#: ../python/pakfire/cli.py:1218
91 msgid "Export a key to a file."
94 -#: ../python/pakfire/cli.py:1225
95 +#: ../python/pakfire/cli.py:1220
96 msgid "The ID of the key to export."
99 -#: ../python/pakfire/cli.py:1227
100 +#: ../python/pakfire/cli.py:1222
101 msgid "Write the key to this file."
104 -#: ../python/pakfire/cli.py:1233
105 +#: ../python/pakfire/cli.py:1228
106 msgid "Delete a key from the local keyring."
109 -#: ../python/pakfire/cli.py:1235
110 +#: ../python/pakfire/cli.py:1230
111 msgid "The ID of the key to delete."
114 -#: ../python/pakfire/cli.py:1241
115 +#: ../python/pakfire/cli.py:1236
116 msgid "List all imported keys."
119 -#: ../python/pakfire/cli.py:1247
120 +#: ../python/pakfire/cli.py:1242
121 msgid "Sign one or more packages."
124 -#: ../python/pakfire/cli.py:1249
125 +#: ../python/pakfire/cli.py:1244
126 msgid "Key that is used sign the package(s)."
129 -#: ../python/pakfire/cli.py:1251
130 +#: ../python/pakfire/cli.py:1246
131 msgid "Package(s) to sign."
134 -#: ../python/pakfire/cli.py:1257
135 +#: ../python/pakfire/cli.py:1252
136 msgid "Verify one or more packages."
139 -#: ../python/pakfire/cli.py:1261
140 +#: ../python/pakfire/cli.py:1256
141 msgid "Package(s) to verify."
144 -#: ../python/pakfire/cli.py:1268
145 +#: ../python/pakfire/cli.py:1263
146 msgid "Generating the key may take a moment..."
149 -#: ../python/pakfire/cli.py:1316
150 +#: ../python/pakfire/cli.py:1311
152 msgid "Signing %s..."
155 -#: ../python/pakfire/cli.py:1333
156 +#: ../python/pakfire/cli.py:1328
158 msgid "Verifying %s..."
161 -#: ../python/pakfire/cli.py:1343
162 +#: ../python/pakfire/cli.py:1338
163 msgid "This signature is valid."
166 -#: ../python/pakfire/cli.py:1346
167 +#: ../python/pakfire/cli.py:1341
171 -#: ../python/pakfire/cli.py:1347
172 +#: ../python/pakfire/cli.py:1342
173 msgid "Could not check if this signature is valid."
176 -#: ../python/pakfire/cli.py:1350 ../python/pakfire/keyring.py:96
177 +#: ../python/pakfire/cli.py:1345 ../python/pakfire/keyring.py:96
182 -#: ../python/pakfire/cli.py:1354 ../python/pakfire/keyring.py:99
183 +#: ../python/pakfire/cli.py:1349 ../python/pakfire/keyring.py:99
188 -#: ../python/pakfire/client/builder.py:173
189 +#. If the keepalive message could not successfully be sent, we don't
190 +#. bother, because the client will soon retry.
191 +#: ../python/pakfire/client/base.py:213
192 +msgid "Could not send a keepalive message to the hub."
195 +#. Don't give a shit either.
196 +#: ../python/pakfire/client/base.py:247
197 +msgid "Could not update the host information."
200 +#: ../python/pakfire/client/builder.py:179
201 msgid "Less than 2GB of free space. Cannot request a new job."
204 #. Log all XMLRPC protocol errors.
205 -#: ../python/pakfire/client/transport.py:78
206 +#: ../python/pakfire/client/transport.py:90
207 msgid "XMLRPC protocol error:"
210 -#: ../python/pakfire/client/transport.py:79
211 +#: ../python/pakfire/client/transport.py:91
216 -#: ../python/pakfire/client/transport.py:80
217 +#: ../python/pakfire/client/transport.py:92
218 msgid " HTTP headers:"
221 -#: ../python/pakfire/client/transport.py:83
222 +#: ../python/pakfire/client/transport.py:95
224 msgid "Error code: %s"
227 -#: ../python/pakfire/client/transport.py:84
228 +#: ../python/pakfire/client/transport.py:96
230 msgid "Error message: %s"
233 -#: ../python/pakfire/client/transport.py:104
234 +#: ../python/pakfire/client/transport.py:116
236 msgid "Trying again in %(timeout)s second(s). %(tries)s tries left."
239 -#: ../python/pakfire/client/transport.py:109
240 +#: ../python/pakfire/client/transport.py:121
241 msgid "Maximum number of tries was reached. Giving up."
244 @@ -981,7 +992,7 @@ msgstr ""
245 msgid "Running pakfire-build in a pakfire container?"
248 -#: ../python/pakfire/errors.py:94 ../python/pakfire/transaction.py:468
249 +#: ../python/pakfire/errors.py:94 ../python/pakfire/transaction.py:475
250 msgid "Transaction test was not successful"
253 @@ -996,10 +1007,14 @@ msgid ""
256 #: ../python/pakfire/errors.py:106
257 -msgid "Could not find the requested URL."
258 +msgid "A request could not be fulfilled by the server."
261 #: ../python/pakfire/errors.py:110
262 +msgid "Could not find the requested URL."
265 +#: ../python/pakfire/errors.py:114
266 msgid "An unforseable problem on the XML-RPC transport connection occured."
269 @@ -1070,7 +1085,7 @@ msgstr ""
273 -#: ../python/pakfire/packages/base.py:110 ../python/pakfire/transaction.py:397
274 +#: ../python/pakfire/packages/base.py:110 ../python/pakfire/transaction.py:404
278 @@ -1078,7 +1093,7 @@ msgstr ""
282 -#: ../python/pakfire/packages/base.py:115 ../python/pakfire/transaction.py:398
283 +#: ../python/pakfire/packages/base.py:115 ../python/pakfire/transaction.py:405
287 @@ -1356,93 +1371,93 @@ msgid ""
288 "perform transaction."
291 -#: ../python/pakfire/transaction.py:330
292 +#: ../python/pakfire/transaction.py:327
294 msgid "Not enough space to download %s of packages."
297 -#: ../python/pakfire/transaction.py:333
298 +#: ../python/pakfire/transaction.py:330
299 msgid "Downloading packages:"
302 -#: ../python/pakfire/transaction.py:397
303 +#: ../python/pakfire/transaction.py:404
307 -#: ../python/pakfire/transaction.py:402
308 +#: ../python/pakfire/transaction.py:409
312 -#: ../python/pakfire/transaction.py:403
313 +#: ../python/pakfire/transaction.py:410
314 msgid "Reinstalling:"
317 -#: ../python/pakfire/transaction.py:404
318 +#: ../python/pakfire/transaction.py:411
322 -#: ../python/pakfire/transaction.py:405
323 +#: ../python/pakfire/transaction.py:412
327 -#: ../python/pakfire/transaction.py:406
328 +#: ../python/pakfire/transaction.py:413
332 -#: ../python/pakfire/transaction.py:412
333 +#: ../python/pakfire/transaction.py:419
334 msgid "Transaction Summary"
337 -#: ../python/pakfire/transaction.py:419
338 +#: ../python/pakfire/transaction.py:426
342 -#: ../python/pakfire/transaction.py:425
343 +#: ../python/pakfire/transaction.py:432
345 msgid "Total download size: %s"
348 -#: ../python/pakfire/transaction.py:429
349 +#: ../python/pakfire/transaction.py:436
351 msgid "Installed size: %s"
354 -#: ../python/pakfire/transaction.py:432
355 +#: ../python/pakfire/transaction.py:439
357 msgid "Freed size: %s"
360 -#: ../python/pakfire/transaction.py:443
361 +#: ../python/pakfire/transaction.py:450
362 msgid "Is this okay?"
365 -#: ../python/pakfire/transaction.py:449
366 +#: ../python/pakfire/transaction.py:456
367 msgid "Running Transaction Test"
370 -#: ../python/pakfire/transaction.py:461
371 +#: ../python/pakfire/transaction.py:468
372 msgid "Transaction Test Succeeded"
375 #. Make a nice progressbar.
376 -#: ../python/pakfire/transaction.py:494
377 +#: ../python/pakfire/transaction.py:501
378 msgid "Verifying signatures..."
381 -#: ../python/pakfire/transaction.py:526
382 +#: ../python/pakfire/transaction.py:533
384 msgid "Found %s signature error(s)!"
387 -#: ../python/pakfire/transaction.py:531
388 +#: ../python/pakfire/transaction.py:538
389 msgid "Going on because we are running in permissive mode."
392 -#: ../python/pakfire/transaction.py:532
393 +#: ../python/pakfire/transaction.py:539
394 msgid "This is dangerous!"
397 -#: ../python/pakfire/transaction.py:553
398 +#: ../python/pakfire/transaction.py:560
399 msgid "Running transaction"
402 diff --git a/python/pakfire/client/base.py b/python/pakfire/client/base.py
403 index 632ec8b..cd661ca 100644
404 --- a/python/pakfire/client/base.py
405 +++ b/python/pakfire/client/base.py
406 @@ -204,7 +204,15 @@ class PakfireBuilderClient(BuildMixin, PakfireClient):
407 # Collect the current loadavg and send it to the hub.
408 loadavg = ", ".join(("%.2f" % round(l, 2) for l in os.getloadavg()))
410 - needs_update = self.conn.send_keepalive(loadavg, overload, free_space)
412 + needs_update = self.conn.send_keepalive(loadavg, overload, free_space)
414 + except XMLRPCInternalServerError:
415 + # If the keepalive message could not successfully be sent, we don't
416 + # bother, because the client will soon retry.
417 + log.warning(_("Could not send a keepalive message to the hub."))
421 if force or needs_update:
422 log.debug("The hub is requesting an update.")
423 @@ -215,20 +223,27 @@ class PakfireBuilderClient(BuildMixin, PakfireClient):
425 config = pakfire.config.ConfigDaemon()
427 - self.conn.send_update(
428 - # Supported architectures.
429 - system.supported_arches,
431 + self.conn.send_update(
432 + # Supported architectures.
433 + system.supported_arches,
439 + # Amount of memory in bytes.
440 + system.memory / 1024,
445 + # Send the currently running version of Pakfire.
448 - # Amount of memory in bytes.
449 - system.memory / 1024,
450 + # Send the host key.
451 + config.get("signatures", "host_key", None),
454 - # Send the currently running version of Pakfire.
456 + except XMLRPCInternalServerError:
457 + # Don't give a shit either.
458 + log.warning(_("Could not update the host information."))
460 - # Send the host key.
461 - config.get("signatures", "host_key", None),
464 diff --git a/python/pakfire/client/transport.py b/python/pakfire/client/transport.py
465 index 4fb8a8f..ac7de8d 100644
466 --- a/python/pakfire/client/transport.py
467 +++ b/python/pakfire/client/transport.py
468 @@ -72,6 +72,14 @@ class XMLRPCMixin:
470 raise XMLRPCNotFoundError(e)
472 + elif e.errcode == 500:
473 + # This could have various reasons, so we can not
474 + # be sure to kill connections here.
475 + # But to visualize the issue, we will raise an
476 + # exception on the last try.
478 + raise XMLRPCInternalServerError(e)
480 elif e.errcode == 503:
481 # Possibly the hub is not running but the SSL proxy
482 # is. Just try again in a short time.
483 diff --git a/python/pakfire/errors.py b/python/pakfire/errors.py
484 index c0f711f..3af257d 100644
485 --- a/python/pakfire/errors.py
486 +++ b/python/pakfire/errors.py
487 @@ -102,6 +102,10 @@ class XMLRPCForbiddenError(XMLRPCError):
488 message = _("You are forbidden to perform this action. Maybe you need to check your credentials.")
491 +class XMLRPCInternalServerError(XMLRPCError):
492 + message = _("A request could not be fulfilled by the server.")
495 class XMLRPCNotFoundError(XMLRPCError):
496 message = _("Could not find the requested URL.")