From f6922fbfe1cafb4dc90b00dd3c83ebe1e2629fd1 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 24 Sep 2023 09:03:55 -0600 Subject: [PATCH 1/9] remove liveness and readiness probes --- deployment/base/deployment.yaml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/deployment/base/deployment.yaml b/deployment/base/deployment.yaml index 09c4fb6..73d4361 100644 --- a/deployment/base/deployment.yaml +++ b/deployment/base/deployment.yaml @@ -37,17 +37,3 @@ spec: envFrom: - configMapRef: name: configmap - - readinessProbe: - httpGet: - path: /ready - port: http - initialDelaySeconds: 3 - periodSeconds: 5 - - livenessProbe: - httpGet: - path: /healthz - port: http - initialDelaySeconds: 3 - periodSeconds: 15 From 264c6e68e66e1e47cae705d1743a77ce4f898987 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 24 Sep 2023 09:05:00 -0600 Subject: [PATCH 2/9] remove unneeded in OTP-23+ SCHEDULERS env variable --- Dockerfile | 3 +-- config/vm.args.src | 2 -- deployment/base/default.env | 1 - deployment/base/deployment.yaml | 6 ------ 4 files changed, 1 insertion(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index afa2e2c..2678680 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,8 +42,7 @@ ENV COOKIE=service_discovery \ RELX_OUT_FILE_PATH=/tmp \ # service_discovery specific env variables to act as defaults DB_HOST=127.0.0.1 \ - LOGGER_LEVEL=debug \ - SCHEDULERS=1 + LOGGER_LEVEL=debug RUN rm -f /etc/apt/apt.conf.d/docker-clean diff --git a/config/vm.args.src b/config/vm.args.src index 3d00cec..44b77b6 100644 --- a/config/vm.args.src +++ b/config/vm.args.src @@ -2,8 +2,6 @@ -setcookie service_discovery_cookie -+S ${SCHEDULERS} - +C multi_time_warp +sbwt none diff --git a/deployment/base/default.env b/deployment/base/default.env index 14d92f7..ce97c1d 100644 --- a/deployment/base/default.env +++ b/deployment/base/default.env @@ -1,3 +1,2 @@ LOGGER_LEVEL=debug -SCHEDULERS=1 DB_HOST=127.0.0.1 diff --git a/deployment/base/deployment.yaml b/deployment/base/deployment.yaml index 73d4361..8e23272 100644 --- a/deployment/base/deployment.yaml +++ b/deployment/base/deployment.yaml @@ -28,12 +28,6 @@ spec: env: - name: DB_HOST value: POSTGRES_SERVICE - - name: SCHEDULERS - valueFrom: - resourceFieldRef: - containerName: service-discovery - resource: limits.cpu - divisor: 1 envFrom: - configMapRef: name: configmap From 9663217f79e9486cb670f3d1b79005dbe7609bd0 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 24 Sep 2023 13:51:57 -0600 Subject: [PATCH 3/9] add ERL_DIST_PORT to container environment so epmd isn't used --- deployment/base/deployment.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/base/deployment.yaml b/deployment/base/deployment.yaml index 8e23272..8d07133 100644 --- a/deployment/base/deployment.yaml +++ b/deployment/base/deployment.yaml @@ -28,6 +28,8 @@ spec: env: - name: DB_HOST value: POSTGRES_SERVICE + - name: ERL_DIST_PORT + value: "5555" envFrom: - configMapRef: name: configmap From f0ac7ac5085b8628195fb245eeaf1e7cee63a4ec Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 25 Sep 2023 04:09:36 -0600 Subject: [PATCH 4/9] remove unneedd +S from dev_vm.args --- config/dev_vm.args | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/dev_vm.args b/config/dev_vm.args index df27031..44b77b6 100644 --- a/config/dev_vm.args +++ b/config/dev_vm.args @@ -2,8 +2,6 @@ -setcookie service_discovery_cookie -+S 1 - +C multi_time_warp +sbwt none From c58120639175d1a9b45cb99d21fceb8e095fd8b8 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 25 Sep 2023 04:10:54 -0600 Subject: [PATCH 5/9] add an 'apt update' to the runner's apt usage --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2678680..ddd54a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,7 +49,7 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean # openssl needed by the crypto app RUN --mount=target=/var/lib/apt/lists,id=apt-lists,type=cache,sharing=locked \ --mount=type=cache,id=apt,sharing=locked,target=/var/cache/apt \ - apt install --no-install-recommends -y openssl ncurses-bin + apt update && apt install --no-install-recommends -y openssl ncurses-bin COPY --from=releaser /opt/rel . From 47ff757f343082bf56ba7aef682bb807dc5524ae Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 25 Sep 2023 04:36:22 -0600 Subject: [PATCH 6/9] cleanup whitespace in sys config files --- config/dev_sys.config | 2 -- config/sys.config.src | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/config/dev_sys.config b/config/dev_sys.config index e8f53a9..b821fcc 100644 --- a/config/dev_sys.config +++ b/config/dev_sys.config @@ -7,7 +7,6 @@ password => "password", database => "discovery"}}]}, - {service_discovery_grpc, [{server, #{grpc_opts => #{service_protos => [sdg_discovery_pb, grpcbox_health_pb, @@ -20,7 +19,6 @@ listen_opts => #{port => 8081, ip => {0,0,0,0}}}}]}, - {erldns, [%% DB Config {storage, diff --git a/config/sys.config.src b/config/sys.config.src index 5c7c296..e897ae5 100644 --- a/config/sys.config.src +++ b/config/sys.config.src @@ -6,17 +6,18 @@ user => "discovery", password => "password", database => "discovery"}}]}, + {service_discovery_grpc, [{server, #{grpc_opts => #{service_protos => [sdg_discovery_pb, - grpcbox_health_pb, - grpcbox_reflection_pb], - services => #{'sd.DiscoveryService' => sdg_service, - 'grpc.health.v1.Health' => grpcbox_health_service, - 'grpc.reflection.v1alpha.ServerReflection' => - grpcbox_reflection_service}}, + grpcbox_health_pb, + grpcbox_reflection_pb], + services => #{'sd.DiscoveryService' => sdg_service, + 'grpc.health.v1.Health' => grpcbox_health_service, + 'grpc.reflection.v1alpha.ServerReflection' => + grpcbox_reflection_service}}, - listen_opts => #{port => 8081, - ip => {0,0,0,0}}}}]}, + listen_opts => #{port => 8081, + ip => {0,0,0,0}}}}]}, {erldns, [%% DB Config @@ -43,6 +44,6 @@ ]}, {kernel, [{logger, [{handler, default, logger_std_h, - #{level => ${LOGGER_LEVEL}, + #{level => '${LOGGER_LEVEL}', formatter => {logger_formatter, #{single_line => true}}}}]}]} ]. From 00bfb0e88cbc53e736d0762a6e26717f62733cbb Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 25 Sep 2023 08:54:43 -0600 Subject: [PATCH 7/9] include uuid in http app --- apps/service_discovery_http/src/service_discovery_http.app.src | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/service_discovery_http/src/service_discovery_http.app.src b/apps/service_discovery_http/src/service_discovery_http.app.src index 1d9e523..d659b05 100644 --- a/apps/service_discovery_http/src/service_discovery_http.app.src +++ b/apps/service_discovery_http/src/service_discovery_http.app.src @@ -9,7 +9,8 @@ service_discovery, jsx, acceptor_pool, - elli + elli, + uuid ]}, {env,[]}, {modules, []}, From dcd14fc860b16f39fa1f5fb342e8862468d5fe58 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 25 Sep 2023 09:20:36 -0600 Subject: [PATCH 8/9] add back readiness probe, used for autoscaling --- deployment/base/deployment.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/deployment/base/deployment.yaml b/deployment/base/deployment.yaml index 8d07133..e3b565d 100644 --- a/deployment/base/deployment.yaml +++ b/deployment/base/deployment.yaml @@ -33,3 +33,10 @@ spec: envFrom: - configMapRef: name: configmap + + readinessProbe: + httpGet: + path: /ready + port: http + initialDelaySeconds: 1 + periodSeconds: 10 From d96fa77684c277732590eb6e4c579c884a88b39d Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 25 Sep 2023 10:47:30 -0600 Subject: [PATCH 9/9] remove unnused healthcheck and shutting down term healthz is no longer needed because the liveness check is removed. Toggling to shutting down and returning a 503 from the ready check isn't useful because the pod will already be being removed from the routes and readiness checks are infrequent -- mainly used for autoscaling. --- apps/service_discovery_http/src/sdh_handler.erl | 9 +-------- .../src/service_discovery_http_app.erl | 11 ----------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/apps/service_discovery_http/src/sdh_handler.erl b/apps/service_discovery_http/src/sdh_handler.erl index b2ff5f6..f6ff12a 100644 --- a/apps/service_discovery_http/src/sdh_handler.erl +++ b/apps/service_discovery_http/src/sdh_handler.erl @@ -12,15 +12,8 @@ handle(Req, _Args) -> handle(Req#req.method, elli_request:path(Req), Req). -handle('GET', [<<"healthz">>], _Req) -> - {ok, [], <<>>}; handle('GET', [<<"ready">>], _Req) -> - case service_discovery_http_app:is_shutting_down() of - true -> - {503, [], <<>>}; - _ -> - {ok, [], <<>>} - end; + {ok, [], <<>>}; handle('GET', [<<"services">>], Req) -> Services = service_discovery:list(), diff --git a/apps/service_discovery_http/src/service_discovery_http_app.erl b/apps/service_discovery_http/src/service_discovery_http_app.erl index 5a21a38..22e4ca5 100644 --- a/apps/service_discovery_http/src/service_discovery_http_app.erl +++ b/apps/service_discovery_http/src/service_discovery_http_app.erl @@ -3,23 +3,12 @@ -behavior(application). -export([start/2, - prep_stop/1, stop/1]). --export([is_shutting_down/0]). - --define(IS_SHUTTING_DOWN, {?MODULE, is_shutting_down}). - start(_, _) -> Env = application:get_all_env(service_discovery_http), service_discovery_http_sup:start_link(Env). -prep_stop(State) -> - persistent_term:put(?IS_SHUTTING_DOWN, true), - State. - stop(_) -> ok. -is_shutting_down() -> - persistent_term:get(?IS_SHUTTING_DOWN, false).