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(orc8r): add reindexing of gateway subscriber state to subscriberdb indexer #13041

Merged
merged 2 commits into from Jun 28, 2022

Conversation

alexzurbonsen
Copy link
Contributor

@alexzurbonsen alexzurbonsen commented Jun 21, 2022

Summary

This PR adds capabilities to subscriberdb indexer to write state of type gateway_subscriber_state into the gateway_subscriber_states table created in #12949. The logic implemented there splits up the state into its entries and renews the entire state with every indexing run (old entries are deleted and new entries are written into gateway_subscriber_states table).

The second commit adds annotations such that the indexer is triggered for this type as well in docker and k8s deployments.

This is the follow up PR to #12949 and implements step 3 of the plan outlined in #8621 - comment.

Test Plan

  • Unit tests of subscriberdb: indexer and subscriber storage
  • manual test of orc8r deployed locally with docker compose

Manual testing is done with grpcurl and the following commands.

  1. Send gateway state with three IMSIs.
grpcurl -vv \
    -insecure \
    -key /tmp/magma_protos/gateway.key \
    -cert /tmp/magma_protos/gateway.crt \
    -authority state-controller.magma.test \
    -protoset /tmp/magma_protos/out.protoset \
    -d '{"states": [{"type": "gateway_subscriber_state",
"deviceID": "d02a138b-04d3-4710-95aa-d810efc61fc1", "value":"eyJzdWJzY3JpYmVycyI6eyJJTVNJMDAyMDIwMDAwMDAwMTIzIjp7Im1hZ21hLmlwdjQiOlt7ImFjdGl2ZV9kdXJhdGlvbl9zZWMiOjAsImFjdGl2ZV9wb2xpY3lfcnVsZXMiOltdLCJhcG4iOiJtYWdtYS5pcHY0IiwiaXB2NCI6IjE5Mi4xNjguMTI4LjEyIiwibGlmZWN5Y2xlX3N0YXRlIjoiU0VTU0lPTl9SRUxFQVNFRCIsIm1zaXNkbiI6IiIsInNlc3Npb25faWQiOiJJTVNJMDAyMDIwMDAwMDAwMTIzLTEyMzQiLCJzZXNzaW9uX3N0YXJ0X3RpbWUiOjE2NTM0ODQxNDR9XX0sIklNU0kwMDIwMjAwMDAwMDA0NTYiOnsibWFnbWEuaXB2NCI6W3siYWN0aXZlX2R1cmF0aW9uX3NlYyI6MSwiYWN0aXZlX3BvbGljeV9ydWxlcyI6W10sImFwbiI6Im1hZ21hLmlwdjQiLCJpcHY0IjoiMTkyLjE2OC4xMjguMTIiLCJsaWZlY3ljbGVfc3RhdGUiOiJTRVNTSU9OX1JFTEVBU0VEIiwibXNpc2RuIjoiIiwic2Vzc2lvbl9pZCI6IklNU0kwMDIwMjAwMDAwMDA0NTYtMTIzNCIsInNlc3Npb25fc3RhcnRfdGltZSI6MTY1MzQ4NDE0NH1dfSwiSU1TSTAwMjAyMDAwMDAwMDc4OSI6eyJtYWdtYS5pcHY0IjpbeyJhY3RpdmVfZHVyYXRpb25fc2VjIjoyLCJhY3RpdmVfcG9saWN5X3J1bGVzIjpbXSwiYXBuIjoibWFnbWEuaXB2NCIsImlwdjQiOiIxOTIuMTY4LjEyOC4xMiIsImxpZmVjeWNsZV9zdGF0ZSI6IlNFU1NJT05fUkVMRUFTRUQiLCJtc2lzZG4iOiIiLCJzZXNzaW9uX2lkIjoiSU1TSTAwMjAyMDAwMDAwMDc4OS0xMjM0Iiwic2Vzc2lvbl9zdGFydF90aW1lIjoxNjUzNDg0MTQ0fV19fX0=", "version":"0"}]}' \
    localhost:7443 \
    magma.orc8r.StateService/ReportStates

The state is written to states table and the indexer writes its entries to the gateway_subscriber_states table.

Screenshot 2022-06-21 at 20 11 09

  1. After sending an empty state
grpcurl -vv \
    -insecure \
    -key /tmp/magma_protos/gateway.key \
    -cert /tmp/magma_protos/gateway.crt \
    -authority state-controller.magma.test \
    -protoset /tmp/magma_protos/out.protoset \
    -d '{"states": [{"type": "gateway_subscriber_state",
"deviceID": "d02a138b-04d3-4710-95aa-d810efc61fc1", "value":"eyJzdWJzY3JpYmVycyI6e319", "version":"0"}]}' \
    localhost:7443 \
    magma.orc8r.StateService/ReportStates

the gateway_subscriber_states table is indeed empty.

  1. Sending mixed states like
'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MjM0Iiwic2Vzc2lvbl9zdGFydF90aW1lIjoxNjUzNDg0MTQ0fV19fX0=", "version":"0"},
{"type": "mobilityd_ipdesc_record",
"deviceID": "IMSI001010000333333.magma.ipv4,ipv4",
"value":"eyJpcCI6IHsiYWRkcmVzcyI6ICJ3S2lBSVE9PSJ9LCAiaXBCbG9jayI6IHsibmV0QWRkcmVzcyI6ICJ3S2lBQUE9PSIsICJwcmVmaXhMZW4iOiAyNH0sICJzdGF0ZSI6ICJBTExPQ0FURUQiLCAic2lkIjogeyJpZCI6ICJJTVNJMDAxMDEwMDAwMzMzMzMzLm1hZ21hLmlwdjQsaXB2NCJ9LCAidHlwZSI6ICJJUF9QT09MIn0=", "version":"0"}
]}'

also works. The respective states get written into the gateway_subscriber_states table as above and subscriberdb_ip_to_imsi.

Additional Information

  • Done in pairing with @sebathomas.
  • This change is backwards-breaking

@pull-request-size pull-request-size bot added the size/L Denotes a Pull Request that changes 100-499 lines. label Jun 21, 2022
@github-actions
Copy link
Contributor

Thanks for opening a PR! 💯

A couple initial guidelines

Howto

  • Reviews. The "Reviewers" listed for this PR are the Magma maintainers who will shepherd it.
  • Checks. All required CI checks must pass before merge.
  • Merge. Once approved and passing CI checks, use the ready2merge label to indicate the maintainers can merge your PR.

More info

Please take a moment to read through the Magma project's

If this is your first Magma PR, also consider reading

@github-actions github-actions bot added component: cwf component: feg FEG-gateway related issues component: orc8r Orchestrator-related issue labels Jun 21, 2022
feg/cloud/go/go.mod Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Jun 21, 2022

cloud-workflow

990 tests   990 ✔️  2m 13s ⏱️
355 suites      0 💤
    7 files        0

Results for commit 793ba11.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 21, 2022

feg-workflow

    2 files  203 suites   39s ⏱️
374 tests 374 ✔️ 0 💤 0
388 runs  388 ✔️ 0 💤 0

Results for commit 793ba11.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 21, 2022

dp-workflow

18 tests   18 ✔️  4m 17s ⏱️
  2 suites    0 💤
  2 files      0

Results for commit 793ba11.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 21, 2022

agw-workflow

580 tests   576 ✔️  3m 49s ⏱️
    2 suites      4 💤
    2 files        0

Results for commit 793ba11.

♻️ This comment has been updated with latest results.

@alexzurbonsen alexzurbonsen force-pushed the subscriberdb/reindex_state branch 2 times, most recently from 42011d3 to 7f6a6a0 Compare June 21, 2022 14:30
@github-actions github-actions bot removed component: feg FEG-gateway related issues component: cwf labels Jun 21, 2022
@alexzurbonsen alexzurbonsen force-pushed the subscriberdb/reindex_state branch 2 times, most recently from 0c7de2a to 92a7860 Compare June 23, 2022 18:21
@@ -111,7 +111,7 @@ subscriberdb:
orc8r.io/state_indexer: "true"
orc8r.io/swagger_spec: "true"
annotations:
orc8r.io/state_indexer_types: "mobilityd_ipdesc_record"
orc8r.io/state_indexer_types: "mobilityd_ipdesc_record,gateway_subscriber_state"
Copy link
Contributor

Choose a reason for hiding this comment

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

[yamllint] reported by reviewdog 🐶
[error] wrong indentation: expected 5 but found 6 (indentation)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure about that. I didn't touch the indentation and the other lines also have 6...

@alexzurbonsen alexzurbonsen changed the title [WIP] Subscriberdb/reindex state fix(orc8r): modify subscriberdb indexer to reindex gateway subscriber state Jun 27, 2022
@alexzurbonsen alexzurbonsen changed the title fix(orc8r): modify subscriberdb indexer to reindex gateway subscriber state fix(orc8r): add reindexing of gateway subscriber state to subscriberdb indexer Jun 27, 2022
@alexzurbonsen alexzurbonsen marked this pull request as ready for review June 27, 2022 08:48
@alexzurbonsen alexzurbonsen requested review from a team June 27, 2022 08:48
@alexzurbonsen alexzurbonsen force-pushed the subscriberdb/reindex_state branch 2 times, most recently from ced38ec to 8e71e46 Compare June 27, 2022 09:05
Modifies the existing indexer servicer by adding the subscriber
storage table to it and functionality to take states of type
"gateway_subscriber_state" (sent by sessiond) and write an entry
for each subscriber into the subscriber storage.

For that we modify the existing indexImpl function to distinguish
between the two possible types ("mobilityd_ipdesc_record" and
"gateway_subscriber_state").

Tests for the new indexer functionality are added.
A custom serde type is registered for the gateway subscriber state
and implemented in storage/subscriber_state.go.

The existing interface of the subscriber storage is changed to use
this new type (GatewaySubscriberState).

Signed-off-by: Alexander zur Bonsen <alexander.zur.bonsen@tngtech.com>
To trigger the indexer also for the type gateway_subscriber_state
the annotation is added to the service registry config of
subscriberdb. k8s config is added in a separated PR.

Signed-off-by: Alexander zur Bonsen <alexander.zur.bonsen@tngtech.com>
@sebathomas sebathomas removed the request for review from a team June 27, 2022 14:39
@sebathomas sebathomas merged commit e62d6a0 into magma:master Jun 28, 2022
emakeev pushed a commit to emakeev/magma that referenced this pull request Aug 5, 2022
…b indexer (magma#13041)

* Add reindexing of gateway_subscriber_state to subscriberdb indexer

Modifies the existing indexer servicer by adding the subscriber
storage table to it and functionality to take states of type
"gateway_subscriber_state" (sent by sessiond) and write an entry
for each subscriber into the subscriber storage.

For that we modify the existing indexImpl function to distinguish
between the two possible types ("mobilityd_ipdesc_record" and
"gateway_subscriber_state").

Tests for the new indexer functionality are added.
A custom serde type is registered for the gateway subscriber state
and implemented in storage/subscriber_state.go.

The existing interface of the subscriber storage is changed to use
this new type (GatewaySubscriberState).

Signed-off-by: Alexander zur Bonsen <alexander.zur.bonsen@tngtech.com>

* Add "gateway_subscriber_state" annotation

To trigger the indexer also for the type gateway_subscriber_state
the annotation is added to the service registry config of
subscriberdb. k8s config is added in a separated PR.

Signed-off-by: Alexander zur Bonsen <alexander.zur.bonsen@tngtech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: orc8r Orchestrator-related issue size/L Denotes a Pull Request that changes 100-499 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants