Commit b2a1330
authored
fix (sync): fix sync reconciliation for remote queries paths (#882)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR fixes sync reconciliation so that the correct remote queries
path (read from the cluster's snapshot `helix.toml`) is used instead of
always falling back to the local project path. It refactors several sync
functions to accept explicit `current_queries_dir` /
`target_queries_dir` arguments, adds enterprise-cluster parity to all
sync flows, extracts a reusable `build_standard_deploy_payload` helper
(now including `runtime_config`), and adds meaningful unit-test coverage
for the new merge/extraction helpers.
**Key issues:**
- `pull_remote_snapshot_into_local` handles directory migration when the
remote queries path differs from the local one, but the migration code
path deletes files from `current_queries_dir` **before** writing to
`target_queries_dir`, risking data loss if a write fails mid-way (the
same-dir code path retains the safe write-then-delete order from the
original implementation).
- `insert_unique_cloud_instance_name` and
`insert_unique_enterprise_instance_name` introduce redundant
double-clones that can be simplified.
<details><summary><h3>Sequence Diagram</h3></summary>
```mermaid
sequenceDiagram
participant CLI
participant Cloud as Helix Cloud API
participant FS as Local Filesystem
Note over CLI: sync (project flow)
CLI->>Cloud: fetch_project_clusters()
CLI->>Cloud: fetch_standard/enterprise_cluster_snapshot_config(selected_cluster)
Cloud-->>CLI: HelixConfig (remote helix.toml)
CLI->>CLI: resolve_selected_project_queries_path(snapshot)
alt Standard cluster
CLI->>Cloud: fetch_sync_response(cluster_id)
Cloud-->>CLI: SyncResponse (.hx files + helix_toml)
CLI->>CLI: compare_manifests(local, remote)
alt Pull
CLI->>FS: pull_remote_snapshot_into_local(current_dir, target_dir, ...)
CLI->>FS: update_project_queries_path_in_helix_toml()
else Push
CLI->>Cloud: push_local_snapshot_to_cluster()
end
else Enterprise cluster
CLI->>Cloud: fetch_enterprise_sync_response(cluster_id)
Cloud-->>CLI: EnterpriseSyncResponse (.rs files + helix_toml)
CLI->>FS: write .rs files to target_queries_dir
CLI->>FS: update_project_queries_path_in_helix_toml()
end
CLI->>Cloud: fetch_project_clusters_for_[standard|enterprise]_cluster()
Cloud-->>CLI: CliProjectClusters
CLI->>Cloud: fetch_[standard|enterprise]_cluster_snapshot_configs(all clusters)
Cloud-->>CLI: snapshot HelixConfigs
CLI->>FS: reconcile_project_config_from_cloud() → write helix.toml
```
</details>
<sub>Last reviewed commit: c6b0d52</sub>
> Greptile also left **1 inline comment** on this PR.
<!-- /greptile_comment -->File tree
6 files changed
+1112
-288
lines changed- helix-cli/src
- commands
- integrations
- hql-tests/tests/user_test_14
6 files changed
+1112
-288
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
45 | 73 | | |
46 | 74 | | |
47 | 75 | | |
| |||
58 | 86 | | |
59 | 87 | | |
60 | 88 | | |
61 | | - | |
| 89 | + | |
62 | 90 | | |
63 | 91 | | |
64 | 92 | | |
| |||
140 | 168 | | |
141 | 169 | | |
142 | 170 | | |
143 | | - | |
| 171 | + | |
144 | 172 | | |
145 | 173 | | |
146 | 174 | | |
| |||
241 | 269 | | |
242 | 270 | | |
243 | 271 | | |
244 | | - | |
245 | | - | |
| 272 | + | |
| 273 | + | |
246 | 274 | | |
247 | 275 | | |
248 | 276 | | |
249 | 277 | | |
250 | 278 | | |
251 | 279 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
260 | 288 | | |
261 | 289 | | |
262 | 290 | | |
| |||
525 | 553 | | |
526 | 554 | | |
527 | 555 | | |
528 | | - | |
| 556 | + | |
529 | 557 | | |
530 | 558 | | |
531 | 559 | | |
| |||
540 | 568 | | |
541 | 569 | | |
542 | 570 | | |
543 | | - | |
544 | | - | |
| 571 | + | |
545 | 572 | | |
546 | 573 | | |
547 | 574 | | |
| |||
682 | 709 | | |
683 | 710 | | |
684 | 711 | | |
685 | | - | |
| 712 | + | |
686 | 713 | | |
687 | 714 | | |
688 | 715 | | |
689 | 716 | | |
690 | 717 | | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
0 commit comments