Skip to content

Commit

Permalink
[BACK-2918] Mirror traffic writes (#272)
Browse files Browse the repository at this point in the history
* [BACK-2416] Mirror traffic writes to all of jellyfish and for data to platform-data.
  • Loading branch information
lostlevels authored Mar 18, 2024
1 parent b6c7c17 commit 0e0beb4
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 39 deletions.
2 changes: 1 addition & 1 deletion charts/tidepool/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: A Helm chart for Tidepool
name: tidepool
version: 0.15.30
version: 0.15.31
maintainers:
- name: Todd Kazakov
email: todd@tidepool.org
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ spec:
disable: true
prefixRewrite: /status
{{- if .Values.shadowing.enabled }}
{{ include "charts.routing.opts.shadowing" . }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
{{- end }}
236 changes: 210 additions & 26 deletions charts/tidepool/charts/data/templates/4-routetable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,35 @@ spec:
upstream:
name: data
{{- if .Values.shadowing.enabled }}
options:
{{ include "charts.routing.opts.shadowing" . }}
options:
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- GET
regex: "/v1/users/[^/]+/data_sources"
routeAction:
single:
upstream:
name: data
{{- if .Values.shadowing.enabled }}
options:
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- POST
- DELETE
regex: "/dataservices/v1/users/[^/]+/data_sources"
routeAction:
single:
upstream:
name: data
options:
regexRewrite:
pattern:
regex: '/dataservices/'
substitution: '/'
- matchers:
- methods:
- POST
Expand All @@ -41,8 +67,22 @@ spec:
options:
timeout: "60s"
{{- if .Values.shadowing.enabled }}
{{ include "charts.routing.opts.shadowing" . }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- POST
regex: "/dataservices/v1/users/[^/]+/data_sets"
routeAction:
single:
upstream:
name: data
options:
timeout: "60s"
regexRewrite:
pattern:
regex: '/dataservices/'
substitution: '/'
- matchers:
- methods:
- POST
Expand All @@ -63,8 +103,21 @@ spec:
name: data
{{- if .Values.shadowing.enabled }}
options:
{{ include "charts.routing.opts.shadowing" . }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- POST
regex: "/dataservices/v1/users/[^/]+/datasets"
routeAction:
single:
upstream:
name: data
options:
regexRewrite:
pattern:
regex: '/dataservices/'
substitution: '/'
- matchers:
- methods:
- POST
Expand All @@ -82,9 +135,23 @@ spec:
upstream:
name: data
{{- if .Values.shadowing.enabled }}
options:
{{ include "charts.routing.opts.shadowing" . }}
options:
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- PUT
- DELETE
regex: "/dataservices/v1/data_sources/[^/]+"
routeAction:
single:
upstream:
name: data
options:
regexRewrite:
pattern:
regex: '/dataservices/'
substitution: '/'
- matchers:
- methods:
- PUT
Expand All @@ -94,6 +161,22 @@ spec:
single:
upstream:
name: data
- matchers:
- methods:
- DELETE
regex: "/dataservices/v1/users/[^/]+/data"
routeAction:
single:
upstream:
name: data
options:
regexRewrite:
pattern:
regex: '/dataservices/'
substitution: '/'
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- DELETE
Expand All @@ -102,6 +185,10 @@ spec:
single:
upstream:
name: data
options:
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- GET
Expand All @@ -113,32 +200,141 @@ spec:
options:
timeout: "60s"
{{- if .Values.shadowing.enabled }}
{{ include "charts.routing.opts.shadowing" . }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- matchers: # matcher for upload modifications
- methods:
- DELETE
- PUT
regex: "/dataservices/v1/data_sets/[^/]+"
routeAction:
single:
upstream:
name: data
options:
timeout: "60s"
regexRewrite:
pattern:
regex: '/dataservices/'
substitution: '/'
# We do not shadow POST requests to create an Upload because the Upload id is
# random. We will rely on the changestream syncing to create the initial Upload.
# But modifications must be shadowed because a deduplicator may be ran on the
# data of the Upload (they must also still be synced in the changestreams as a
# POST may internally do an update in platform-data).
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers: # matcher for upload modifications
- methods:
- DELETE
- PUT
regex: "/v1/data_sets/[^/]+"
routeAction:
single:
upstream:
name: data
options:
timeout: "60s"
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers: # matcher for the modifications of the data belonging to a specific Upload
- methods:
- DELETE
- POST
regex: "/dataservices/v1/data_sets/[^/]+/data"
routeAction:
single:
upstream:
name: data
options:
timeout: "60s"
regexRewrite:
pattern:
regex: '/dataservices/'
substitution: '/'
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers: # matcher for the modifications of the data belonging to a specific Upload
- methods:
- DELETE
- POST
regex: "/v1/data_sets/[^/]+/data"
routeAction:
single:
upstream:
name: data
options:
timeout: "60s"
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- PUT
prefix: /v1/data_sets
- DELETE
regex: "/dataservices/v1/datasets/[^/]+"
routeAction:
single:
upstream:
name: data
options:
timeout: "60s"
regexRewrite:
pattern:
regex: '/dataservices/'
substitution: '/'
# see note in "/dataservices/v1/data_sets/[^/]+" route for why me must shadow
# non POST modifications to Uploads
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- POST
- PUT
- DELETE
prefix: /v1/datasets
regex: "/v1/datasets/[^/]+"
routeAction:
single:
upstream:
name: data
options:
timeout: "60s"
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- POST
regex: "/dataservices/v1/datasets/[^/]+/data"
routeAction:
single:
upstream:
name: data
options:
timeout: "60s"
regexRewrite:
pattern:
regex: '/dataservices/'
substitution: '/'
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- POST
regex: "/v1/datasets/[^/]+/data"
routeAction:
single:
upstream:
name: data
options:
timeout: "60s"
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- GET
Expand All @@ -151,7 +347,7 @@ spec:
extauth:
disable: true
{{- if .Values.shadowing.enabled }}
{{ include "charts.routing.opts.shadowing" . }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
Expand All @@ -177,21 +373,8 @@ spec:
prefixRewrite: /
timeout: "60s"
{{- if .Values.shadowing.enabled }}
{{ include "charts.routing.opts.shadowing" . }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
- DELETE
- PUT
- POST
prefix: /dataservices/
routeAction:
single:
upstream:
name: data
options:
prefixRewrite: /
timeout: "60s"
- matchers:
- methods:
- POST
Expand All @@ -216,6 +399,7 @@ spec:
- methods:
- GET
- POST
# not sure if these may also have a /dataservices prefix
prefix: /v1/summaries
routeAction:
single:
Expand Down
5 changes: 2 additions & 3 deletions charts/tidepool/charts/jellyfish/templates/4-routetable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ spec:
name: jellyfish
options:
timeout: "60s"
{{- if .Values.shadowing }}
shadowing:
{{- toYaml .Values.shadowing | nindent 8 }}
{{- if .Values.shadowing.enabled }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
- matchers:
- methods:
Expand Down
5 changes: 5 additions & 0 deletions charts/tidepool/charts/jellyfish/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ nodeSelector: {}
tolerations: []
# -- affinity
affinity: {}
shadowing:
enabled: false
upstreamName: "jellyfish"
namespace: "shadow"
percentage: 0
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
extauth:
disable: true
{{- if .Values.shadowing.enabled }}
{{ include "charts.routing.opts.shadowing" . }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{ else }}
prefixRewrite: /status
{{ end }}
Expand All @@ -38,6 +38,6 @@ spec:
disable: true
timeout: '3m'
{{- if .Values.shadowing.enabled }}
{{ include "charts.routing.opts.shadowing" . }}
{{ end }}
{{- include "charts.routing.opts.shadowing" . | nindent 6 }}
{{- end }}
{{- end }}
Loading

0 comments on commit 0e0beb4

Please sign in to comment.