Skip to content

Commit

Permalink
(refactor)kafka: add updated liveness checks (litmuschaos#945)
Browse files Browse the repository at this point in the history
Signed-off-by: ksatchit <[email protected]>
  • Loading branch information
Karthik Satchitanand authored and Chandan Kumar committed Nov 15, 2019
1 parent 11feb06 commit a5656b4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
kafka_instance: "{{ lookup('env','KAFKA_INSTANCE_NAME') }}"
kafka_broker: "{{ lookup('env','KAFKA_BROKER') }}"
kafka_stream: "{{ lookup('env','KAFKA_LIVENESS_STREAM') }}"
kafka_consumer_timeout: "{{ lookup('env','KAFKA_CONSUMER_TIMEOUT') }}"
kafka_service: "{{ lookup('env','KAFKA_SERVICE') }}"
kafka_port: "{{ lookup('env','KAFKA_PORT') }}"
kafka_replication_factor: "{{ lookup('env','KAFKA_REPLICATION_FACTOR') }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ spec:
- name: KAFKA_LIVENESS_STREAM
value: 'enabled'

# in milliseconds
- name: KAFKA_CONSUMER_TIMEOUT
value: '30000'

- name: TOTAL_CHAOS_DURATION
value: '30'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
kafka_kind: "{{ lookup('env','KAFKA_KIND') }}"
kafka_broker: "{{ lookup('env','KAFKA_BROKER') }}"
kafka_stream: "{{ lookup('env','KAFKA_LIVENESS_STREAM') }}"
kafka_consumer_timeout: "{{ lookup('env','KAFKA_CONSUMER_TIMEOUT') }}"
kafka_service: "{{ lookup('env','KAFKA_SERVICE') }}"
kafka_port: "{{ lookup('env','KAFKA_PORT') }}"
kafka_replication_factor: "{{ lookup('env','KAFKA_REPLICATION_FACTOR') }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ spec:
- name: KAFKA_LIVENESS_STREAM
value: 'enabled'

# in milliseconds
- name: KAFKA_CONSUMER_TIMEOUT
value: '30000'

- name: TOTAL_CHAOS_DURATION
value: '15'

Expand Down
7 changes: 5 additions & 2 deletions utils/apps/kafka/kafka_liveness.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
labels:
name: kafka-liveness
spec:
restartPolicy: Never
initContainers:
- name: kafka-topic-creator
image: litmuschaos/kafka-client:ci
Expand Down Expand Up @@ -39,11 +40,13 @@ spec:
command:
- sh
- -c
- "./producer.sh"
- "stdbuf -oL ./producer.sh"
- name: kafka-consumer
image: litmuschaos/kafka-client:ci
imagePullPolicy: Always
env:
- name: KAFKA_CONSUMER_TIMEOUT
value: "{{ kafka_consumer_timeout }}"
- name: TOPIC_NAME
value: {{ kafka_topic }}
- name: KAFKA_SERVICE
Expand All @@ -53,4 +56,4 @@ spec:
command:
- sh
- -c
- "./consumer.sh"
- "stdbuf -oL ./consumer.sh"
10 changes: 5 additions & 5 deletions utils/common/status_app_pod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

- name: Get the container status of application.
shell: >
kubectl get pod -n {{ a_ns }} -l {{ a_label }}
-o custom-columns=:..containerStatuses[].state --no-headers | grep -w "running"
kubectl get pod -n {{ a_ns }} -l {{ a_label }} --no-headers
-o jsonpath='{.items[*].status.containerStatuses[*].ready}' | tr ' ' '\n' | uniq
args:
executable: /bin/bash
register: containerStatus
until: "'running' in containerStatus.stdout"
delay: 2
retries: 150
until: "containerStatus.stdout == 'true'"
delay: '{{ delay }}'
retries: '{{ retries }}'



0 comments on commit a5656b4

Please sign in to comment.