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

Populate applied state for BGP #282

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions bgp/gobgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ func newBgpTask(targetName, zapiURL string, listenPort uint16) *bgpTask {
appliedState := &oc.Root{}
// appliedBGP is the SoT for BGP applied configuration. It is maintained locally by the task.
appliedBGP := appliedState.GetOrCreateNetworkInstance(fakedevice.DefaultNetworkInstance).GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, fakedevice.BGPRoutingProtocol).GetOrCreateBgp()
appliedBGP.PopulateDefaults()
appliedRoutingPolicy := appliedState.GetOrCreateRoutingPolicy()
appliedRoutingPolicy.PopulateDefaults()

return &bgpTask{
targetName: targetName,
Expand Down Expand Up @@ -241,9 +239,16 @@ func (t *bgpTask) reconcile(intended *oc.Root) error {
}
default:
// Waiting for BGP to be startable.
return nil
}

return nil
err := ygot.MergeStructInto(t.appliedBGP, intendedBGP, &ygot.MergeOverwriteExistingFields{})
// TODO(wenbli): Since policy definitions is an atomic node,
// unsupported policy leaves will be merged as well. Therefore omitting
// them from the applied state until we find a way to to prune out
// unsupported paths prior to merge.
t.appliedRoutingPolicy.PolicyDefinition = nil
return err
}

// updateAppliedState is the ONLY function that's called when updating the appliedState.
Expand Down