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

Service installs: Fix creating two tasks when moving a device #1857

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

thgreasi
Copy link
Member

@thgreasi thgreasi commented Nov 22, 2024

Before this, we had two device PATCH hooks, (a) one handling device moves, and (b) one handling device pinning&unpinning, but we also have (c) a separate hook that unpins devices when moved. As a result when moving a device (c) would change the values so that the payload includes both belongs_to__application & is_pinned_on__release, hence both (a) & (b) hook would run and try to create any missing service install, which other than the extra work, it also means that if task based service install creation was enabled, would cause two tasks to be added.

We could also have an optimization for the case that values.is_pinned_on__release != null
to make the part that finds the target release faster, but chose to keep this simpler since:
a) We expect that in the majority of device move requests users will not be also be pinning
the device at the same time.
b) Only the sync approach would benefit from it, since creating the service installs via tasks
(which is going to be the default), only accepts the deviceIds as a parameter.

Change-type: patch

@thgreasi thgreasi marked this pull request as draft November 22, 2024 14:51
@thgreasi thgreasi requested a review from a team November 22, 2024 14:52
@thgreasi thgreasi force-pushed the fix-double-task-on-move branch 4 times, most recently from 574e94d to 342f406 Compare November 22, 2024 18:30
@thgreasi thgreasi marked this pull request as ready for review November 22, 2024 18:30
@thgreasi thgreasi force-pushed the fix-double-task-on-move branch 2 times, most recently from 8793dbc to 8bf34dc Compare November 25, 2024 11:22
Comment on lines +299 to +304
// We could also have an optimization for the case that `values.is_pinned_on__release != null`
// to make the part that finds the target release faster, but chose to keep this simpler since:
// a) We expect that in the majority of device move requests users will not be also be pinning
// the device at the same time.
// b) Only the sync approach would benefit from it, since creating the service installs via tasks
// (which is going to be the default), only accepts the deviceIds as a parameter,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is very much a TODO comment and would make more sense in the commit body imo, having it in the code like this is probably not going to end up being useful as no one will look at it anyway. Fwiw I do agree we don't need the extra levels of optimization as well so the only reason we would ever act on this is if we found performance issues that triggered us to investigate anyway, in which case we probably wouldn't find this

Comment on lines +305 to +306
await createAppServiceInstalls(api, newAppId, affectedIds, tx);
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd appreciate a comment saying that since we're moving apps we can just create the app service installs and not worry about targeting the specific release, otherwise I would wonder why we're returning here

Copy link
Member Author

Choose a reason for hiding this comment

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

@flowzone-app flowzone-app bot merged commit c2fdca5 into master Nov 26, 2024
51 checks passed
@flowzone-app flowzone-app bot deleted the fix-double-task-on-move branch November 26, 2024 07:39
@thgreasi
Copy link
Member Author

🤦 I just rebased before finding out that it was already approved w/ comments...
Let me PR the comment

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.

3 participants