Skip to content

GCU: Add path tracing support#4317

Open
bhouse-nexthop wants to merge 1 commit intosonic-net:masterfrom
bhouse-nexthop:gcu-tracing
Open

GCU: Add path tracing support#4317
bhouse-nexthop wants to merge 1 commit intosonic-net:masterfrom
bhouse-nexthop:gcu-tracing

Conversation

@bhouse-nexthop
Copy link
Contributor

@bhouse-nexthop bhouse-nexthop commented Feb 28, 2026

What I did

GCU uses a very complex set of generators and validators. When a suboptimal plan is created, it can be hard to determine why the path was generated the way it was and how best to optimize the generators.

This patch adds the ability to pass an IO object to all attempted paths with annotations such as valid, invalid, recurse_reject (source and target were already attempted), and path_issue (patch was good, but a generator further down the hierarchy failed). It will also list the generator used for each patch, and if invalid it will list the validator which failed it with a possibly extended error message.

For callers to config replace or config apply-patch a new command line option of --path-trace which takes a filename to dump the json output.

This patch also increases the diff output shown during test run failures to make it easier to debug issues based on logging generated via CI/CD.

Fixes sonic-net/sonic-buildimage#25748

How I did it

Modified various classes and functions to pass around objects and metadata needed to generate the trace.

How to verify it

Run config replace or config apply-patch with the --path-trace argument.

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

Example output showing a suboptimal plan:
trace.json

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bhouse-nexthop
Copy link
Contributor Author

unit tests are failing due to the spelling fix PRs that merged before this. I'll rebase once someone fixes the failures.

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bhouse-nexthop
Copy link
Contributor Author

@qiluo-msft @lguohan I have a bunch of GCU fixes coming, but they're gated by this PR due to code conflicts. Can you please review and hopefully merge. This has been crucial in diagnosing GCU-related issues. There should be zero additional overhead (whether CPU or memory) with the tracing support if tracing hasn't been enabled.

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

GCU uses a very complex set of generators and validators.  When a suboptimal
plan is created, it can be hard to determine why the path was generated the
way it was and how best to optimize the generators.

This patch adds the ability to pass an IO object to all attempted paths
with annotations such as `valid`, `invalid`, `recurse_reject` (source and
target were already attempted), and `path_issue` (patch was good, but a
generator further down the hierarchy failed).  It will also list the
generator used for each patch, and if `invalid` it will list the validator
which failed it with a possibly extended error message.

For callers to `config replace` or `config apply-patch` a new command line
option of `--path-trace` which takes a filename to dump the json output.

This patch also increases the diff output shown during test run failures
to make it easier to debug issues based on logging generated via CI/CD.

Signed-off-by: Brad House <bhouse@nexthop.ai>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: GCU: Need a better way to evaluate generated plans

2 participants