-
Notifications
You must be signed in to change notification settings - Fork 8
Unify cluster_id and model_id types to u32 (fixes #677) #680
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #680 +/- ##
==========================================
+ Coverage 81.59% 81.72% +0.12%
==========================================
Files 83 83
Lines 23660 23957 +297
==========================================
+ Hits 19305 19578 +273
- Misses 4355 4379 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Octoaide!
|
|
Octoaide! |
syncpark
left a comment
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.
Data migration is required for the tables and events.
|
Thanks for the catch — I analyzed the feedback and implemented the required data migrations. I’ve committed and pushed the changes; here’s what I changed and how it addresses the tables/events you called out. What I changed
Why this fixes the issue
Verification
Thanks again for the pointer — the migrations for Cluster, TimeSeries, and the listed events (HttpThreat, NetworkThreat, WindowsThreat, ExtraThreat) are implemented and included in the release migration. Let me know if you want me to add extra unit tests that simulate specific legacy data cases (e.g., particular negative cluster_id values). |
|
So, we just need to migrate the HttpThreat event data? |
|
Thanks — I reviewed the feedback and made the changes accordingly. Summary of what I analyzed and implemented:
Everything has been committed and pushed. Thanks for the pointers — this reduces unnecessary migration work and keeps the migration code focused on what actually runs in production. |
kimhanbeom
left a comment
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.
- previously suggested removing the
cluster_id/model_idi32→u32 migration because the keys are stored usingto_be_bytes, and for non-negative values the big-endian representation is identical, meaning the migration would only rewrite the same data. However, upon rechecking,ModelIndicator::Valueis serialized usingbincode::DefaultOptions(varint), so the i32→u32 change is not byte-compatible for non-zero values. As a result, an i32→u32 migration forModelIndicatoris actually required, and I’m requesting that it be added accordingly. - Could you please change the
HttpThreatmigration to avoid buffering all updates in memory. Instead, commit in batches (e.g., 100–200 records per transaction) to keep memory usage bounded and prevent OOM on large datasets.
|
I reviewed your feedback and made the requested changes — then committed and pushed them. What I found and changed
Other changes & verification
Thanks for the catch — both issues are addressed. Let me know if you want a different batch size or additional logging around the migration progress. |
kimhanbeom
left a comment
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.
@octoaide
Could you add test coverage for the new migrations (migrate_model_indicators and migrate_http_threat_events)?”
|
Could you rebase and resolve the conflicts as well please? |
11 files changed, 74 insertions(+), 60 deletions(-) Automated changes made by octoaide bot.
…t_events Add comprehensive tests for the new migration functions: - test_migrate_model_indicators: Tests migration of ModelIndicator entries from i32 model_id to u32 - test_migrate_http_threat_events: Tests migration of HttpThreat events with cluster_id from Option<usize> to Option<u32> - test_migrate_model_indicators_empty_db: Tests migration with no entries - test_migrate_http_threat_events_empty_db: Tests migration with no events
69fb30c to
c3ec1ee
Compare
|
Thanks for the feedback — I took care of both items. I rebased the branch onto main and resolved the conflicts (notably in src/migration.rs where I merged main’s migrate_network_cf with the PR’s migrate_model_indicators and migrate_http_threat_events, and in src/migration/migration_structures.rs where I reconciled imports and migration structs). All conflicts are resolved and the branch is up to date. I also added the requested test coverage and committed/pushed the changes:
While fixing tests I addressed a clippy lint (items_after_statements) by adding #[allow(clippy::items_after_statements] to the test struct definition. All tests pass (272 unit tests, 10 doc tests) and there are no clippy warnings. Everything has been committed and pushed — let me know if you want me to squash or rework any commits before merging. Thanks again for the review! |
Summary
This PR unifies the types used for cluster IDs and model IDs across the codebase by converting all occurrences to u32. Multiple files used i32, usize, String, or usize for cluster_id/model_id; this change standardizes those fields and related function signatures to use u32. This reduces type conversions and potential bugs related to mixed integer types.
What changed and why
Files modified (high level)
Verification
Related references
u32#677Closes
Closes #677