Skip to content

Commit

Permalink
Merge pull request #282 from openconfig/populate-applied-apply-policy
Browse files Browse the repository at this point in the history
Populate applied state for BGP
  • Loading branch information
wenovus authored Oct 2, 2023
2 parents 842aac5 + 845a887 commit 07a2d40
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit 07a2d40

Please sign in to comment.