-
Notifications
You must be signed in to change notification settings - Fork 426
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
Clear pending (un)installs when installers are deleted #23427
Conversation
…ending (un)installs on installer delete TODO: * Apply to bulk installer changes * Update tests to ensure that pending (un)installs get deleted
Still TODO: bulk actions
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23427 +/- ##
==========================================
+ Coverage 63.13% 63.15% +0.02%
==========================================
Files 1555 1556 +1
Lines 147093 147290 +197
Branches 3725 3669 -56
==========================================
+ Hits 92861 93019 +158
- Misses 46886 46910 +24
- Partials 7346 7361 +15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@noahtalerman for copy, how does this look? Slight tweak from design review to maintain existing "deleting the installer won't uninstall from all hosts" verbiage: |
@@ -18,13 +18,15 @@ const DELETE_SW_INSTALLED_DURING_SETUP_ERROR_MSG = | |||
interface IDeleteSoftwareModalProps { | |||
softwareId: number; | |||
teamId: number; | |||
software: any; // TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we set this to ISoftwarePackage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just pass in the name as a string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would have to tweak upstream because according to the type checker we might (but in reality won't) have a VPP app instead, which would result in an undefined installer property, so I can't tighten the type up without other changes (type checker shows ISoftwarePackage | undefined
).
The Edit Software modal has the same issue, so probably makes sense to hit both with the same fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way usually handle that is by setting the type as a union with undefined
, then use optional chaining to handle the undefined case (which we know won't happen) when referencing it. You could also nullish coallesce to a default case for comfort, though since we know it will always be defined it should be okay either way, of course. So something like
software: ISoftwarePackage | undefined;
...
software?.name ?? "this software"
I'll sometimes leave a comment to the effect of "This will actually always be defined" just to be clear, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have quite a few instances of this situation, which is of course not ideal, but very often cleaning up the typing upstream would involve a) untangling a huge mess of spaghetti and/or b) refactoring our API service layer with generics (something we've discussed) to have actual type checking there. Both would be great to do, but of course, require time, effort, and prioritization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jacobshandling Revised to pass the (nullable) name of the package in b289060
Tests pass on this, including new tests, but I still need to manually QA. Added @lucasmrod for BE review, @RachelElysia for FE review, so if my self-QA passes (will write up test plan on the parent ticket) I can get this merged and cherry-picked later today. |
@@ -18,13 +18,15 @@ const DELETE_SW_INSTALLED_DURING_SETUP_ERROR_MSG = | |||
interface IDeleteSoftwareModalProps { | |||
softwareId: number; | |||
teamId: number; | |||
software: any; // TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just pass in the name as a string?
hsi.status = :software_status_install_pending`, | ||
`SELECT | ||
COUNT(*) c | ||
FROM host_software_installs hsi | ||
WHERE hsi.host_id = :host_id AND | ||
WHERE hsi.host_id = :host_id AND hsi.software_installer_id IS NOT NULL AND |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual fix for the bug reported by QA wolf right? Should the other changes be linked to different issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Underlying cause for the QAWolf bug is that we now need to manually clean up pending installs when installers get deleted, rather than the pending installs getting deleted automatically due to the ON DELETE CASCADE
that was previously on host_software_installs.software_installer_id
. This fix is belt-and-suspenders so the apparent problem goes away in QAWolf's environment without either a migration or a manual DB query, but without the larger cleanup we'd have invisible pending (un)installs when an installer is deleted, and the install part is a regression from v4.58.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
For unreleased bug #23350, introduced because we're no longer cascade-deleting _all_ related installs (related to #22996, #21654, #22087) # Checklist for submitter - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] Manual QA for all new/changed functionality
For unreleased bug #23350, introduced because we're no longer cascade-deleting all related installs (related to #22996, #21654, #22087)
Checklist for submitter
SELECT *
is avoided, SQL injection is prevented (using placeholders for values in statements)