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

[scd] Store past OVNs on operational intents upsert #1096

Merged
merged 1 commit into from
Sep 9, 2024
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
21 changes: 14 additions & 7 deletions pkg/scd/operational_intents_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading