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

Implement remove command #89

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from
Open

Implement remove command #89

wants to merge 35 commits into from

Conversation

rk1274
Copy link
Contributor

@rk1274 rk1274 commented Feb 12, 2025

@rk1274 rk1274 requested review from sb10 and mjkw31 February 12, 2025 15:37
@y-popov
Copy link
Contributor

y-popov commented Feb 13, 2025

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

@rk1274 rk1274 requested a review from sb10 February 17, 2025 13:26
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.
Copy link
Contributor

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)
Copy link
Contributor

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.
Copy link
Contributor

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.

Copy link
Contributor

@y-popov y-popov Feb 18, 2025

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.

Copy link
Contributor

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).

Copy link
Contributor

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).

Copy link
Contributor

@sb10 sb10 left a 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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs docs

Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs docs

Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs docs

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

@rk1274 rk1274 force-pushed the remove-command branch 2 times, most recently from 0193666 to 85750a7 Compare February 21, 2025 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants