Skip to content

Commit

Permalink
Better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuratczyk committed Feb 4, 2025
1 parent cfcbee0 commit 62829b6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
33 changes: 21 additions & 12 deletions deps/rabbit/src/rabbit_peer_discovery.erl
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,31 @@ maybe_init() ->
%% node, even if the configuration changed in between.
persistent_term:put(?PT_PEER_DISC_BACKEND, Backend),

case catch Backend:init() of
ok ->
?LOG_INFO(
"Peer discovery: backend initialisation succeeded",
try
case Backend:init() of
ok ->
?LOG_DEBUG(
"Peer discovery: backend initialisation succeeded",
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
ok;
{error, _Reason} = Error ->
?LOG_WARNING(
"Peer discovery: backend initialisation failed: ~tp.",
[Error],
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
ok
end
catch
error:undef ->
?LOG_DEBUG(
"Peer discovery: backend does not support initialisation",
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
ok;
{error, _Reason} = Error ->
_:Reason:Stacktrace ->
?LOG_ERROR(
"Peer discovery: backend initialisation failed: ~tp",
[Error],
"Peer discovery: backend initialisation failed: ~tp, ~tp",
[Reason, Stacktrace],
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
ok;
{'EXIT', {undef, _}} ->
?LOG_DEBUG(
"Peer discovery: backend does not support initialisation",
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
ok
end.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ seed_node(undefined, SeedNodeOrdinal) ->
"Perhaps you are trying to deploy RabbitMQ without a StatefulSet?",
[Nodename],
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
{error, lists:flatten(io_lib:format("my nodename (~s) doesn't seem to be have an -ID suffix "
{error, lists:flatten(io_lib:format("my nodename (~s) doesn't seem to have the expected -ID suffix "
"like StatefulSet pods should", [?MODULE:node()]))}
end;
seed_node(SeedNode, _SeedNodeOrdinal) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ returns_node_0_by_default(_Config) ->
'[email protected]' => {ok, {'[email protected]', disc} },
'[email protected]' => {ok, {'[email protected]', disc} },
'[email protected]' => {ok, {'[email protected]', disc} },
'bunny@hop' => {error, "my nodename (bunny@hop) doesn't seem to be have an -ID suffix like StatefulSet pods should"}
'bunny@hop' => {error, "my nodename (bunny@hop) doesn't seem to have the expected -ID suffix like StatefulSet pods should"}
},

[begin
Expand All @@ -60,7 +60,7 @@ ordinal_start_is_configurable(_Config) ->
'[email protected]' => {ok, {'[email protected]', disc} },
'[email protected]' => {ok, {'[email protected]', disc} },
'[email protected]' => {ok, {'[email protected]', disc} },
'bunny@hop' => {error, "my nodename (bunny@hop) doesn't seem to be have an -ID suffix like StatefulSet pods should"}
'bunny@hop' => {error, "my nodename (bunny@hop) doesn't seem to have the expected -ID suffix like StatefulSet pods should"}
},

[begin
Expand Down

0 comments on commit 62829b6

Please sign in to comment.