-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement remove command #89
base: develop
Are you sure you want to change the base?
Conversation
We also need to store remove requests in the database, so if a server goes down we will be able to recover interrrupted removal process |
put/baton.go
Outdated
@@ -85,6 +86,34 @@ func GetBatonHandler() (*Baton, error) { | |||
return &Baton{}, err | |||
} | |||
|
|||
// GetBatonHandlerWithMetaClient returns a Handler that uses Baton to interact | |||
// with iRODS and contains a meta client for interacting with metadata. If you | |||
// don't have baton-do in your PATH, you'll get an error. |
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 should be some docs and, probably for GetBatonHandler() as well, and probably for server.Config.StorageHandler that makes it explicit you need to call this and not GetBatonHandler() for remove functionality to work.
Is there a better way of arranging things so there aren't 2 GetBaton...() methods? Or some other way of avoiding possible mistakes like this?
put/baton.go
Outdated
it := remotePathToRodsItem(path) | ||
|
||
err := timeoutOp(func() error { | ||
_, errl := b.metaClient.RemObj(ex.Args{}, *it) |
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.
Write a test that fails due to panic when you use a Baton from GetHandler(), then fix this in some way to return a nicer error. Likewise for queryMeta, RemoveDir and GetMeta.
put/put.go
Outdated
@@ -23,7 +23,7 @@ | |||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
******************************************************************************/ | |||
|
|||
// package put is used to put files in iRODS. | |||
// package put is used to interact with iRODS. |
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.
One possible solution to the confusion over baton GetHandler vs GetBatonHandlerWithMetaClient is that put package remains for putting only, and another package is created with its own interface that embeds put's Handler and has the extra non-put stuff, and it's that interface that the server requires.
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.
@sb10 we implemented your idea in the most recent commit (7d3b...).
Could you take a look and tell whether this looks good or not? In terms of whether it indeed makes sense to split put and remove functions between different packages.
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.
I think in principle it's a valuable change to make, if it can be done right, and if there are callers that need the split.
The benefit of a split in the Handler interface would be if there is any code outside the put package that needs a Handler with just put functions, but not remove functions. Or vice versa.
But it seems like server needs the remove functions, and at least one put function?
Does cmd/put in non-server mode also only want put functions?
If there's a split desired functionality, then yes, we should have 2 different interfaces, and keep the put package as a pure package for putting.
But baton and mock (probably changing to internal/mock) should be their own packages that provide something that implements both interfaces. Getting back to what triggered this, can there be, in some new baton pkg, a New() function that would happily satisfy both put.Handler and remove.Handler? (ie. is there harm in always having the meta bit? Or can the meta bit be auto-vivified when needed?)
The remove interface in the remove package should be called Handler and should only include the methods that it needs to implement its functionality (so probably not a blanket embed of put.Handler).
server/server_test.go
Outdated
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.
Not sure if the tests are already in here or elsewhere, but there should be tests of the server's new removal functionality that use the mock instead of real iRODS via baton.
There should be tests that explore the behaviour of the user asking for a local path directory to be removed, that should work when local path no longer exists: all files in the directory should still get removed from iRODS (well, the mock).
…emoved from DB and delint
0befb81
to
9ae8992
Compare
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.
I think you're still going through my previous review, but here are some more things I noticed.
put/baton.go
Outdated
return err | ||
} | ||
|
||
func (b *Baton) QueryMeta(dirToSearch string, meta map[string]string) ([]string, error) { |
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.
Needs docs
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.
fixed
return meta, nil | ||
} | ||
|
||
func (l *LocalHandler) RemoveDir(path string) error { |
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 now public methods here need docs.
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.
fixed
set/db.go
Outdated
@@ -243,6 +248,17 @@ func updateDatabaseSetWithUserSetDetails(dbSet, userSet *Set) error { | |||
return nil | |||
} | |||
|
|||
func (d *DB) UploadEntry(sid, key string, entry *Entry) error { |
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.
Needs docs
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.
fixed
return err | ||
} | ||
|
||
type RemoveReq struct { |
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.
Needs docs
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.
fixed
842e8bd
to
12d625d
Compare
0193666
to
85750a7
Compare
85750a7
to
78ed27e
Compare
https://jira.sanger.ac.uk/browse/HSI-64