annotate mod_s2s_cache_failures/mod_s2s_cache_failures.lua @ 6513:5fb466693e85

mod_storage_xmlarchive: Ensure list index files are removed using os.remove() on the list files leaves the new index files behind since util.datamanager does not know they are removed. Thanks Link Mauve
author Kim Alvefur <zash@zash.se>
date Tue, 07 Apr 2026 21:10:54 +0200
parents 7ed4627ba65d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6343
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 module:set_global();
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local cache = require "prosody.util.cache";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local st = require "prosody.util.stanza";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 local time = require "prosody.util.time";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 local measure_failed_domains = module:metric(
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 "gauge", "failed_domains", "",
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 "Number of cached domain failures"
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 );
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 local measure_rejected_stanzas = module:metric(
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 "counter", "failed_stanzas", "",
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 "Number of rejected stanzas to failed domains"
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 );
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 local failed_domains_cache_size = module:get_option_number("s2s_failure_cache_size", 128);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 local domains = cache.new(failed_domains_cache_size);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 -- This function returns an appropriate delay until we should retry connecting
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 -- It includes randomness, so that every Prosody server does not attempt
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 -- to reconnect to the target server at the same time (which may overload it
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 -- and cause further downtime). The logic and numbers here results in approximately
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 -- 15 retries per hour, with up to 30min between attempts.
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 local function get_holdoff_time(first_disconnect, last_disconnect)
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 -- Retry for a server that has been down for 2 hours will be the same
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 -- range as a server that has been down for 1 hour
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 local downtime = math.min(3600, last_disconnect - first_disconnect);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 -- Range from at least 10-20s up to a range proportional to the downtime
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 return math.random(10 + downtime/4, 20 + downtime/2);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 module:hook("s2sout-established", function (event)
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 -- Successfully connected, so stop tracking this domain
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 local domain = event.session.to_host;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 domains:set(domain, nil);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 end);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 module:hook("s2sout-destroyed", function (event)
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 local domain = event.session.to_host;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 if not event.reason or event.session.type ~= "s2sout_unauthed" then
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 return;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 local current_time = time.now();
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 local holdoff_time = get_holdoff_time(current_time, current_time);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 local state = domains:get(domain) or { current_time, nil, -1, current_time + holdoff_time, event.reason };
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 state[2], state[3] = current_time, state[3] + 1;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 domains:set(domain, state);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 module:log("info", "Preventing further connections to %s for %d seconds", holdoff_time);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 end);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 module:hook("route/remote", function (event)
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 local origin, stanza, domain = event.origin, event.stanza, event.to_host;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 local domain_info = domains:get(domain);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 if domain_info then
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 measure_rejected_stanzas:add(1);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58 local holdoff_until = domain_info[4];
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 if time.now() < holdoff_until then
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 return;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 local reply = st.error_reply(
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 stanza,
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 "wait",
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 "remote-server-timeout",
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 domain_info[5] and ("Unreachable domain ("..domain_info[5]..")") or "Unreachable domain"
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 );
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 return origin.send(reply);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 end);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 module:hook("stats-update", function ()
6347
7ed4627ba65d mod_s2s_cache_failures: Fix traceback when reporting stats (thanks sundance)
Kim Alvefur <zash@zash.se>
parents: 6343
diff changeset
73 measure_failed_domains:with_labels():set(domains:count());
6343
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 end);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 module:add_item("shell-command", {
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 section = "s2s";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 section_desc = "View and manage server-to-server connections";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
79 name = "reset_failures";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80 desc = "Clear cache of connection failures";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 args = {
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 { name = "remote_host", type = "string" };
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 };
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 handler = function (_, remote_host)
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85 if remote_host then
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 if domains:get(remote_host) == nil then
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 return false, "No failure cached for "..remote_host;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 domains:set(remote_host, nil);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 return true, "Reset failure cache for "..remote_host;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 -- No remote host specified, so clear all
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 domains:clear();
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 return true, "Failure cache cleared";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 end;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 });
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 module:add_item("shell-command", {
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
100 section = "s2s";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101 section_desc = "View and manage server-to-server connections";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 name = "show_failures";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 desc = "Show cache of connection failures";
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104 args = {
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 { name = "remote_host", type = "string" };
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 };
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 handler = function (shell, remote_host)
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 local function show_domain_failures(domain, domain_info)
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 domain_info = domain_info or domains:get(domain);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 if not domain_info then
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 return false;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
113 local first_disconnect, last_disconnect = domain_info[1], domain_info[2];
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 local attempts, holdoff, reason = domain_info[3], domain_info[4], domain_info[5];
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 shell.session.print(domain..":");
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 shell.session.print(" First disconnected: "..os.date("%c", first_disconnect));
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 shell.session.print(" Last disconnected: "..os.date("%c", last_disconnect));
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119 if reason then
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 shell.session.print(" because: "..reason);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122 shell.session.print(" Reconnection attempts: "..attempts);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 shell.session.print(" No more attempts until: "..os.date("%c", last_disconnect + holdoff));
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 return true;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 if remote_host then
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 if not show_domain_failures(remote_host) then
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 return false, "No failure cached for "..remote_host;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 return true, "Showing failure record for "..remote_host;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 local c = 0;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 for domain, domain_info in domains:items() do
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 c = c + 1;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 show_domain_failures(domain, domain_info);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 end
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 return true, ("Showing %d failure records"):format(c);
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
141 end;
ee2ebdec1fae mod_s2s_cache_failures: New module to cache failures to remote domains and control retries
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
142 });