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] properly cleanup implicit sub on oir update #1104

Merged

Conversation

Shastick
Copy link
Contributor

@Shastick Shastick commented Sep 6, 2024

This is a rework of #1057 after most changes for #1088 have landed.

The DSS built from this PR successfully passed the new qualifier's implicit subscription handling scenario, although that scenario still needs to be extended to cover all corner cases.

The PR is open for review, as it addresses #1056

@Shastick Shastick force-pushed the fix-implicit-sub-oir-update-clean branch from 03bd2b6 to 00a7e0c Compare September 6, 2024 15:41
@Shastick Shastick marked this pull request as ready for review September 7, 2024 17:55
Copy link
Contributor

@mickmis mickmis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor comments, otherwise LGTM. Thanks for the previous refactorings, that makes this change much more readable.

// See https://github.com/interuss/dss/issues/1059 for more details
func subscriptionIsImplicitAndOnlyAttachedToOIR(ctx context.Context, r repos.Repository, oirID *dssmodels.ID, subscription *scdmodels.Subscription) (bool, error) {
if subscription == nil {
return false, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a sanity check: return an error if subscription is nil. It does not make sense invoking that function with a nil subscription.
Or remove the check altogether since it is private and use twice where a non-nil check is already performed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Subscriptions are allowed to be nil when the state of an OIR is 'accepted' so receiving a nil here does not necessarily indicate a problem
  • when an OIR is created there is no previous subscription to speak of, so a nil makes sense as well

My intent of having the check here was probably to avoid the extra checks in the caller, but conciseness consideration taken aside:

I may have originally called the method subscriptionNeedsCleanup: at that time the early return with false would fit pretty well with the method name. But even now, if a subscription does not exist it feels Ok to just return false, as a non-existing subscription can't be implicit or attached to the OIR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the context where this method is called, I feel like moving the check out of it will not bring any benefits: I'd rather leave it as-is, especially knowing that an upcoming PR is going to remove this code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a subscription does not exist it feels Ok to just return false, as a non-existing subscription can't be implicit or attached to the OIR?

I guess that's a possible interpretation, but then I'd say that the root issue here is that the abstraction defined by this function is a bit awkward. Not a huge issue in itself here though.
As long as we are not silencing errors I'm OK, and looks like it's not the case here.

especially knowing that an upcoming PR is going to remove this code

Is this actually planned for?
(but not a valid reason anyway)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in #1059 and it's part of the work we'd like to possibly get done until the 14th

pkg/scd/operational_intents_handler.go Outdated Show resolved Hide resolved
pkg/scd/operational_intents_handler.go Outdated Show resolved Hide resolved
@Shastick Shastick force-pushed the fix-implicit-sub-oir-update-clean branch from 00a7e0c to 557c8eb Compare September 9, 2024 11:35
@mickmis mickmis merged commit a17cbe9 into interuss:master Sep 9, 2024
6 checks passed
@mickmis mickmis deleted the fix-implicit-sub-oir-update-clean branch September 9, 2024 12:25
@mickmis mickmis restored the fix-implicit-sub-oir-update-clean branch September 9, 2024 12:34
mickmis added a commit that referenced this pull request Sep 9, 2024
mickmis added a commit that referenced this pull request Sep 9, 2024
Reverts #1104 due to incorrect merge commit being used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants