Skip to content
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

Fix cets_status improper missing/unknown tables #40

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

arcusfelis
Copy link
Contributor

@arcusfelis arcusfelis commented Nov 13, 2023

This PR addresses MIM-2092.

systemInfo looks like that when testing in k8s with Helm:

kubectl exec -it mongooseim-0 -- mongooseimctl cets systemInfo
{
  "data" : {
    "cets" : {
      "systemInfo" : {
        "unavailableNodes" : [

        ],
        "remoteUnknownTables" : [
          "cets_s2s_secret",
          "cets_s2s_session",
          "cets_s2s_secret",
          "cets_s2s_session",
          "cets_s2s_secret",
          "cets_s2s_session",
          "cets_s2s_secret",
          "cets_s2s_session",
          "cets_s2s_secret",
          "cets_s2s_session",
          "cets_s2s_secret",
          "cets_bosh",
          "cets_session",
          "cets_bosh",
          ...],
                  "remoteNodesWithUnknownTables" : [
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]"
        ],
        "remoteNodesWithMissingTables" : [
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]",
          "[email protected]"
        ],
        "remoteMissingTables" : [
          "cets_bosh",
          "cets_cluster_id",
          "cets_s2s_secret"
        ],
        ...

Why? Because maps:keys/1 returns sorted keys only in tests (because atoms used in modules are sorted at the compilation step, so it is hard to find this bug in the synthetic environment. Test would also "pass" if we just try to parse status_data.txt and pass it into cets_status:format_data/1, without first tweaking the atom table like in cets_SUITE:test_data_for_duplicate_missing_table_in_status/1 function).
Once you start registering atoms dynamically, maps:keys/1 returns keys in the order atoms were registered in the atom table.

This PR ensures that keys are sorted before we do following calculations (like determining which tables are missing).

This PR also splits cets_status into gather_data and format_data, so we can more easily debug such issues.

Map keys are sorted in the atom creation order.
Which means that we should force sort them if we want
them used as ordsets.
Otherwise we would get not-proper status info
(like table duplicates in missing/unknown table lists)
@arcusfelis arcusfelis marked this pull request as ready for review November 13, 2023 14:19
Copy link

codecov bot commented Nov 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5fb3db1) 97.98% compared to head (e28f49e) 98.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #40      +/-   ##
==========================================
+ Coverage   97.98%   98.00%   +0.02%     
==========================================
  Files           9        9              
  Lines         645      652       +7     
==========================================
+ Hits          632      639       +7     
  Misses         13       13              
Files Coverage Δ
src/cets_status.erl 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@pawlooss1 pawlooss1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 😎 This was surely a tricky one. I also find split version of status/1 easier to read.

@pawlooss1 pawlooss1 merged commit 2ca3105 into main Nov 13, 2023
8 checks passed
@pawlooss1 pawlooss1 deleted the mu-fix-status-tables branch November 13, 2023 14:54
@chrzaszcz
Copy link
Member

I'm a bit late, but it looks good to me as well 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants