Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide deployment services check #714

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{/* Common initContainers-decide-wait-for-service-dependencies definition */}}
{{- define "_snippet-initContainers-decide-wait-for-service-dependencies" }}
- name: decide-wait-for-service-dependencies
image: {{ .Values.busybox.image }}
imagePullPolicy: {{ .Values.busybox.pullPolicy }}
env:
{{- include "snippet.clickhouse-env" . | nindent 4 }}
command:
- /bin/sh
- -c
- >
{{ if .Values.clickhouse.enabled }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need Clickhouse either?

until (
NODES_COUNT=$(wget -qO- \
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@{{ include "posthog.clickhouse.fullname" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local:8123" \
--post-data "SELECT count() FROM clusterAllReplicas('{{ .Values.clickhouse.cluster }}', system, one)"
)
test ! -z $NODES_COUNT && test $NODES_COUNT -eq {{ mul .Values.clickhouse.layout.shardsCount .Values.clickhouse.layout.replicasCount }}
);
do
echo "waiting for all ClickHouse nodes to be available"; sleep 1;
done
{{ end }}

{{ if .Values.redis.enabled }}
until (nc -vz "{{ include "posthog.redis.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" {{ include "posthog.redis.port" . }});
do
echo "waiting for Redis"; sleep 1;
done
{{ end }}

{{ if .Values.kafka.enabled }}

KAFKA_BROKERS="{{ include "posthog.kafka.brokers" . }}"

KAFKA_HOST=$(echo $KAFKA_BROKERS | cut -f1 -d:)
KAFKA_PORT=$(echo $KAFKA_BROKERS | cut -f2 -d:)

until (nc -vz "$KAFKA_HOST.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" $KAFKA_PORT);
do
echo "waiting for Kafka"; sleep 1;
done
{{ end }}
{{- end }}
3 changes: 1 addition & 2 deletions charts/posthog/templates/decide-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,5 @@ spec:
securityContext: {{- omit .Values.decide.securityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
initContainers:
{{- include "_snippet-initContainers-wait-for-service-dependencies" . | indent 8 }}
{{- include "_snippet-initContainers-wait-for-migrations" . | indent 8 }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decide still makes queries to PostgreSQL right? So we still need to wait for them to have been applied?

Copy link
Contributor

@tiina303 tiina303 Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I might have misunderstood earlier & mislead the ff team ... this would only apply on new container setup, not on restart? If that's true and considering we do rolling deploys this is fine to keep as is. Sorry.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if you don't include the migration check, you'll end up with a SELECT all, the, fields, including, ones, that, don't, exist, yet FROM posthog_persons which will error and if we're lucky fall back to redis, or just straight error out. Either way I don't think that's desired.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just confirmed that init containers only run when the pod is created

pods never restart, only the containers within them

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then we should investigate, why FF went down, when PG was unavailable (as this was the initial hypothesis iirc and based on what Frank said it's not the case)

{{- include "_snippet-initContainers-decide-wait-for-service-dependencies" . | indent 8 }}
{{- end }}
Loading