Skip to content

[intfsorch]: Retry loopback action update failures#4766

Draft
Xichen96 wants to merge 7 commits into
sonic-net:masterfrom
Xichen96:dev/xichenlin/intfsorch-loopback-action-retry
Draft

[intfsorch]: Retry loopback action update failures#4766
Xichen96 wants to merge 7 commits into
sonic-net:masterfrom
Xichen96:dev/xichenlin/intfsorch-loopback-action-retry

Conversation

@Xichen96

@Xichen96 Xichen96 commented Jul 19, 2026

Copy link
Copy Markdown

What I did

Fixed IntfsOrch handling of loopback_action updates for an existing router interface.

Root cause

IntfsOrch::doTask() called setIntfLoopbackAction() but ignored its return value. The helper already returns false when SAI handling reports task_need_retry, but the caller continued to the final m_toSync.erase(). A transient SAI failure therefore discarded the desired action instead of retaining it for another drain.

An unsupported value such as loopback_action=invalid is different: it is permanent invalid input and must not retain the entire interface SET forever.

Fix

The new flow is:

validate loopback_action
    unsupported value
        -> log and ignore only that field
        -> continue processing other fields

    supported value
        -> set SAI_ROUTER_INTERFACE_ATTR_LOOPBACK_PACKET_ACTION
        -> retryable SAI failure: keep the original task queued
        -> success or terminal handling: consume the task normally

This preserves SWSS retry behavior without letting one invalid field block unrelated valid updates in the same APP_DB row.

Why I did it

A transient SAI resource condition must not silently lose desired state. Conversely, this update must remain usable:

SET Ethernet0
    loopback_action = invalid
    nat_zone        = 7

The invalid action is ignored, while the valid NAT-zone update still converges.

This issue is independent of the interface-removal and VRF-rehome state machines in PRs #4746 and #4764. The branch has been restacked on current master, preserving merged PR #4758 and its regression coverage.

How I verified it

Focused mock coverage in tests/mock_tests/intfsorch_ut.cpp verifies:

  • IntfsOrchRetriesLoopbackActionSetFailure
    • injects one SAI_STATUS_INSUFFICIENT_RESOURCES result for the loopback-action attribute;
    • verifies the task remains in m_toSync;
    • retries the drain;
    • verifies the task is consumed and SAI_PACKET_ACTION_DROP is applied.
  • IntfsOrchIgnoresInvalidLoopbackActionField
    • submits an invalid action with nat_zone=7;
    • verifies no loopback action is sent to SAI;
    • verifies the task is consumed;
    • verifies the NAT-zone update is applied.
  • Test executor casts are checked before use.
  • Failure injection is scoped to SAI_ROUTER_INTERFACE_ATTR_LOOPBACK_PACKET_ACTION, so another RIF attribute update cannot consume the injected failure.

Current exact-head master PR build

  • Head: a6d671f713779bb42824c99425af6d1a7f616cc6
  • Azure PR build: 1171668
  • The fresh exact-head build is in progress.
  • DCO and EasyCLA are green; all Copilot review threads are resolved.
  • No local build was used; validation is PR-build only.

Prior pre-restack evidence

  • Head 8e4b4c2df00601c5585a6a986f80d95f8ee4d418
  • Azure PR build 1171072
  • All architecture, ASAN, Docker, Trixie, Test vstest, and TestAsan vstest lanes passed.

That build is useful implementation evidence, but the current restacked head requires its own completed result.

202605 PR-build validation

Details if related

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@Xichen96

Copy link
Copy Markdown
Author

/azp run

@Xichen96
Xichen96 requested a review from Copilot July 19, 2026 16:58
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves IntfsOrch’s handling of loopback_action updates from APP_INTF_TABLE: it preserves SET tasks in the consumer queue when a retryable SAI failure occurs while updating the RIF loopback packet action, and it treats invalid loopback_action values as a logged no-op so other fields in the same SET can still be applied.

Changes:

  • Validate loopback_action early in IntfsOrch::doTask() and ignore invalid values (via getSaiLoopbackAction() warning + skipping the field).
  • If setting the RIF loopback action fails in a retryable way, keep the SET in m_toSync so it will be retried on the next drain.
  • Add mock unit tests covering (1) retry behavior on SAI set failure and (2) ignoring invalid loopback_action while still applying other fields (e.g., MTU).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
orchagent/intfsorch.cpp Adds loopback_action validation and retry behavior so requested loopback action updates aren’t lost on retryable SAI errors.
tests/mock_tests/intfsorch_ut.cpp Adds unit tests to verify retry-on-failure and ignore-invalid-field behavior for loopback_action.

Comment thread tests/mock_tests/intfsorch_ut.cpp
Comment thread tests/mock_tests/intfsorch_ut.cpp
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@Xichen96

Copy link
Copy Markdown
Author

/azp run

@Xichen96
Xichen96 requested a review from Copilot July 19, 2026 17:13
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@Xichen96

Copy link
Copy Markdown
Author

/azpw run

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1169337:

✅Stage TestAsan:

  • Job vstest: retried.

✅Stage Test:

  • Job vstest: retried.
  • Job vstest: retried.

@Xichen96 Xichen96 closed this Jul 21, 2026
@Xichen96 Xichen96 reopened this Jul 21, 2026
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

tests/mock_tests/intfsorch_ut.cpp:523

  • dynamic_cast<Consumer*> may return nullptr; this test dereferences consumer immediately, which would crash the test if the executor lookup ever changes. Add an assertion (or ASSERT_NE) before using consumer.
        auto consumer = dynamic_cast<Consumer *>(gIntfsOrch->getExecutor(APP_INTF_TABLE_NAME));
        ASSERT_NE(consumer, nullptr);

tests/mock_tests/intfsorch_ut.cpp:549

  • dynamic_cast<Consumer*> may return nullptr; this test dereferences consumer immediately, which would crash the test if the executor lookup ever changes. Add an assertion (or ASSERT_NE) before using consumer.
        };
        auto consumer = dynamic_cast<Consumer *>(gIntfsOrch->getExecutor(APP_INTF_TABLE_NAME));

Copilot AI review requested due to automatic review settings July 22, 2026 07:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread tests/mock_tests/intfsorch_ut.cpp Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b6b568a1-5d2a-4309-b1ac-ef21ca155079
Signed-off-by: Xichen96 <lukelin0907@gmail.com>
Copilot AI review requested due to automatic review settings July 22, 2026 07:26
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

tests/mock_tests/intfsorch_ut.cpp:57

  • The new _ut_set_router_interface_attribute() stub returns SAI_STATUS_SUCCESS for every non-loopback attribute, which can unintentionally mask failures and alter behavior for other tests in this suite (e.g., MAC/MTU/MPLS/NAT-zone attribute sets). Consider delegating to the original SAI set_router_interface_attribute implementation for attributes you are not explicitly testing, and only intercepting/failing the loopback-action attribute.
        return SAI_STATUS_SUCCESS;
    }

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Delegate non-loopback router-interface attribute updates to the original SAI implementation so the retry hook does not mask other unit-test behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b6b568a1-5d2a-4309-b1ac-ef21ca155079
Signed-off-by: Xichen96 <lukelin0907@gmail.com>
Copilot AI review requested due to automatic review settings July 22, 2026 08:08
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@mssonicbld

Copy link
Copy Markdown
Collaborator

This PR has backport request label(s) for branch(es): 202605, but is missing required test information. Please make sure you tick the tested branch(es) in the Tested branch section and provide test evidence (e.g., 202605: <test result>) in the Test result section as well in your PR description.

---Powered by SONiC BuildBot

@Xichen96 Xichen96 closed this Jul 22, 2026
@Xichen96 Xichen96 reopened this Jul 22, 2026
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants