-
Notifications
You must be signed in to change notification settings - Fork 1
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
[MM-59066] server/job: prevent deletion of non-finished jobs #30
Conversation
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.
Nice!
server/job_test.go
Outdated
t.Run("Empty dump location", func(t *testing.T) { | ||
job := &DumpJob{ | ||
DumpLocation: "", | ||
} | ||
|
||
success, err := job.DeleteDump(plugin) | ||
require.NoError(t, err) | ||
require.False(t, success) | ||
}) |
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 it be a good idea to check if the fs
was asked to delete anything?
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.
Added an assertion for that, created a temp file and then checked if it was deleted or not.
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.
Good to go after the shadowing issue is fixed.
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.
Tested and passed
Confirmed I could see the bug: Both the data
and dump
folder located here server/data/plugin-data/mattermost-plugin-metrics
were being deleted
- Tested to ensure the
data
folder is no longer getting deleted - The
dump
folder does get deleted as expected sinceRemove All
has been clicked - The
dump
folder does get recreated once the next queued job completes - Regression tested other plugin functionality around the path to the data folder as well as the download and remove options for existing dumps.
No issues found.
LGTM!
Huge thanks to @isacikgoz for teaching me about this plugin and helping me with adding a delay to make repro conditions much easier. 🎉
Heads up @isacikgoz I don't have permission to modify labels in this repo. I cannot remove the QA Review label. |
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Summary
An issue has been pointed out that if a “Remove All” request is being made during a job is running will led to a case that plugin to delete entire data directory. So, the logic was deleting the directory of the dump. But the problem is, if a job receives a request to be deleted, and it doesn’t have a dump directory (which would be set after the job finishes), it will have an empty value. And if the empty value is given to filestore, the entire data directory will be deleted.
Ticket Link
https://mattermost.atlassian.net/browse/MM-59066