Skip to content

fix: roll back failed SM policy creation - #88

Open
mrweixd wants to merge 3 commits into
free5gc:mainfrom
mrweixd:fix/sm-policy-create-cleanup
Open

mrweixd wants to merge 3 commits into
free5gc:mainfrom
mrweixd:fix/sm-policy-create-cleanup

Conversation

@mrweixd

@mrweixd mrweixd commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Fix failed SM policy creation leaving policy contexts behind when rating-group allocation fails for default, flow-rule, or traffic-influence PCC rules.
  • Roll back charging data and rating groups acquired by the failed request while preserving existing sessions.
  • Restore the previous policy when replacement fails, and clean up old rating groups when replacement succeeds.
  • Return HTTP 500 with INSUFFICIENT_RESOURCES for rating-group allocation failures.
  • Add regression tests covering allocation failures, policy replacement, and MongoDB deletion failures.

Fixes free5gc/free5gc#1202
Fixes free5gc/free5gc#1204
Fixes free5gc/free5gc#1203

Note

  • Validation uses the MongoDB driver's mock responses and a local HTTP/2 UDR stub:
    • go test -race ./... passed for the implementation.
    • go test -race ./internal/sbi/processor passed after adding deletion-failure tests.
    • golangci-lint v2.11.4 passed with 0 issues.
  • When MongoDB deletion fails, the error is logged and the corresponding rating group remains reserved to prevent unsafe ID reuse.
  • Standards references:
    • 3GPP TS 29.512 V17.11.0, clauses 4.2.2.2, 5.3.2.3.1 and 5.7.
    • 3GPP TS 29.500 V17.11.0, clause 5.2.7.2.

@ki225 ki225 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mrweixd LGTM. Could you please rebase this branch first? Thx

Handle rating-group allocation failures for free5gc/free5gc issues #1202, #1204 and #1203. Track request-owned resources, restore previous policy state on failure, and clean up replaced policy groups on success.

Add regression coverage for failed creation and successful policy replacement.
Cover partial rollback cleanup failure, failed replacement rollback, and commit cleanup failures with and without new charging groups. Verify policy ownership and allocator reservations.
@mrweixd
mrweixd force-pushed the fix/sm-policy-create-cleanup branch from dc0580b to 785337c Compare October 28, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants