sftp server does not allow pushing to new product unless you specify --create-prefix

Bug #36889 reported by David Allouche
8
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
James Henstridge

Bug Description

When trying to push a branch, for example ~person/product/name, if person does not have any branch registered in product, then "mkdir ~person/product/name" fails, and bzr is unable to push the branch.

This is also related to bug 36888, which is probably the reason why this behaviour is not uncovered by the test suite.

mkdir ~person/product/name should succed even if ls ~person does not list product. After mkdir, ls ~person must list product.

Tags: lp-code
Andrew Bennetts (spiv)
Changed in launchpad:
assignee: nobody → spiv
Revision history for this message
Andrew Bennetts (spiv) wrote :

In general, bzr push requires that the parent directory of the branch already exists. It seems we want it to behave differently for the supermirror? Perhaps it would be nice if bzr interactively gave you the option to try create parent directories?

$ bzr push sftp://bazaar.launchpad.net/~user/product/branch
bzr: Cannot push: parent directory ~user/product does not exist
Try to create it (y/n) ?

Another option would be a command line arg:

$ bzr push sftp://bazaar.launchpad.net/~user/product/branch
bzr: Cannot push: parent directory ~user/product does not exist. Try --mkdirs.

$ bzr push --mkdirs sftp://bazaar.launchpad.net/~user/product/branch
Pushing...

Revision history for this message
David Allouche (ddaa) wrote :

We should not require the --mkdirs option for users to push to the supermirror, under some specific and difficult to explain circumstances. That would just turn --mkdirs into an "unbreak me" option when push to bazaar.launchpad.net.

When pushing, bzr should try creating the target directory without first checking the existence of its parent with directory listing (which is racy anyway). If it behaves otherwise, it's a bzr bug.

Then the sftp server should allow creating a branch in an existing product even if the product has no branch for that user, and therefore does not appear in the listing.

Revision history for this message
Andrew Bennetts (spiv) wrote : sftp server requires product directories to be created explicitly

It turns out bzr push already has a --create-prefix option, by the way.

To an extent, this isn't a launchpad bug: pushing to a new directory directory on any other SFTP server would have the exact same issue. The only reason why it seems to be such a big issue is that launchpad requires a certain directory structure, and also because bzr doesn't suggest trying --create-prefix as part of it's "Parent directory of %s does not exist." message.

That said, it would be nice to have pushing to ~user/new-product/new-branch "just work" even if the user doesn't have any other branches in new-product. Robert informs me that bzr does optimistically try to mkdir the whole thing first, so this should just require a change to the server. This change may be a little ugly, but we'll see.

Changed in launchpad:
status: Unconfirmed → Confirmed
Revision history for this message
David Allouche (ddaa) wrote : Re: sftp server does not allow pushing to new product

Since creation of product directories is not persistent on the bazaar.launchpad.net sftp, it's already not behaving like a normal filesystem. I think it's okay to depart further from conventional filesystem semantics.

Revision history for this message
Steve Alexander (stevea) wrote :

This is an important fix in the sftp server, as it will make docs describing using this simpler, and use of this simpler.

Changed in launchpad-bazaar:
importance: Medium → High
Revision history for this message
James Henstridge (jamesh) wrote :

I've done a fix for this that is up for review now.

It changes the sftp filesystem code so that getting a non-existant child of a /~username dir will return a placeholder directory node. This node will have no children (which is correct since there are no branches registered against the product), and its createDirectory() implementation will create both the product and branch directories.

Changed in launchpad-bazaar:
assignee: spiv → jamesh
status: Confirmed → In Progress
Revision history for this message
James Henstridge (jamesh) wrote :

Fix committed as r3952

Changed in launchpad-bazaar:
status: In Progress → Fix Committed
Revision history for this message
James Henstridge (jamesh) wrote :

This fix was included in today's rollout.

Changed in launchpad-bazaar:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.