From 7e0e5319d25cb9ff0444eb133f261829321aa0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Mon, 2 Sep 2024 10:33:14 +0200 Subject: [PATCH] [scd] Store past OVNs on operational intents upsert --- pkg/scd/operational_intents_handler.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/scd/operational_intents_handler.go b/pkg/scd/operational_intents_handler.go index a1707f625..86b8732e5 100644 --- a/pkg/scd/operational_intents_handler.go +++ b/pkg/scd/operational_intents_handler.go @@ -391,7 +391,7 @@ type validOIRParams struct { key map[scdmodels.OVN]bool } -func (vp *validOIRParams) toOIR(manager dssmodels.Manager, attachedSub *scdmodels.Subscription, version scdmodels.VersionNumber) *scdmodels.OperationalIntent { +func (vp *validOIRParams) toOIR(manager dssmodels.Manager, attachedSub *scdmodels.Subscription, version scdmodels.VersionNumber, pastOVNs []scdmodels.OVN) *scdmodels.OperationalIntent { // For OIR's in the accepted state, we may not have a attachedSub available, // in such cases the attachedSub ID on scdmodels.OperationalIntent will be nil // and will be replaced with the 'NullV4UUID' when sent over to a client. @@ -401,9 +401,11 @@ func (vp *validOIRParams) toOIR(manager dssmodels.Manager, attachedSub *scdmodel subID = &attachedSub.ID } return &scdmodels.OperationalIntent{ - ID: vp.id, - Manager: manager, - Version: version, + ID: vp.id, + Manager: manager, + Version: version, + OVN: "", // TODO dss#1078: this field must be populated to support USSs setting OVNs in advance + PastOVNs: pastOVNs, StartTime: vp.uExtent.StartTime, EndTime: vp.uExtent.EndTime, @@ -829,10 +831,15 @@ func (a *Server) upsertOperationalIntentReference(ctx context.Context, authorize return stacktrace.PropagateWithCode(err, stacktrace.GetCode(err), "Request validation failed") } - version := scdmodels.VersionNumber(1) - var previousSub *scdmodels.Subscription + var ( + version = scdmodels.VersionNumber(1) + pastOVNs = make([]scdmodels.OVN, 0) + previousSub *scdmodels.Subscription + ) if old != nil { version = old.Version + 1 + pastOVNs = append(old.PastOVNs, validParams.ovn) + // Fetch the previous OIR's subscription if it exists if old.SubscriptionID != nil { previousSub, err = r.GetSubscription(ctx, *old.SubscriptionID) @@ -915,7 +922,7 @@ func (a *Server) upsertOperationalIntentReference(ctx context.Context, authorize } // Construct the new OperationalIntent - op := validParams.toOIR(manager, attachedSub, version) + op := validParams.toOIR(manager, attachedSub, version, pastOVNs) // Upsert the OperationalIntent op, err = r.UpsertOperationalIntent(ctx, op)