Skip to content

Commit

Permalink
pre_stop_hook templating
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiitk committed Feb 22, 2024
1 parent abf8952 commit 498c524
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 19 deletions.
53 changes: 39 additions & 14 deletions kubernetes-manifests/prestop-hook.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
<%def name="lifecycle()">
% if pre_stop_hook:
preStop:
exec:
command:
- "grpcurl"
- "-plaintext"
- "-import-path"
- "/"
- "-proto"
- "/src/proto/grpc/testing/test.proto"
- "localhost:8000"
- "grpc.testing.HookService/Hook"
% endif
<%def name="lifecycle()" filter="trim">
## containers:
lifecycle:
preStop:
exec:
command:
- "grpcurl"
- "-plaintext"
- "-import-path"
- "/"
- "-proto"
- "/src/proto/grpc/testing/test.proto"
- "localhost:8000"
- "grpc.testing.HookService/Hook"
</%def>
<%def name="container()" filter="trim">
## containers:
- name: hook
image: gcr.io/grpc-testing/rbellevi/pre-stop-hook-test:6
lifecycle:
preStop:
exec:
command: ["/prestop.sh"]
volumeMounts:
${volume_mount()}
</%def>
<%def name="volume_mount()" filter="trim">
## containers:
## volumeMounts:
- name: prestop-hook-volume
## TODO(sergiitk): update to /tmp/prestop-hook
mountPath: /hook
</%def>
<%def name="volume()" filter="trim">
## volumes:
- name: prestop-hook-volume
emptyDir:
medium: Memory
</%def>
8 changes: 5 additions & 3 deletions kubernetes-manifests/server.deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%namespace name="prestop_hook" file="prestop-hook.yaml" import="pre_stop_hook" />
<%namespace name="prestop_hook" file="prestop-hook.yaml" />
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -39,6 +39,7 @@ spec:
## Extend the number of probes well beyond the duration of the test
## driver waiting for the container to start.
failureThreshold: 1000
${prestop_hook.lifecycle() if pre_stop_hook else ''}
args:
- "--port=${test_port}"
% if enable_csm_observability:
Expand Down Expand Up @@ -77,15 +78,15 @@ spec:
- mountPath: /tmp/grpc-xds/
name: grpc-td-conf
readOnly: true
${prestop_hook.volume_mount() if pre_stop_hook else ''}
resources:
limits:
cpu: 800m
memory: 512Mi
requests:
cpu: 100m
memory: 512Mi
lifecycle:
${prestop_hook.lifecycle()}
${prestop_hook.container() if pre_stop_hook else ''}
initContainers:
- name: grpc-td-init
image: ${td_bootstrap_image}
Expand Down Expand Up @@ -118,4 +119,5 @@ spec:
- name: grpc-td-conf
emptyDir:
medium: Memory
${prestop_hook.volume() if pre_stop_hook else ''}
...
6 changes: 4 additions & 2 deletions tests/gamma/affinity_session_drain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
RpcTypeUnaryCall = xds_url_map_testcase.RpcTypeUnaryCall

# Constants
REPLICA_COUNT = 3
# TODO(sergiitk): set to 3
REPLICA_COUNT = 1
# We never actually hit this timeout under normal circumstances, so this large
# value is acceptable.
TERMINATION_GRACE_PERIOD = datetime.timedelta(minutes=2)
# TODO(sergiitk): reset to 10
TERMINATION_GRACE_PERIOD = datetime.timedelta(minutes=1)
DRAINING_TIMEOUT = datetime.timedelta(minutes=10)


Expand Down

0 comments on commit 498c524

Please sign in to comment.