]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - pakfire/patches/0004-client-daemon-Don-t-make-internal-server-errors-fata.patch
pakfire: Rebase on latest development status.
[people/ms/ipfire-3.x.git] / pakfire / patches / 0004-client-daemon-Don-t-make-internal-server-errors-fata.patch
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.
6
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
9 time.
10
11 However, we should now about the error and so the last try would
12 raise an exception.
13 ---
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(-)
19
20 diff --git a/po/pakfire.pot b/po/pakfire.pot
21 index 10f4e2a..4fd12e7 100644
22 --- a/po/pakfire.pot
23 +++ b/po/pakfire.pot
24 @@ -8,7 +8,7 @@ msgid ""
25 msgstr ""
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 ""
34
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
39 msgid "Nothing to do"
40 msgstr ""
41
42 @@ -416,7 +416,7 @@ msgstr ""
43 msgid "Give name of at least one package to check."
44 msgstr ""
45
46 -#: ../python/pakfire/cli.py:348 ../python/pakfire/transaction.py:398
47 +#: ../python/pakfire/cli.py:348 ../python/pakfire/transaction.py:405
48 msgid "Repository"
49 msgstr ""
50
51 @@ -740,7 +740,7 @@ msgid "Job: %(name)s"
52 msgstr ""
53
54 #: ../python/pakfire/cli.py:1078 ../python/pakfire/packages/base.py:107
55 -#: ../python/pakfire/transaction.py:397
56 +#: ../python/pakfire/transaction.py:404
57 msgid "Arch"
58 msgstr ""
59
60 @@ -777,140 +777,151 @@ msgstr ""
61 msgid "Pakfire daemon command line interface."
62 msgstr ""
63
64 -#: ../python/pakfire/cli.py:1161
65 +#: ../python/pakfire/cli.py:1156
66 msgid "Pakfire key command line interface."
67 msgstr ""
68
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."
72 msgstr ""
73
74 -#: ../python/pakfire/cli.py:1207
75 +#: ../python/pakfire/cli.py:1202
76 msgid "The real name of the owner of this key."
77 msgstr ""
78
79 -#: ../python/pakfire/cli.py:1209
80 +#: ../python/pakfire/cli.py:1204
81 msgid "The email address of the owner of this key."
82 msgstr ""
83
84 -#: ../python/pakfire/cli.py:1217
85 +#: ../python/pakfire/cli.py:1212
86 msgid "Filename of that key to import."
87 msgstr ""
88
89 -#: ../python/pakfire/cli.py:1223
90 +#: ../python/pakfire/cli.py:1218
91 msgid "Export a key to a file."
92 msgstr ""
93
94 -#: ../python/pakfire/cli.py:1225
95 +#: ../python/pakfire/cli.py:1220
96 msgid "The ID of the key to export."
97 msgstr ""
98
99 -#: ../python/pakfire/cli.py:1227
100 +#: ../python/pakfire/cli.py:1222
101 msgid "Write the key to this file."
102 msgstr ""
103
104 -#: ../python/pakfire/cli.py:1233
105 +#: ../python/pakfire/cli.py:1228
106 msgid "Delete a key from the local keyring."
107 msgstr ""
108
109 -#: ../python/pakfire/cli.py:1235
110 +#: ../python/pakfire/cli.py:1230
111 msgid "The ID of the key to delete."
112 msgstr ""
113
114 -#: ../python/pakfire/cli.py:1241
115 +#: ../python/pakfire/cli.py:1236
116 msgid "List all imported keys."
117 msgstr ""
118
119 -#: ../python/pakfire/cli.py:1247
120 +#: ../python/pakfire/cli.py:1242
121 msgid "Sign one or more packages."
122 msgstr ""
123
124 -#: ../python/pakfire/cli.py:1249
125 +#: ../python/pakfire/cli.py:1244
126 msgid "Key that is used sign the package(s)."
127 msgstr ""
128
129 -#: ../python/pakfire/cli.py:1251
130 +#: ../python/pakfire/cli.py:1246
131 msgid "Package(s) to sign."
132 msgstr ""
133
134 -#: ../python/pakfire/cli.py:1257
135 +#: ../python/pakfire/cli.py:1252
136 msgid "Verify one or more packages."
137 msgstr ""
138
139 -#: ../python/pakfire/cli.py:1261
140 +#: ../python/pakfire/cli.py:1256
141 msgid "Package(s) to verify."
142 msgstr ""
143
144 -#: ../python/pakfire/cli.py:1268
145 +#: ../python/pakfire/cli.py:1263
146 msgid "Generating the key may take a moment..."
147 msgstr ""
148
149 -#: ../python/pakfire/cli.py:1316
150 +#: ../python/pakfire/cli.py:1311
151 #, python-format
152 msgid "Signing %s..."
153 msgstr ""
154
155 -#: ../python/pakfire/cli.py:1333
156 +#: ../python/pakfire/cli.py:1328
157 #, python-format
158 msgid "Verifying %s..."
159 msgstr ""
160
161 -#: ../python/pakfire/cli.py:1343
162 +#: ../python/pakfire/cli.py:1338
163 msgid "This signature is valid."
164 msgstr ""
165
166 -#: ../python/pakfire/cli.py:1346
167 +#: ../python/pakfire/cli.py:1341
168 msgid "Unknown key"
169 msgstr ""
170
171 -#: ../python/pakfire/cli.py:1347
172 +#: ../python/pakfire/cli.py:1342
173 msgid "Could not check if this signature is valid."
174 msgstr ""
175
176 -#: ../python/pakfire/cli.py:1350 ../python/pakfire/keyring.py:96
177 +#: ../python/pakfire/cli.py:1345 ../python/pakfire/keyring.py:96
178 #, python-format
179 msgid "Created: %s"
180 msgstr ""
181
182 -#: ../python/pakfire/cli.py:1354 ../python/pakfire/keyring.py:99
183 +#: ../python/pakfire/cli.py:1349 ../python/pakfire/keyring.py:99
184 #, python-format
185 msgid "Expires: %s"
186 msgstr ""
187
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."
193 +msgstr ""
194 +
195 +#. Don't give a shit either.
196 +#: ../python/pakfire/client/base.py:247
197 +msgid "Could not update the host information."
198 +msgstr ""
199 +
200 +#: ../python/pakfire/client/builder.py:179
201 msgid "Less than 2GB of free space. Cannot request a new job."
202 msgstr ""
203
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:"
208 msgstr ""
209
210 -#: ../python/pakfire/client/transport.py:79
211 +#: ../python/pakfire/client/transport.py:91
212 #, python-format
213 msgid "URL: %s"
214 msgstr ""
215
216 -#: ../python/pakfire/client/transport.py:80
217 +#: ../python/pakfire/client/transport.py:92
218 msgid " HTTP headers:"
219 msgstr ""
220
221 -#: ../python/pakfire/client/transport.py:83
222 +#: ../python/pakfire/client/transport.py:95
223 #, python-format
224 msgid "Error code: %s"
225 msgstr ""
226
227 -#: ../python/pakfire/client/transport.py:84
228 +#: ../python/pakfire/client/transport.py:96
229 #, python-format
230 msgid "Error message: %s"
231 msgstr ""
232
233 -#: ../python/pakfire/client/transport.py:104
234 +#: ../python/pakfire/client/transport.py:116
235 #, python-format
236 msgid "Trying again in %(timeout)s second(s). %(tries)s tries left."
237 msgstr ""
238
239 -#: ../python/pakfire/client/transport.py:109
240 +#: ../python/pakfire/client/transport.py:121
241 msgid "Maximum number of tries was reached. Giving up."
242 msgstr ""
243
244 @@ -981,7 +992,7 @@ msgstr ""
245 msgid "Running pakfire-build in a pakfire container?"
246 msgstr ""
247
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"
251 msgstr ""
252
253 @@ -996,10 +1007,14 @@ msgid ""
254 msgstr ""
255
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."
259 msgstr ""
260
261 #: ../python/pakfire/errors.py:110
262 +msgid "Could not find the requested URL."
263 +msgstr ""
264 +
265 +#: ../python/pakfire/errors.py:114
266 msgid "An unforseable problem on the XML-RPC transport connection occured."
267 msgstr ""
268
269 @@ -1070,7 +1085,7 @@ msgstr ""
270 msgid "Name"
271 msgstr ""
272
273 -#: ../python/pakfire/packages/base.py:110 ../python/pakfire/transaction.py:397
274 +#: ../python/pakfire/packages/base.py:110 ../python/pakfire/transaction.py:404
275 msgid "Version"
276 msgstr ""
277
278 @@ -1078,7 +1093,7 @@ msgstr ""
279 msgid "Release"
280 msgstr ""
281
282 -#: ../python/pakfire/packages/base.py:115 ../python/pakfire/transaction.py:398
283 +#: ../python/pakfire/packages/base.py:115 ../python/pakfire/transaction.py:405
284 msgid "Size"
285 msgstr ""
286
287 @@ -1356,93 +1371,93 @@ msgid ""
288 "perform transaction."
289 msgstr ""
290
291 -#: ../python/pakfire/transaction.py:330
292 +#: ../python/pakfire/transaction.py:327
293 #, python-format
294 msgid "Not enough space to download %s of packages."
295 msgstr ""
296
297 -#: ../python/pakfire/transaction.py:333
298 +#: ../python/pakfire/transaction.py:330
299 msgid "Downloading packages:"
300 msgstr ""
301
302 -#: ../python/pakfire/transaction.py:397
303 +#: ../python/pakfire/transaction.py:404
304 msgid "Package"
305 msgstr ""
306
307 -#: ../python/pakfire/transaction.py:402
308 +#: ../python/pakfire/transaction.py:409
309 msgid "Installing:"
310 msgstr ""
311
312 -#: ../python/pakfire/transaction.py:403
313 +#: ../python/pakfire/transaction.py:410
314 msgid "Reinstalling:"
315 msgstr ""
316
317 -#: ../python/pakfire/transaction.py:404
318 +#: ../python/pakfire/transaction.py:411
319 msgid "Updating:"
320 msgstr ""
321
322 -#: ../python/pakfire/transaction.py:405
323 +#: ../python/pakfire/transaction.py:412
324 msgid "Downgrading:"
325 msgstr ""
326
327 -#: ../python/pakfire/transaction.py:406
328 +#: ../python/pakfire/transaction.py:413
329 msgid "Removing:"
330 msgstr ""
331
332 -#: ../python/pakfire/transaction.py:412
333 +#: ../python/pakfire/transaction.py:419
334 msgid "Transaction Summary"
335 msgstr ""
336
337 -#: ../python/pakfire/transaction.py:419
338 +#: ../python/pakfire/transaction.py:426
339 msgid "package"
340 msgstr ""
341
342 -#: ../python/pakfire/transaction.py:425
343 +#: ../python/pakfire/transaction.py:432
344 #, python-format
345 msgid "Total download size: %s"
346 msgstr ""
347
348 -#: ../python/pakfire/transaction.py:429
349 +#: ../python/pakfire/transaction.py:436
350 #, python-format
351 msgid "Installed size: %s"
352 msgstr ""
353
354 -#: ../python/pakfire/transaction.py:432
355 +#: ../python/pakfire/transaction.py:439
356 #, python-format
357 msgid "Freed size: %s"
358 msgstr ""
359
360 -#: ../python/pakfire/transaction.py:443
361 +#: ../python/pakfire/transaction.py:450
362 msgid "Is this okay?"
363 msgstr ""
364
365 -#: ../python/pakfire/transaction.py:449
366 +#: ../python/pakfire/transaction.py:456
367 msgid "Running Transaction Test"
368 msgstr ""
369
370 -#: ../python/pakfire/transaction.py:461
371 +#: ../python/pakfire/transaction.py:468
372 msgid "Transaction Test Succeeded"
373 msgstr ""
374
375 #. Make a nice progressbar.
376 -#: ../python/pakfire/transaction.py:494
377 +#: ../python/pakfire/transaction.py:501
378 msgid "Verifying signatures..."
379 msgstr ""
380
381 -#: ../python/pakfire/transaction.py:526
382 +#: ../python/pakfire/transaction.py:533
383 #, python-format
384 msgid "Found %s signature error(s)!"
385 msgstr ""
386
387 -#: ../python/pakfire/transaction.py:531
388 +#: ../python/pakfire/transaction.py:538
389 msgid "Going on because we are running in permissive mode."
390 msgstr ""
391
392 -#: ../python/pakfire/transaction.py:532
393 +#: ../python/pakfire/transaction.py:539
394 msgid "This is dangerous!"
395 msgstr ""
396
397 -#: ../python/pakfire/transaction.py:553
398 +#: ../python/pakfire/transaction.py:560
399 msgid "Running transaction"
400 msgstr ""
401
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()))
409
410 - needs_update = self.conn.send_keepalive(loadavg, overload, free_space)
411 + try:
412 + needs_update = self.conn.send_keepalive(loadavg, overload, free_space)
413 +
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."))
418 +
419 + return
420
421 if force or needs_update:
422 log.debug("The hub is requesting an update.")
423 @@ -215,20 +223,27 @@ class PakfireBuilderClient(BuildMixin, PakfireClient):
424
425 config = pakfire.config.ConfigDaemon()
426
427 - self.conn.send_update(
428 - # Supported architectures.
429 - system.supported_arches,
430 + try:
431 + self.conn.send_update(
432 + # Supported architectures.
433 + system.supported_arches,
434 +
435 + # CPU information.
436 + system.cpu_model,
437 + system.cpu_count,
438 +
439 + # Amount of memory in bytes.
440 + system.memory / 1024,
441
442 - # CPU information.
443 - system.cpu_model,
444 - system.cpu_count,
445 + # Send the currently running version of Pakfire.
446 + PAKFIRE_VERSION,
447
448 - # Amount of memory in bytes.
449 - system.memory / 1024,
450 + # Send the host key.
451 + config.get("signatures", "host_key", None),
452 + )
453
454 - # Send the currently running version of Pakfire.
455 - PAKFIRE_VERSION,
456 + except XMLRPCInternalServerError:
457 + # Don't give a shit either.
458 + log.warning(_("Could not update the host information."))
459
460 - # Send the host key.
461 - config.get("signatures", "host_key", None),
462 - )
463 + return
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:
469 # Cannot go on.
470 raise XMLRPCNotFoundError(e)
471
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.
477 + if tries == 1:
478 + raise XMLRPCInternalServerError(e)
479 +
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.")
489
490
491 +class XMLRPCInternalServerError(XMLRPCError):
492 + message = _("A request could not be fulfilled by the server.")
493 +
494 +
495 class XMLRPCNotFoundError(XMLRPCError):
496 message = _("Could not find the requested URL.")
497
498 --
499 1.7.10.4
500