Skip to content

Commit 0db6fde

Browse files
Merge pull request #1 from dcos/master
Merge with main
2 parents 4f59756 + 7bd01ac commit 0db6fde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1726
-781
lines changed

apps/dcos_dns/include/dcos_dns.hrl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
-type upstream() :: {inet:ip4_address(), inet:port_number()}.
1010

11-
-define(LASHUP_SET_KEY(ZoneName), [navstar, dns, zones, ZoneName]).
12-
-define(RECORDS_SET_FIELD, {records, riak_dt_orswot}).
1311
-define(LASHUP_LWW_KEY(ZoneName), [dns, zones, ZoneName]).
1412
-define(RECORDS_LWW_FIELD, {records, riak_dt_lwwreg}).
1513
-define(DCOS_DIRECTORY(Prefix), <<Prefix, ".thisdcos.directory">>).

apps/dcos_dns/src/dcos_dns.app.src

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
{applications, [
88
kernel,
99
stdlib,
10+
syntax_tools,
11+
compiler,
1012
erldns,
11-
lager,
1213
inets,
1314
jsx,
1415
dns,

apps/dcos_dns/src/dcos_dns.erl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
-module(dcos_dns).
22

3+
-include_lib("kernel/include/logger.hrl").
34
-include("dcos_dns.hrl").
45
-include_lib("dns/include/dns_records.hrl").
56
-include_lib("erldns/include/erldns.hrl").
@@ -175,7 +176,7 @@ push_zone(ZoneName, Records) ->
175176
Zone = build_zone(ZoneName, RecordsByName),
176177
push_prepared_zone(Begin, ZoneName, Zone)
177178
catch error:Error ->
178-
lager:error(
179+
?LOG_ERROR(
179180
"Failed to push DNS Zone \"~s\": ~p",
180181
[ZoneName, Error]),
181182
{error, Error}
@@ -201,7 +202,7 @@ push_prepared_zone(Begin, ZoneName, Zone) ->
201202
Duration = erlang:monotonic_time() - Begin,
202203
DurationMs = erlang:convert_time_unit(Duration, native, millisecond),
203204
#zone{record_count = RecordCount} = Zone,
204-
lager:notice(
205+
?LOG_NOTICE(
205206
"DNS Zone ~s was updated (~p records, duration: ~pms)",
206207
[ZoneName0, RecordCount, DurationMs]),
207208
prometheus_summary:observe(
@@ -211,7 +212,7 @@ push_prepared_zone(Begin, ZoneName, Zone) ->
211212
dns, zone_records,
212213
[ZoneName0], RecordCount)
213214
catch error:Error ->
214-
lager:error(
215+
?LOG_ERROR(
215216
"Failed to push DNS Zone \"~s\": ~p",
216217
[ZoneName, Error]),
217218
{error, Error}

apps/dcos_dns/src/dcos_dns_config.erl

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
-module(dcos_dns_config).
1010
-author("Sargun Dhillon <sargun@mesosphere.com>").
1111

12+
-include_lib("kernel/include/logger.hrl").
1213
-include("dcos_dns.hrl").
1314

1415
%% API
@@ -20,8 +21,7 @@
2021
forward_zones/0,
2122
handler_limit/0,
2223
mesos_resolvers/0, mesos_resolvers/1,
23-
loadbalance/0,
24-
store_modes/0
24+
loadbalance/0
2525
]).
2626

2727
exhibitor_timeout() ->
@@ -59,12 +59,12 @@ bind_ips() ->
5959
V ->
6060
V
6161
end,
62-
lager:debug("found ips: ~p", [IPs0]),
62+
?LOG_DEBUG("found ips: ~p", [IPs0]),
6363
BlacklistedIPs = application:get_env(?APP, bind_ip_blacklist, []),
64-
lager:debug("blacklist ips: ~p", [BlacklistedIPs]),
64+
?LOG_DEBUG("blacklist ips: ~p", [BlacklistedIPs]),
6565
IPs1 = [ IP || IP <- IPs0, not lists:member(IP, BlacklistedIPs) ],
6666
IPs2 = lists:usort(IPs1),
67-
lager:debug("final ips: ~p", [IPs2]),
67+
?LOG_DEBUG("final ips: ~p", [IPs2]),
6868
IPs2.
6969

7070
-spec(get_ips() -> [inet:ip_address()]).
@@ -106,7 +106,3 @@ mesos_resolvers(Upstreams) ->
106106
-spec(loadbalance() -> atom()).
107107
loadbalance() ->
108108
application:get_env(?APP, loadbalance, round_robin).
109-
110-
-spec(store_modes() -> [lww | set]).
111-
store_modes() ->
112-
application:get_env(?APP, store_modes, [lww, set]).

apps/dcos_dns/src/dcos_dns_config_loader_server.erl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
%% API
2323
-export([start_link/0, start_link/1]).
2424

25+
-include_lib("kernel/include/logger.hrl").
2526
-include("dcos_dns.hrl").
2627

2728
-define(REFRESH_INTERVAL_NORMAL, 120000).
@@ -55,11 +56,11 @@ init([]) ->
5556
{ok, #state{}}.
5657

5758
handle_call(Msg, _From, State) ->
58-
lager:warning("Unhandled messages: ~p", [Msg]),
59+
?LOG_WARNING("Unhandled messages: ~p", [Msg]),
5960
{reply, ok, State}.
6061

6162
handle_cast(Msg, State) ->
62-
lager:warning("Unhandled messages: ~p", [Msg]),
63+
?LOG_WARNING("Unhandled messages: ~p", [Msg]),
6364
{noreply, State}.
6465

6566
handle_info(?REFRESH_MESSAGE, State) ->
@@ -73,7 +74,7 @@ handle_info(?REFRESH_MESSAGE, State) ->
7374
end,
7475
{noreply, State, hibernate};
7576
handle_info(Msg, State) ->
76-
lager:warning("Unhandled messages: ~p", [Msg]),
77+
?LOG_WARNING("Unhandled messages: ~p", [Msg]),
7778
{noreply, State}.
7879

7980
terminate(_Reason, _State) ->
@@ -105,7 +106,7 @@ get_masters() ->
105106
"master_list" ->
106107
get_masters_file();
107108
Source ->
108-
lager:warning("Unable to load masters (dcos_dns) from source: ~p", [Source]),
109+
?LOG_WARNING("Unable to load masters (dcos_dns) from source: ~p", [Source]),
109110
{error, bad_source}
110111
end.
111112

@@ -138,7 +139,6 @@ get_masters_exhibitor(URI) ->
138139
IPAddresses = lists:map(fun dcos_dns_app:parse_ipv4_address/1, ExhibitorHostnames),
139140
{ok, [{IPAddress, ?MESOS_DNS_PORT} || IPAddress <- IPAddresses]};
140141
Error ->
141-
lager:warning("Failed to retrieve information from exhibitor to configure dcos_dns: ~p", [Error]),
142+
?LOG_WARNING("Failed to retrieve information from exhibitor to configure dcos_dns: ~p", [Error]),
142143
{error, unavailable}
143144
end.
144-

apps/dcos_dns/src/dcos_dns_handler.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-module(dcos_dns_handler).
22

33
-include("dcos_dns.hrl").
4+
-include_lib("kernel/include/logger.hrl").
45
-include_lib("dns/include/dns_records.hrl").
56

67
-define(TIMEOUT, 5000).
@@ -30,7 +31,7 @@ start(Protocol, Request, Fun) ->
3031
case sidejob_supervisor:start_child(dcos_dns_handler_sj,
3132
?MODULE, start_link, Args) of
3233
{error, Error} ->
33-
lager:error("Unexpected error: ~p", [Error]),
34+
?LOG_ERROR("Unexpected error: ~p", [Error]),
3435
{error, Error};
3536
{ok, Pid} ->
3637
{ok, Pid}
@@ -182,7 +183,7 @@ worker(Protocol, Pid, Upstream, Request) ->
182183
{ok, Response} ->
183184
Pid ! {reply, self(), Response};
184185
{error, Reason} ->
185-
lager:warning(
186+
?LOG_WARNING(
186187
"DNS worker [~p] ~s failed with ~p",
187188
[Protocol, UpstreamAddress, Reason]),
188189
prometheus_counter:inc(

apps/dcos_dns/src/dcos_dns_key_mgr.erl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
-module(dcos_dns_key_mgr).
22
-behaviour(gen_server).
33

4+
-include_lib("kernel/include/logger.hrl").
5+
46
-ifdef(TEST).
57
-include_lib("eunit/include/eunit.hrl").
68
-endif.
@@ -136,7 +138,7 @@ create_zk_key() ->
136138
erlzk:close(Pid),
137139
Ret;
138140
{error, Reason} ->
139-
lager:error("Unable to connect to zookeeper: ~p", [Reason]),
141+
?LOG_ERROR("Unable to connect to zookeeper: ~p", [Reason]),
140142
false
141143
end.
142144

@@ -148,7 +150,7 @@ create_zk_key(Pid) ->
148150
{error, no_node} ->
149151
do_create_zk_key(Pid);
150152
{error, closed} ->
151-
lager:warning("Unable to get data from zk: closed"),
153+
?LOG_WARNING("Unable to get data from zk: closed"),
152154
false
153155
end.
154156

@@ -161,7 +163,7 @@ do_create_zk_key(Pid) ->
161163
Else ->
162164
%% This can actually just be a side effect of a concurrency violation
163165
%% Rather than trying to handle all the cases, we just try again later
164-
lager:warning("Unable to create zknode: ~p", [Else]),
166+
?LOG_WARNING("Unable to create zknode: ~p", [Else]),
165167
false
166168
end.
167169

apps/dcos_dns/src/dcos_dns_listener.erl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ init([]) ->
2727
{ok, {}, {continue, {}}}.
2828

2929
handle_continue({}, {}) ->
30-
MatchSpec =
31-
case dcos_dns_config:store_modes() of
32-
[lww | _Modes] ->
33-
ets:fun2ms(fun ({?LASHUP_LWW_KEY('_')}) -> true end);
34-
[set | _Modes] ->
35-
ets:fun2ms(fun ({?LASHUP_SET_KEY('_')}) -> true end)
36-
end,
30+
MatchSpec = ets:fun2ms(fun ({?LASHUP_LWW_KEY('_')}) -> true end),
3731
{ok, Ref} = lashup_kv:subscribe(MatchSpec),
3832
{noreply, #state{ref = Ref}}.
3933

@@ -56,9 +50,6 @@ handle_info(_Info, State) ->
5650
%%%===================================================================
5751

5852
-spec(handle_event(Key :: term(), Value :: term()) -> ok | {error, term()}).
59-
handle_event(?LASHUP_SET_KEY(ZoneName), Value) ->
60-
{?RECORDS_SET_FIELD, Records} = lists:keyfind(?RECORDS_SET_FIELD, 1, Value),
61-
dcos_dns:push_prepared_zone(ZoneName, Records);
6253
handle_event(?LASHUP_LWW_KEY(ZoneName), Value) ->
6354
{?RECORDS_LWW_FIELD, Records} = lists:keyfind(?RECORDS_LWW_FIELD, 1, Value),
6455
dcos_dns:push_prepared_zone(ZoneName, Records).

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy