-
Notifications
You must be signed in to change notification settings - Fork 5
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
[TT-1802] Clean up Stow locations when deleting middleware #22
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… disk Resetting the configuration for mserv to zero and (re)reading afresh aids testability.
Added a new test, along with some helpers and mock implementations, to cover the DeleteMW. Note that the test is currently failing as of this commit, so let's see about fixing that!
There was previously no call made from the bundle delete handler for stow to remove its local/S3 container, so local files and S3 buckets would be left lying around after their corresponding middleware definitions within MServ wer long gone. fix TT-1802
The RemoveContainer implementation for "local" Kind in stow does not use the full path when deleting, only a relative one. If WasabiAiR/stow#239 were to be implemented/resolved then this block of code could be deleted.
…er, for S3's sake Via Stow, S3 buckets can only be removed once they no longer contain any objects. fix TT-1802
… beginning We still do a GetMWByID call on the middleware in the store at the start of the handler, which would error and return immediately if middleware with that ID did not exist. Given that succeeds though, we proceed to clean out the stow container and remove that, which is much more error-prone given the new changes in this feature branch. Assuming all of that succeeds, then we delete the middleware from the store.
komalsukhani
approved these changes
Mar 17, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The handler to delete middleware was not cleaning up containers for either of the two different kinds of stow location in use by MServ i.e.
local
ands3
.api
package(api.API).HandleDeleteBundle(...)
stow.Walk
removes each item from the container (necessary for S3) (10a6774)(stow.Location).RemoveContainer
removes the empty container itself (d63b6d4)os.Chdir
is necessary to workaround a shortcoming in how stow handleslocal
containers: RemoveContainer forlocal
seems incorrect WasabiAiR/stow#239 (aeb5c36)General
FmtPluginContainer
format string used for container name layouts (94705cb, 81b5a70)stow.Kind
consts inGetFileStore()
rather than hard-coded strings (18cf3d3)http_funcs
packageTestDeleteMW
to cover the existing and updated functionality of the API's delete handler (1cb44d8)conf
packageReload()
func which will flush the current config and re-read data (c8e1a32)util/conf
packageFlush()
to facilitateconf.Reload()
util/storage/mock
packageMiscellaneous
maligned
in thegolangci-lint
config file, as it has since moved intogo vet
(8cfe5ee)Related Issue
TT-1802.
Motivation and Context
End users don't want S3 buckets left lying around after they delete a middleware.
Test Coverage For This Change
Added
TestDeleteMW
, and ran some integration tests on my local, to cover bothlocal
ands3
kinds of stow locations.Screenshots (if appropriate)
Types of changes
Checklist
master
!master
branch (left side). Also, it would be best if you started your change off our latestmaster
.go mod tidy && go mod vendor
in applicable directories.gofmt -s -w .
go vet ./...
golangci-lint run