plugins: Add rollback support for failed plugin updates - #6179
plugins: Add rollback support for failed plugin updates#6179skools-here wants to merge 17 commits into
Conversation
|
ptal @illume |
There was a problem hiding this comment.
Pull request overview
This PR makes plugin updates safer by adding a backup-and-rollback mechanism so an existing plugin isn’t lost if installing the new version fails mid-update.
Changes:
- Update flow now renames the existing plugin directory to a
.backupdirectory before moving the new plugin into place, and restores it on failure. - Adds cleanup logic for temporary extraction directories on failure.
- Adds Electron unit tests covering successful updates, rollback on move failure, and failures before backup creation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| plugins/pluginctl/src/plugin-management.js | Adds backup/rollback behavior to transactionalize CLI plugin updates. |
| app/electron/plugin-management.ts | Adds backup/rollback behavior to transactionalize Electron plugin updates. |
| app/electron/plugin-management.test.ts | Adds unit tests for update success, rollback, and pre-backup failure scenarios. |
|
ptal @illume |
illume
left a comment
There was a problem hiding this comment.
Thanks for this PR.
The open review comments from Copilot still need attention — can you have a look? Once addressed, please mark them as resolved.
|
ptal @illume |
72955b1 to
5cd4999
Compare
illume
left a comment
There was a problem hiding this comment.
Thanks for working on this.
Looks like there are some lint errors in the frontend — cd frontend && npm run lint will show them.
How to fix lint errors
Run cd frontend && npm run lint to see all ESLint errors. Many can be fixed automatically with cd frontend && npm run lint -- --fix. Remaining errors need manual attention.
illume
left a comment
There was a problem hiding this comment.
Thanks for this PR.
The open review comments from Copilot still need attention — can you have a look? Once addressed, please mark them as resolved.
| test('Error propagation when progressCallback is provided', async () => { | ||
| const errorCallback = jest.fn(); | ||
|
|
||
| // install should resolve to undefined when progressCallback is provided, as it catches the error and reports it via callback | ||
| await expect( | ||
| PluginManager.install( | ||
| 'https://artifacthub.io/packages/headlamp/headlamp-plugins/non-existent-plugin', | ||
| tempDir, | ||
| '', | ||
| errorCallback | ||
| ) | ||
| ).resolves.toBeUndefined(); | ||
|
|
||
| expect(errorCallback).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| type: 'error', | ||
| message: expect.stringContaining('HTTP error! status: 404'), | ||
| }) | ||
| ); | ||
| }); |
| await PluginManager.install( | ||
| 'https://artifacthub.io/packages/headlamp/headlamp-plugins/headlamp_flux', | ||
| tempDir, | ||
| '', | ||
| mockProgressCallback |
| if (progressCallback) { | ||
| try { | ||
| progressCallback({ type: 'success', message: 'Plugin Updated' }); | ||
| } catch (callbackErr) { | ||
| console.error('Progress callback failed:', callbackErr); | ||
| } | ||
| } |
illume
left a comment
There was a problem hiding this comment.
Thanks for working on this.
Would you mind addressing the open Copilot review comments? Please mark each comment as resolved after addressing it.
illume
left a comment
There was a problem hiding this comment.
Thanks for the contribution.
This PR has git conflicts — could you resolve them?
How to resolve conflicts
Rebase or merge the latest main into your branch, resolve the conflicts, and push the updated branch.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: skools-here The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
This PR makes plugin updates transactional by introducing a backup-and-rollback mechanism in the plugin update flow.
Previously,
PluginManager.update()removed the existing plugin before moving the newly downloaded version into place. If the move operation failed due to filesystem errors, insufficient permissions, or disk space issues, the original plugin was permanently lost. This change ensures that the existing plugin is preserved and automatically restored if the update process fails.Related Issue
Fixes #6174
Changes