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

[MM-59066] server/job: prevent deletion of non-finished jobs #30

Merged
merged 4 commits into from
Jul 5, 2024

Conversation

isacikgoz
Copy link
Member

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

@isacikgoz isacikgoz added the 2: Dev Review Requires review by a core committer label Jun 25, 2024
Copy link
Member

@cpoile cpoile left a comment

Choose a reason for hiding this comment

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

Nice!

Comment on lines 42 to 50
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)
})
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

@agnivade agnivade left a 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.

server/job.go Outdated Show resolved Hide resolved
@isacikgoz isacikgoz added the 2: QA Review Requires review by a QA tester label Jun 27, 2024
@isacikgoz isacikgoz removed the 2: Dev Review Requires review by a core committer label Jun 27, 2024
server/job.go Outdated Show resolved Hide resolved
Copy link

@DHaussermann DHaussermann left a 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 since Remove 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. 🎉

@DHaussermann
Copy link

Heads up @isacikgoz I don't have permission to modify labels in this repo. I cannot remove the QA Review label.

@hanzei hanzei added 3: Reviews Complete All reviewers have approved the pull request and removed 2: QA Review Requires review by a QA tester labels Jul 4, 2024
isacikgoz and others added 2 commits July 5, 2024 11:29
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
@isacikgoz isacikgoz merged commit c9323fd into master Jul 5, 2024
4 checks passed
@isacikgoz isacikgoz deleted the MM-59066 branch July 5, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants