-
Notifications
You must be signed in to change notification settings - Fork 9
feat(identity): sync CLI — copy the persons log into ClickHouse (metrics person_id, iteration 1)
#2065
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
Merged
Merged
feat(identity): sync CLI — copy the persons log into ClickHouse (metrics person_id, iteration 1)
#2065
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
src/backend/services/identity-resolution/helm/templates/sync-cronjob.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| {{- if .Values.sync.enabled }} | ||
| # Scheduled persons-sync: copies the MariaDB `persons` observation log into | ||
| # ClickHouse `identity.identity_persons` — the table the metrics dbt builds | ||
| # resolve email → person_id against. Scheduled AFTER the seed CronJob by | ||
| # default: the seed rewrites the log, the sync publishes it (each run is a | ||
| # full snapshot + atomic swap, so ordering is a freshness concern only, | ||
| # never a correctness one). | ||
| # | ||
| # Same image/config/secret wiring as the seed CronJob; the `sync` | ||
| # subcommand runs one copy and exits (exit codes: 0 ok / 1 failed / | ||
| # 2 lock busy / 3 empty-log guard — override the guard with a manual | ||
| # `--force` Job). Runs serialize on a global MariaDB advisory lock, so | ||
| # `concurrencyPolicy: Forbid` is belt-and-braces for cron-vs-cron only. | ||
| # | ||
| # Manual run: | ||
| # kubectl create job --from=cronjob/{{ include "insight-identity-resolution.fullname" . }}-sync sync-manual-$USER | ||
| apiVersion: batch/v1 | ||
| kind: CronJob | ||
| metadata: | ||
| name: {{ include "insight-identity-resolution.fullname" . }}-sync | ||
| labels: | ||
| {{- include "insight-identity-resolution.labels" . | nindent 4 }} | ||
| app.kubernetes.io/component: persons-sync | ||
| spec: | ||
| schedule: {{ .Values.sync.schedule | quote }} | ||
| concurrencyPolicy: {{ .Values.sync.concurrencyPolicy }} | ||
| successfulJobsHistoryLimit: {{ .Values.sync.successfulJobsHistoryLimit }} | ||
| failedJobsHistoryLimit: {{ .Values.sync.failedJobsHistoryLimit }} | ||
| jobTemplate: | ||
| spec: | ||
| # Retries for transient connect blips; the advisory lock + the | ||
| # snapshot-swap idempotency make a repeated run safe. The deadline caps | ||
| # a wedged pod well past the in-binary 5-minute sync timeout. | ||
| backoffLimit: {{ .Values.sync.backoffLimit }} | ||
| activeDeadlineSeconds: {{ .Values.sync.activeDeadlineSeconds }} | ||
| template: | ||
| metadata: | ||
| # NOT the shared selectorLabels: the Service selects on | ||
| # name+instance alone, and a sync pod carrying them would enter the | ||
| # Service's endpoints (it listens on nothing). | ||
| labels: | ||
| app.kubernetes.io/name: identity-resolution-sync | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| app.kubernetes.io/component: persons-sync | ||
| spec: | ||
| {{- with .Values.global }} | ||
| {{- with .imagePullSecrets }} | ||
| imagePullSecrets: | ||
| {{- toYaml . | nindent 12 }} | ||
| {{- end }} | ||
| {{- end }} | ||
| enableServiceLinks: false | ||
| restartPolicy: Never | ||
| securityContext: | ||
| runAsNonRoot: true | ||
| runAsUser: 1000 | ||
| fsGroup: 1000 | ||
| containers: | ||
| - name: persons-sync | ||
| image: "{{ required "image.repository is required" .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
| imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
| command: ["/app/identity-resolution"] | ||
| args: ["-c", "/app/config/insight.yaml", "sync"] | ||
| volumeMounts: | ||
| - name: identity-resolution-config | ||
| mountPath: /app/config/insight.yaml | ||
| subPath: insight.yaml | ||
| readOnly: true | ||
| envFrom: | ||
| # Same Secret as the deployment: database_url, clickhouse_*, | ||
| # tenant_default_id — everything the sync needs. The | ||
| # ClickHouse user must be able to CREATE/INSERT/EXCHANGE in | ||
| # the `identity` database (the snapshot-swap write path). | ||
| - secretRef: | ||
| name: {{ required "existingSecret is required (umbrella provides `insight-identity-resolution-config`; standalone installs supply their own)" .Values.existingSecret | quote }} | ||
| {{- with .Values.sync.tenantDefaultId }} | ||
| env: | ||
| # Explicit tenant for the JOURNAL row (the copy itself is | ||
| # tenant-agnostic). Same override semantics as the seed's. | ||
| - name: APP__gears__identity-resolution__config__tenant_default_id | ||
| value: {{ . | quote }} | ||
| {{- end }} | ||
| securityContext: | ||
| allowPrivilegeEscalation: false | ||
| resources: | ||
| {{- toYaml .Values.sync.resources | nindent 16 }} | ||
| volumes: | ||
| - name: identity-resolution-config | ||
| configMap: | ||
| name: {{ include "insight-identity-resolution.fullname" . }}-gears-config | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The insight-gitops should be modified for customer cluster or this value should be set from values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already covered on the gitops path:
deploy/gitops/scripts/compose-app-secrets.sh(the "First-admin bootstrap inputs" block) writesAPP__gears__identity-resolution__config__tenant_default_idintoinsight-identity-resolution-configwheneverTENANT_DEFAULTis configured for the cluster — and the sync CronJob consumes that same Secret viaenvFrom, so customer clusters need no gitops change.sync.tenantDefaultIdhere is the standalone-install override, mirroring the seed's pattern from #1690. And the tenant is only journal-row scoping for the sync — a cluster without it still runs via the sole-tenant inference fallback.