[ENH]: Rust sysdb schema migration service#6069
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
|
|
8a541ce to
8acc93a
Compare
8acc93a to
fa5f0b2
Compare
|
Add rust-based Spanner migration service and centralize emulator config Introduces a Rust Key Changes• Added Affected Areas• rust/rust-sysdb/spanner-migrations/src This summary was automatically generated by @propel-code-bot |
fa5f0b2 to
53f2678
Compare
5316f50 to
335646c
Compare
335646c to
60603b1
Compare
| metadata: | ||
| name: rust-sysdb-migration-{{ .Values.rustSysdbMigration.image.tag }} | ||
| namespace: {{ .Values.namespace }} | ||
| annotations: |
There was a problem hiding this comment.
do you need annotations?
There was a problem hiding this comment.
keeping it because sysdb-migration service has it
There was a problem hiding this comment.
right, but why does it need it was my question
| - name: config | ||
| configMap: | ||
| name: rust-sysdb-migration-config | ||
| {{if .Values.rustSysdbMigration.tolerations}} |
There was a problem hiding this comment.
does it need tolerations and node selector?
There was a problem hiding this comment.
keeping since sysdb-migration has
There was a problem hiding this comment.
reading the description, it doesn't seem like it's applicable here. would prefer to clean this up in a future change along with sysdb-migration service.
| @@ -0,0 +1,149 @@ | |||
| //! Shared Spanner configuration types. | |||
There was a problem hiding this comment.
thoughts on moving this to the chroma-config crate instead of creating one here? In general, I was thinking of moving all the mcmr common config (like topology, regions, etc) into this crate and reuse it across services.
There was a problem hiding this comment.
Even the bootstrap function?
There was a problem hiding this comment.
why does the bootstrap function need to be shared? shouldn't only the rust-sysdb-migration perform the bootstrap? and rust-sysdb assume that all the entities exist in the db?
| image: | ||
| repository: 'rust-sysdb-migration' | ||
| tag: 'latest' | ||
| project: chroma-dev |
There was a problem hiding this comment.
why not use the rust/worker/chroma_config.yaml directly. We inject config using that and not helm values. It'd be hard to maintain this with that
There was a problem hiding this comment.
create a rust_sysdb_migration section and put it under there. Next week, I'll centralize all of this under mcmr_config section
| @@ -0,0 +1,10 @@ | |||
| [package] | |||
There was a problem hiding this comment.
see above. would prefer it to be a part of chroma-config crate
ac91667 to
2bac7cf
Compare
2bac7cf to
77190b0
Compare
77190b0 to
9f65a8f
Compare
9f65a8f to
752979b
Compare
| {{- if .Values.rustSysdbMigration.configuration }} | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: rust-sysdb-migration-config | ||
| namespace: {{ .Values.namespace }} | ||
| data: | ||
| config.yaml: | | ||
| {{ .Values.rustSysdbMigration.configuration | indent 4 }} | ||
| --- | ||
| {{- end }} | ||
| apiVersion: batch/v1 | ||
| kind: Job | ||
| metadata: | ||
| name: rust-sysdb-migration-{{ .Values.rustSysdbMigration.image.tag }} | ||
| namespace: {{ .Values.namespace }} | ||
| spec: | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: rust-sysdb-migration | ||
| spec: | ||
| restartPolicy: OnFailure | ||
| containers: | ||
| - name: rust-sysdb-migration | ||
| image: "{{ .Values.rustSysdbMigration.image.repository }}:{{ .Values.rustSysdbMigration.image.tag }}" | ||
| imagePullPolicy: IfNotPresent | ||
| env: | ||
| - name: CONFIG_PATH | ||
| value: "/config/config.yaml" | ||
| volumeMounts: | ||
| {{- if .Values.rustSysdbMigration.configuration }} | ||
| - name: config | ||
| mountPath: /config/ | ||
| {{- end }} | ||
| {{- if .Values.rustSysdbMigration.configuration }} | ||
| volumes: | ||
| - name: config | ||
| configMap: | ||
| name: rust-sysdb-migration-config | ||
| {{- end }} | ||
| {{- if .Values.rustSysdbMigration.tolerations }} | ||
| tolerations: | ||
| {{- toYaml .Values.rustSysdbMigration.tolerations | nindent 8 }} | ||
| {{- end }} | ||
| {{- if .Values.rustSysdbMigration.nodeSelector }} | ||
| nodeSelector: | ||
| {{- toYaml .Values.rustSysdbMigration.nodeSelector | nindent 8 }} | ||
| {{- end }} | ||
| --- |
There was a problem hiding this comment.
[Logic] The current Helm template creates the Job resource unconditionally, while the ConfigMap it depends on is only created if .Values.rustSysdbMigration.configuration is provided. This will cause the job to fail at runtime if no configuration is supplied, as the path specified in CONFIG_PATH will not exist.
To prevent deploying a non-functional job, it's better to make the creation of all related resources conditional on the presence of the configuration. Wrapping the entire template in a conditional block ensures that both the ConfigMap and the Job are only created when the necessary configuration is available. This also allows for the removal of redundant inner conditional checks for volumes and volume mounts.
Context for Agents
The current Helm template creates the `Job` resource unconditionally, while the `ConfigMap` it depends on is only created if `.Values.rustSysdbMigration.configuration` is provided. This will cause the job to fail at runtime if no configuration is supplied, as the path specified in `CONFIG_PATH` will not exist.
To prevent deploying a non-functional job, it's better to make the creation of all related resources conditional on the presence of the configuration. Wrapping the entire template in a conditional block ensures that both the `ConfigMap` and the `Job` are only created when the necessary configuration is available. This also allows for the removal of redundant inner conditional checks for volumes and volume mounts.
File: k8s/distributed-chroma/templates/rust-sysdb-migration.yaml
Line: 500a8304b to
76fe609
Compare
| instance: "test-instance" | ||
| database: "local-database" No newline at end of file | ||
| database: "local-database" | ||
| rust-sysdb-migration: |
There was a problem hiding this comment.
this is not needed right? Since the schema service is only in chroma2 namespace
There was a problem hiding this comment.
Not needed yes, removing.
| k8s_yaml( | ||
| local( | ||
| 'helm template --set-file rustFrontendService.configuration=' + rfe_config_file + ',rustLogService.configuration=rust/worker/chroma_config.yaml,heapTenderService.configuration=rust/worker/chroma_config.yaml,compactionService.configuration=rust/worker/chroma_config.yaml,queryService.configuration=rust/worker/chroma_config.yaml,garbageCollector.configuration=rust/worker/chroma_config.yaml,rustSysdbService.configuration=rust/worker/chroma_config.yaml --values ' + distributed_chroma_values + ' k8s/distributed-chroma' | ||
| 'helm template --set-file rustFrontendService.configuration=' + rfe_config_file + ',rustLogService.configuration=rust/worker/chroma_config.yaml,heapTenderService.configuration=rust/worker/chroma_config.yaml,compactionService.configuration=rust/worker/chroma_config.yaml,queryService.configuration=rust/worker/chroma_config.yaml,garbageCollector.configuration=rust/worker/chroma_config.yaml,rustSysdbService.configuration=rust/worker/chroma_config.yaml,rustSysdbMigration.configuration=rust/worker/chroma_config.yaml --values ' + distributed_chroma_values + ' k8s/distributed-chroma' |
There was a problem hiding this comment.
it populates
.Values.rustSysdbMigration.configuration
in rust-sysdb-migration.yaml
| use std::env; | ||
|
|
||
| const CONFIG_PATH_ENV_VAR: &str = "CONFIG_PATH"; | ||
| const DEFAULT_CONFIG_PATH: &str = "./chroma_config.yaml"; |
There was a problem hiding this comment.
If this is in chroma2 namespace then should this be chroma_config2.yaml?
| ); | ||
|
|
||
| // Set environment variable for clients | ||
| std::env::set_var("SPANNER_EMULATOR_HOST", emulator.grpc_endpoint()); |
There was a problem hiding this comment.
Is this needed? since you set the config in AdminClientConfig below, I am guessing this is not needed
76fe609 to
3a3b482
Compare
3a3b482 to
d3b78dd
Compare
| k8s_yaml( | ||
| local( | ||
| 'helm template --set-file rustFrontendService.configuration=' + rfe_config_file + ',rustLogService.configuration=rust/worker/chroma_config.yaml,heapTenderService.configuration=rust/worker/chroma_config.yaml,compactionService.configuration=rust/worker/chroma_config.yaml,queryService.configuration=rust/worker/chroma_config.yaml,garbageCollector.configuration=rust/worker/chroma_config.yaml,rustSysdbService.configuration=rust/worker/chroma_config.yaml --values ' + distributed_chroma_values + ' k8s/distributed-chroma' | ||
| 'helm template --set-file rustFrontendService.configuration=' + rfe_config_file + ',rustLogService.configuration=rust/worker/chroma_config.yaml,heapTenderService.configuration=rust/worker/chroma_config.yaml,compactionService.configuration=rust/worker/chroma_config.yaml,queryService.configuration=rust/worker/chroma_config.yaml,garbageCollector.configuration=rust/worker/chroma_config.yaml,rustSysdbService.configuration=rust/worker/chroma_config.yaml,rustSysdbMigration.configuration=rust/worker/chroma_config2.yaml --values ' + distributed_chroma_values + ' k8s/distributed-chroma' |
There was a problem hiding this comment.
nit: I think this change is not needed
There was a problem hiding this comment.
it populates
.Values.rustSysdbMigration.configuration
in rust-sysdb-migration.yaml
the service panics without this change as it can't find the configuration path
| @@ -0,0 +1,50 @@ | |||
| {{- if .Values.rustSysdbMigration.configuration }} | |||
There was a problem hiding this comment.
ok to do in another PR but would encourage you to think about how to feature flag bringing up the migration service in staging/prod since it would fail currently due to no real spanner present. One idea that I've done for the rust sysdb service is disable this entire manifest conditioned on a value that you set to true in values.dev.yaml and false in values.yaml. i.e. at the top of this file add:
{{- if .Values.rustSysdbMigration.enabled }}
and at the end of this file add:
{{-end }}
And then in values.dev.yaml set
rust-sysdb-migration:
enabled: true
In values.yaml set:
rust-sysdb-migration:
enabled: false

Description of changes
Summarize the changes made by this PR.
Test plan
How are these changes tested?
pytestfor python,yarn testfor js,cargo testfor rustMigration plan
Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?
Observability plan
What is the plan to instrument and monitor this change?
Documentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the _docs section?_