Skip to content

Commit

Permalink
[scd] Store past OVNs on operational intents upsert
Browse files Browse the repository at this point in the history
  • Loading branch information
mickmis committed Sep 6, 2024
1 parent 7ecfa90 commit beb2042
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/scd/operational_intents_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,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.
Expand All @@ -379,9 +379,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,
Expand Down Expand Up @@ -766,9 +768,13 @@ func (a *Server) upsertOperationalIntentReference(ctx context.Context, authorize
return stacktrace.PropagateWithCode(err, stacktrace.GetCode(err), "Request validation failed")
}

version := scdmodels.VersionNumber(1)
var (
version = scdmodels.VersionNumber(1)
pastOVNs = make([]scdmodels.OVN, 0)
)
if old != nil {
version = old.Version + 1
pastOVNs = append(old.PastOVNs, validParams.ovn)
}

var sub *scdmodels.Subscription
Expand Down Expand Up @@ -837,7 +843,7 @@ func (a *Server) upsertOperationalIntentReference(ctx context.Context, authorize
}

// Construct the new OperationalIntent
op := validParams.toOIR(manager, sub, version)
op := validParams.toOIR(manager, sub, version, pastOVNs)

// Upsert the OperationalIntent
op, err = r.UpsertOperationalIntent(ctx, op)
Expand Down

0 comments on commit beb2042

Please sign in to comment.