review Brian's patches for #607 #830

Closed
opened 2009-11-13 03:09:09 +00:00 by zooko · 24 comments
per <http://allmydata.org/pipermail/tahoe-dev/2009-October/003061.html>
zooko added the
c/code-dirnodes
p/major
t/defect
v/1.5.0
labels 2009-11-13 03:09:09 +00:00
zooko added this to the 1.6.0 milestone 2009-11-13 03:09:09 +00:00
zooko self-assigned this 2009-11-13 03:09:09 +00:00
Author

Okay here is the timeline of all patches committed since the 1.5.0 release until today: http://allmydata.org/trac/tahoe/timeline?from=2009-11-13&daysback=104&changeset=on&update=Update

First up: changeset:0d5dc5161791a90a: "Overhaul IFilesystemNode handling, to simplify tests and use POLA internally."

Okay here is the timeline of all patches committed since the 1.5.0 release until today: <http://allmydata.org/trac/tahoe/timeline?from=2009-11-13&daysback=104&changeset=on&update=Update> First up: changeset:0d5dc5161791a90a: "Overhaul IFilesystemNode handling, to simplify tests and use POLA internally."
Author

I feel uncomfortable about the prospect that we might release a new stable version of Tahoe-LAFS without anybody having reviewed these deep changes. I'm marking this as "critical" to remind myself that I'm currently uncomfortable releasing a new stable release without first closing this ticket. I still own this ticket because I plan to do it, but if anyone else wants to do it I would definitely appreciate the help. We could even split up the work.

I feel uncomfortable about the prospect that we might release a new stable version of Tahoe-LAFS without anybody having reviewed these deep changes. I'm marking this as "critical" to remind myself that I'm currently uncomfortable releasing a new stable release without first closing this ticket. I still own this ticket because I plan to do it, but if anyone else wants to do it I would definitely appreciate the help. We could even split up the work.
zooko added
p/critical
and removed
p/major
labels 2009-12-29 00:14:02 +00:00

I'd offer to help with the review, but, well, reviewing one's own patches might cause a recursive loop in the universe and destroy us all :).

But seriously, if there's anything I can explain or provide more background on, just give a yell.

I'd offer to help with the review, but, well, reviewing one's own patches might cause a recursive loop in the universe and destroy us all :). But seriously, if there's anything I can explain or provide more background on, just give a yell.
francois commented 2010-01-10 01:42:09 +00:00
Owner

I made a functional review of these new immutable dirnodes and their
use by tahoe backup.

I've been running tahoe backup on a daily basis to save my precious
data for about 8 months now. After an upgrade to the latest trunk, I ran
a backup manually which, as expected, created a new DIR-IMM dirnode
inside Archive and a link to it named Latest.

Here are my observations so far:

  1. An older Tahoe gateway did not recognized the new DIR-IMM

immutable directory and correctly showed an question mark on the webapi.

  1. It seems to break the blackmatch FUSE implementation, an exception is

raised when it tries to access an immutable dirnode.

Sat Jan  9 22:25:05 2010: exception:
Traceback (most recent call last):
  File "/home/francois/WORK/dev/tahoe/contrib/fuse/impl_c/blackmatch.py", line 177, in inner_logexc
    ret = meth(self, *args, **kwargs)
  File "/home/francois/WORK/dev/tahoe/contrib/fuse/impl_c/blackmatch.py", line 314, in done
    precondition(not self.read_heap, self.read_heap, self.target_size, self.get_size())
  File "/usr/local/lib/python2.6/dist-packages/allmydata_tahoe-1.5.0_r4054-py2.6.egg/allmydata/util/assertutil.py", line 46, in precondition
    raise AssertionError, "".join(msgbuf)
AssertionError: precondition: [(3832, 0, <Deferred at 0x3c94440>)] <type 'list'>, 264 <type 'int'>, 264 <type 'int'>

I'll run 'tahoe deep-check' to see if it works correctly.

I made a functional review of these new immutable dirnodes and their use by *tahoe backup*. I've been running *tahoe backup* on a daily basis to save my precious data for about 8 months now. After an upgrade to the latest trunk, I ran a backup manually which, as expected, created a new *DIR-IMM* dirnode inside *Archive* and a link to it named *Latest*. Here are my observations so far: 1. An older Tahoe gateway did not recognized the new *DIR-IMM* > immutable directory and correctly showed an question mark on the webapi. 2. It seems to break the blackmatch FUSE implementation, an exception is > raised when it tries to access an immutable dirnode. ``` Sat Jan 9 22:25:05 2010: exception: Traceback (most recent call last): File "/home/francois/WORK/dev/tahoe/contrib/fuse/impl_c/blackmatch.py", line 177, in inner_logexc ret = meth(self, *args, **kwargs) File "/home/francois/WORK/dev/tahoe/contrib/fuse/impl_c/blackmatch.py", line 314, in done precondition(not self.read_heap, self.read_heap, self.target_size, self.get_size()) File "/usr/local/lib/python2.6/dist-packages/allmydata_tahoe-1.5.0_r4054-py2.6.egg/allmydata/util/assertutil.py", line 46, in precondition raise AssertionError, "".join(msgbuf) AssertionError: precondition: [(3832, 0, <Deferred at 0x3c94440>)] <type 'list'>, 264 <type 'int'>, 264 <type 'int'> ``` I'll run 'tahoe deep-check' to see if it works correctly.
francois commented 2010-01-10 17:12:18 +00:00
Owner

My daily tahoe backup got a huge performance hit after the upgrade from 1.5.0 to trunk. This the result of a typical daily run on 1.5.0 (+ a few patches).

 16 files uploaded (186918 reused), 67 directories created (26010 reused), 0 problematic files skipped
 backup done, elapsed time: 1:03:32

This is the result of the first run after upgrade.

 1056 files uploaded (201639 reused), 14107 directories created (19134 reused)
 backup done, elapsed time: 9:46:20

I've just launched a second run to determine whether it's only a one-time penalty due to the upgrade or if it's another problem. If this behavior is normal, it's probably worth begin mentioned in the release notes.

My daily *tahoe backup* got a huge performance hit after the upgrade from 1.5.0 to trunk. This the result of a typical daily run on 1.5.0 (+ a few patches). ``` 16 files uploaded (186918 reused), 67 directories created (26010 reused), 0 problematic files skipped backup done, elapsed time: 1:03:32 ``` This is the result of the first run after upgrade. ``` 1056 files uploaded (201639 reused), 14107 directories created (19134 reused) backup done, elapsed time: 9:46:20 ``` I've just launched a second run to determine whether it's only a one-time penalty due to the upgrade or if it's another problem. If this behavior is normal, it's probably worth begin mentioned in the release notes.

Yeah, the first run with the new immutable-directory code will have to re-upload all of your directories, so you should see a slowdown on the first run. But after that, the second and later runs should be super quick, much faster than the second-and-later runs of the old (mutable directory) code, because the immutable-directory code will be doing fast sqlite lookups instead of a bunch of tahoe-side directory reads.

If you keep seeing slowdowns and can confirm that nothing much has changed between subsequent runs, let's take a look at the SQL schema and make sure we're not missing an index on something important.

I'll add a note to the release notes to prepare folks for this change and for the initial slowdown.

Yeah, the first run with the new immutable-directory code will have to re-upload all of your directories, so you should see a slowdown on the first run. But after that, the second and later runs should be super quick, much faster than the second-and-later runs of the old (mutable directory) code, because the immutable-directory code will be doing fast sqlite lookups instead of a bunch of tahoe-side directory reads. If you keep seeing slowdowns and can confirm that nothing much has changed between subsequent runs, let's take a look at the SQL schema and make sure we're not missing an index on something important. I'll add a note to the release notes to prepare folks for this change and for the initial slowdown.
francois commented 2010-01-10 22:00:03 +00:00
Owner

Yes! The subsequent runs are way faster.

 0 files uploaded (197702 reused), 0 directories created (26372 reused)
 535 files checked, 0 directories checked
 backup done, elapsed time: 0:05:30
Yes! The subsequent runs are way faster. ``` 0 files uploaded (197702 reused), 0 directories created (26372 reused) 535 files checked, 0 directories checked backup done, elapsed time: 0:05:30 ```
Author

I opened #894 (blackmatch fuse doesn't know what to think about immutable directories).

I opened #894 (blackmatch fuse doesn't know what to think about immutable directories).
kevan commented 2010-01-12 18:47:54 +00:00
Owner

I read this comment:

Call this to override the size of the RSA keys created for new
mutable files. The default of None means to let mutable.filenode
choose its own size, which means 2048 bits.

for KeyGenerator.set_default_keysize to mean that if I call that method with None as an argument, the key generator will know to generate keys of 2048 bits. If I understand the code correctly, what actually happens is that the default keysize (which is in fact 2048 bits before I call this method) is overwritten with None.

If I later call KeyGenerator.generate without specifying a keysize, None is passed (depending on whether a remote key generator is running) to the remote key generator (in source:src/allmydata/key_generator.py) or to the RSA implementation in pycryptopp. In neither case of these cases, from what I understand, is the comment actually true -- in the former, the key generator will prefer the passed key size to its default (which is also 2048 bits) and pass it to pycryptopp, and in the latter the configured keysize will be passed to pycryptopp, which will in both cases complain about its arguments.

I read this comment: ``` Call this to override the size of the RSA keys created for new mutable files. The default of None means to let mutable.filenode choose its own size, which means 2048 bits. ``` for [KeyGenerator](wiki/KeyGenerator).set_default_keysize to mean that if I call that method with None as an argument, the key generator will know to generate keys of 2048 bits. If I understand the code correctly, what actually happens is that the default keysize (which is in fact 2048 bits before I call this method) is overwritten with None. If I later call [KeyGenerator](wiki/KeyGenerator).generate without specifying a keysize, None is passed (depending on whether a remote key generator is running) to the remote key generator (in source:src/allmydata/key_generator.py) or to the RSA implementation in pycryptopp. In neither case of these cases, from what I understand, is the comment actually true -- in the former, the key generator will prefer the passed key size to its default (which is also 2048 bits) and pass it to pycryptopp, and in the latter the configured keysize will be passed to pycryptopp, which will in both cases complain about its arguments.
kevan commented 2010-01-12 18:50:30 +00:00
Owner

Also note that KeyGenerator in client.py has the same name as the key generator in source:src/allmydata/key_generator.py. I'm not sure if that's a stylistic concern or anything -- they're probably unlikely to ever be in scope in the same context.

Also note that [KeyGenerator](wiki/KeyGenerator) in client.py has the same name as the key generator in source:src/allmydata/key_generator.py. I'm not sure if that's a stylistic concern or anything -- they're probably unlikely to ever be in scope in the same context.
kevan commented 2010-01-12 18:56:49 +00:00
Owner

erm, nevermind -- I read that comment again and realized that I didn't read it right -- mutable.filenode is not the same thing as client.KeyGenerator.

erm, nevermind -- I read that comment again and realized that I didn't read it right -- mutable.filenode is not the same thing as client.KeyGenerator.
Author

Thank you very much for reviewing Brian's patches! I desperately need help with this task. (And I'm prioritizing reviewing your patches for #778, which I have been doing on the bus to work every morning by the way.)

Please post on this ticket which specific patches you have reviewed so I can skip those ones when I'm looking for Brian-patches to review.

Thank you very much for reviewing Brian's patches! I desperately need help with this task. (And I'm prioritizing reviewing your patches for #778, which I have been doing on the bus to work every morning by the way.) Please post on this ticket which specific patches you have reviewed so I can skip those ones when I'm looking for Brian-patches to review.

Kevan: yeah, allmydata.client.KeyGenerator is what mutable-file creation uses to get an RSA keypair, and it either generates one locally or sends a message to a remote key-generator process (defined in allmydata.key_generator.KeyGenerator). I agree that the comment needs improvement. I touched that code to make it easier for most unit tests to generate small/fast keys, while still allowing at least one test to use full-sized 2048-bit keys, and of course to make sure that normal operations use full-size keys. As you observed, each call to KeyGenerator.generate() gets to pick a keysize, and if the caller doesn't provide one, it will use self.default_keysize which can be controlled by a call to KeyGenerator.set_default_keysize(), and defaults to 2048.

I think the comment on set_default_keysize was moved from generate without sufficient editing. I've just pushed a patch changeset:fb879ddea40c03e7 to improve the comments a bit.. let me know if you see any mistakes in the new text.

Kevan: yeah, `allmydata.client.KeyGenerator` is what mutable-file creation uses to get an RSA keypair, and it either generates one locally or sends a message to a remote key-generator process (defined in `allmydata.key_generator.KeyGenerator`). I agree that the comment needs improvement. I touched that code to make it easier for most unit tests to generate small/fast keys, while still allowing at least one test to use full-sized 2048-bit keys, and of course to make sure that normal operations use full-size keys. As you observed, each call to `KeyGenerator.generate()` gets to pick a keysize, and if the caller doesn't provide one, it will use `self.default_keysize` which can be controlled by a call to `KeyGenerator.set_default_keysize()`, and defaults to 2048. I think the comment on `set_default_keysize` was moved from `generate` without sufficient editing. I've just pushed a patch changeset:fb879ddea40c03e7 to improve the comments a bit.. let me know if you see any mistakes in the new text.
kevan commented 2010-01-14 00:53:42 +00:00
Owner

zooko: I've looked over the functional changes for changeset:0d5dc5161791a90a, but none of the tests.

warner: Yes, that's much better. Thanks for indulging me. :)

zooko: I've looked over the functional changes for changeset:0d5dc5161791a90a, but none of the tests. warner: Yes, that's much better. Thanks for indulging me. :)
kevan commented 2010-01-15 03:29:56 +00:00
Owner

I've just finished looking over the tests.

You store the nodemaker as self.nodemaker in [test_dirnode.Dirnode2]source:src/allmydata/test/test_dirnode.py?rev=4045#L780, and you've switched the tests to use nodemaker where they used client before, but you've left self.client as an ivar. Unless I'm missing something, none of the tests use it, so it should work just fine as a local variable in setUp.

Other than that, everything looks fine. Though there isn't a set of tests specifically for the NodeMaker (unless I've missed them), the fact that it is an abstraction of existing (and, from what I can tell, well-tested) behavior rather than new behavior means that this is probably a non-issue.

I've now looked at all of changeset:0d5dc5161791a90a.

I've just finished looking over the tests. You store the nodemaker as `self.nodemaker` in [test_dirnode.Dirnode2]source:src/allmydata/test/test_dirnode.py?rev=4045#L780, and you've switched the tests to use nodemaker where they used client before, but you've left `self.client` as an ivar. Unless I'm missing something, none of the tests use it, so it should work just fine as a local variable in `setUp`. Other than that, everything looks fine. Though there isn't a set of tests specifically for the [NodeMaker](wiki/NodeMaker) (unless I've missed them), the fact that it is an abstraction of existing (and, from what I can tell, well-tested) behavior rather than new behavior means that this is probably a non-issue. I've now looked at all of changeset:0d5dc5161791a90a.

Yeah, you're right. I've pushed changeset:9ab7524f0da3fcf8 to implement your suggestion.

And yes, there's no test_nodemaker, but all of nodemaker.py was extracted from client.py, and during the development process I iterated to attain full line-coverage on nodemaker.py . So I wasn't too worried about it. Plus I couldn't think of a good way to test it in isolation.

A lot of changeset:0d5dc5161791a90a was changing everything else to stop needing a Client, and instead using a Nodemaker or some other set of objects. And those changes should be covered by the existing tests for all of those "elses". Plus changing a lot of tests themselves to be smaller and not use a full Client when possible.

Yeah, you're right. I've pushed changeset:9ab7524f0da3fcf8 to implement your suggestion. And yes, there's no test_nodemaker, but all of nodemaker.py was extracted from client.py, and during the development process I iterated to attain full line-coverage on nodemaker.py . So I wasn't too worried about it. Plus I couldn't think of a good way to test it in isolation. A lot of changeset:0d5dc5161791a90a was changing everything *else* to stop needing a Client, and instead using a Nodemaker or some other set of objects. And those changes should be covered by the existing tests for all of those "elses". Plus changing a lot of tests themselves to be smaller and not use a full Client when possible.
kevan commented 2010-01-19 04:34:48 +00:00
Owner

Is there a canonical list of changesets that need to be reviewed for this to be closed?

Is there a canonical list of changesets that need to be reviewed for this to be closed?
Author

That's a good question. How about if I kind of scout around for patches that Brian committed that seem to be relevant to #607... Oh boy there are a lot of them.

changeset:5fe713fc52dc331b, changeset:f85690697a21e669, changeset:3ee740628ab32aae, changeset:e2ffc3dc03df8d73, changeset:304aadd4f7632afe, changeset:f871c3bb3ddc3b42, changeset:d079eb45f6581c27, changeset:cf65cc2ae3cc1062, changeset:b30041c5ecf3e2b6, changeset:c2520e4ec76195fb, changeset:480e1d318dd46619, changeset:ea373de042c49ba1 (you might be especially interested in that one. :-)), changeset:8a7c980e3765f89c, changeset:b4ec86c95a64d911, changeset:1273b5c233b076aa, changeset:768c76aa5fbe2c7f, changeset:2695af91a73661bf, changeset:f47672d12acb9042, changeset:cc422f8dc00d5cd3, changeset:5fe713fc52dc331b, changeset:cc422f8dc00d5cd3, changeset:512fe3ad62d0ad94, changeset:f85690697a21e669, changeset:834b20210ac37194.

Phewf! That is quite a lot, but the more of it you can review before the Tahoe-LAFS v1.6 release the better. Even if you don't find any major bugs, you will definitely be gaining expertise in the core Tahoe-LAFS logic -- expertise which I hope you will go on to use in Tahoe-LAFS v1.7. :-)

That's a good question. How about if I kind of scout around for patches that Brian committed that seem to be relevant to #607... Oh boy there are a lot of them. changeset:5fe713fc52dc331b, changeset:f85690697a21e669, changeset:3ee740628ab32aae, changeset:e2ffc3dc03df8d73, changeset:304aadd4f7632afe, changeset:f871c3bb3ddc3b42, changeset:d079eb45f6581c27, changeset:cf65cc2ae3cc1062, changeset:b30041c5ecf3e2b6, changeset:c2520e4ec76195fb, changeset:480e1d318dd46619, changeset:ea373de042c49ba1 (you might be especially interested in that one. :-)), changeset:8a7c980e3765f89c, changeset:b4ec86c95a64d911, changeset:1273b5c233b076aa, changeset:768c76aa5fbe2c7f, changeset:2695af91a73661bf, changeset:f47672d12acb9042, changeset:cc422f8dc00d5cd3, changeset:5fe713fc52dc331b, changeset:cc422f8dc00d5cd3, changeset:512fe3ad62d0ad94, changeset:f85690697a21e669, changeset:834b20210ac37194. Phewf! That is quite a lot, but the more of it you can review before the Tahoe-LAFS v1.6 release the better. Even if you don't find any major bugs, you will definitely be gaining expertise in the core Tahoe-LAFS logic -- expertise which I hope you will go on to use in Tahoe-LAFS v1.7. :-)
kevan commented 2010-01-19 04:49:12 +00:00
Owner

Excellent -- thanks for that. I'm mostly reviewing these when I have a spare moment during my day, so I'm not sure how much I'll get done, but I'll try.

Hm. Well, let's say for now that I'll take care of changeset:5fe713fc52dc331b. If I finish that, I'll start on the next changeset that is unclaimed.

Excellent -- thanks for that. I'm mostly reviewing these when I have a spare moment during my day, so I'm not sure how much I'll get done, but I'll try. Hm. Well, let's say for now that I'll take care of changeset:5fe713fc52dc331b. If I finish that, I'll start on the next changeset that is unclaimed.

When doing #833, I looked over all of the dirnode and web tests for immutable directories, and also the webapi.txt documentation. Those all looked OK; anything I found is addressed in the #833 patch.

When doing #833, I looked over all of the dirnode and web tests for immutable directories, and also the webapi.txt documentation. Those all looked OK; anything I found is addressed in the #833 patch.
Author

Okay, good enough! Thanks, Kevan and David-Sarah!

Okay, good enough! Thanks, Kevan and David-Sarah!
zooko added the
r/fixed
label 2010-01-28 15:04:04 +00:00
zooko closed this issue 2010-01-28 15:04:04 +00:00
kevan commented 2010-02-04 00:51:33 +00:00
Owner

I just finished looking through changeset:5fe713fc52dc331b, and didn't see any problems. I'll probably poke through some of the rest of these eventually, so I guess I'll reopen this if I find any problems.

I just finished looking through changeset:5fe713fc52dc331b, and didn't see any problems. I'll probably poke through some of the rest of these eventually, so I guess I'll reopen this if I find any problems.
kevan commented 2010-02-04 04:49:51 +00:00
Owner

Okay, from changeset:f85690697a21e669:

Am I missing something, or could you remove the self.convergence ivar from Client? From what I can tell, the only place it is used now is to make the secret holder that the nodemaker uses to get the convergence secret.

Well, I guess we can't remove it: we have web/unlinked.py,
web/filenode.py, frontends/ftpd.py and frontends/sftpd.py
that all reference that part of Client to get the convergence secret. It seems
like it would be more elegant if there was only
one canonical place for that -- the SecretHolder instance. We deal with this challenge for other sorts of files with methods in Client -- see

if mutable:
            req.content.seek(0)
            data = req.content.read()
            d = client.create_mutable_file(data)
            def _uploaded(newnode):
                d2 = self.parentnode.set_node(self.name, newnode,
                                              overwrite=replace)
                d2.addCallback(lambda res: newnode)
                return d2
            d.addCallback(_uploaded)
        else:
            uploadable = FileHandle(req.content, convergence=client.convergence)
            d = self.parentnode.add_file(self.name, uploadable,
                                         overwrite=replace)

where there is a method in client that talks to the nodemaker and makes a new mutable file, abstracting away the details of convergence and so on, but none for an immutable file. But then there isn't a method to make an immutable file in nodemaker, either, so there's not a lot to use as an abstraction. I guess that's kind of rambly, but that's what I was thinking when reading that changeset -- why not add immutable file logic to the nodemaker, and use that to eliminate external dependencies on things that aren't the SecretHolder?

The rest of the changes look okay.

Okay, from changeset:f85690697a21e669: Am I missing something, or could you remove the `self.convergence` ivar from `Client`? From what I can tell, the only place it is used now is to make the secret holder that the nodemaker uses to get the convergence secret. Well, I guess we can't remove it: we have `web/unlinked.py`, `web/filenode.py`, `frontends/ftpd.py` and `frontends/sftpd.py` that all reference that part of `Client` to get the convergence secret. It seems like it would be more elegant if there was only one canonical place for that -- the `SecretHolder` instance. We deal with this challenge for other sorts of files with methods in `Client` -- see ``` if mutable: req.content.seek(0) data = req.content.read() d = client.create_mutable_file(data) def _uploaded(newnode): d2 = self.parentnode.set_node(self.name, newnode, overwrite=replace) d2.addCallback(lambda res: newnode) return d2 d.addCallback(_uploaded) else: uploadable = FileHandle(req.content, convergence=client.convergence) d = self.parentnode.add_file(self.name, uploadable, overwrite=replace) ``` where there is a method in client that talks to the nodemaker and makes a new mutable file, abstracting away the details of convergence and so on, but none for an immutable file. But then there isn't a method to make an immutable file in nodemaker, either, so there's not a lot to use as an abstraction. I guess that's kind of rambly, but that's what I was thinking when reading that changeset -- why not add immutable file logic to the nodemaker, and use that to eliminate external dependencies on things that aren't the `SecretHolder`? The rest of the changes look okay.

Replying to kevan:

Well, I guess we can't remove it: we have web/unlinked.py,
web/filenode.py, frontends/ftpd.py and frontends/sftpd.py
that all reference that part of Client to get the convergence secret.
It seems like it would be more elegant if there was only one canonical
place for that -- the SecretHolder instance.

Yeah.. I'm not sure I was thinking about it at the time, but some day we're
likely to add a webapi facility to let clients provide the convergence secret
on an upload-by-upload basis, which is a vague argument for continuing to let
at least web/*.py grab the default from Client and then pass it
into the uploader code themselves.

There will be other values like this in the future.. I'm thinking of the
Accounting authority string here (for which there might be a client-wide
default, or there may be no default and webapi callers are obligated to
provide their own on each request).

We deal with this challenge for other sorts of files with methods in
Client

Yeah, I've updated more of the mutable-using code than the immutable code so
far (the immutable code is among the oldest in the tree).

So far, NodeMaker has acquired responsibility for turning caps into
nodes, and then picked up methods to create brand new nodes:
create_mutable_file, create_new_mutable_directory, and most
recently create_immutable_directory. So the next logical step would be
to give it a way to create new immutable filenodes,
create_immutable_file which would be known as upload() in the
vernacular.

(oh, it's also worth pointing out that mutable files don't use convergence..
wouldn't even make sense with them, so that's one fewer arguments needed for
client.create_mutable_file())

It would probably be a good start to get rid of dirnode.add_file,
change the signature of set_node to return the node that was just
added, and then replace the example you cite with something like:

if mutable:
    req.content.seek(0)
    data = req.content.read()
    d = client.create_mutable_file(data)
else:
    uploadable = FileHandle(req.content, convergence=client.convergence)
    d = client.upload(uploadable)
d.addCallback(lambda newnode: 
              self.parentnode.set_node(self.name, newnode, overwrite=replace)

If the nodemaker learned how to upload stuff, that could probably turn into:

if mutable:
    req.content.seek(0)
    data = req.content.read()
    d = nodemaker.create_mutable_file(data)
else:
    uploadable = FileHandle(req.content) # convergence?
    d = nodemaker.create_immutable_file(uploadable)
d.addCallback(lambda newnode: 
              self.parentnode.set_node(self.name, newnode, overwrite=replace)

As I get more comfortable with the Producer/Consumer framework, I see some
places where I can get rid of the funky custom classes that I built (like
FileHandle and IUploadable) and replace them with more normal
things like file-like objects and IProducers. I'm not yet sure I could
do away with IUploadable, but it's worth exploring. If both
create_mutable_file and create_immutable_file were defined to
accept either a string, a Producer, or a file-like object, then that code
could turn into:

if mutable:
    d = nodemaker.create_mutable_file(req.content)
else:
    d = nodemaker.create_immutable_file(req.content) # convergence?
d.addCallback(lambda newnode: 
              self.parentnode.set_node(self.name, newnode, overwrite=replace)
Replying to [kevan](/tahoe-lafs/trac/issues/830#issuecomment-374330): > > Well, I guess we can't remove it: we have `web/unlinked.py`, > `web/filenode.py`, `frontends/ftpd.py` and `frontends/sftpd.py` > that all reference that part of `Client` to get the convergence secret. > It seems like it would be more elegant if there was only one canonical > place for that -- the `SecretHolder` instance. Yeah.. I'm not sure I was thinking about it at the time, but some day we're likely to add a webapi facility to let clients provide the convergence secret on an upload-by-upload basis, which is a vague argument for continuing to let at least `web/*.py` grab the default from `Client` and then pass it into the uploader code themselves. There will be other values like this in the future.. I'm thinking of the Accounting authority string here (for which there might be a client-wide default, or there may be no default and webapi callers are obligated to provide their own on each request). > We deal with this challenge for other sorts of files with methods in > `Client` Yeah, I've updated more of the mutable-using code than the immutable code so far (the immutable code is among the oldest in the tree). So far, `NodeMaker` has acquired responsibility for turning caps into nodes, and then picked up methods to create brand new nodes: `create_mutable_file`, `create_new_mutable_directory`, and most recently `create_immutable_directory`. So the next logical step would be to give it a way to create new immutable filenodes, `create_immutable_file` which would be known as `upload()` in the vernacular. (oh, it's also worth pointing out that mutable files don't use convergence.. wouldn't even make sense with them, so that's one fewer arguments needed for `client.create_mutable_file()`) It would probably be a good start to get rid of `dirnode.add_file`, change the signature of `set_node` to return the node that was just added, and then replace the example you cite with something like: ``` if mutable: req.content.seek(0) data = req.content.read() d = client.create_mutable_file(data) else: uploadable = FileHandle(req.content, convergence=client.convergence) d = client.upload(uploadable) d.addCallback(lambda newnode: self.parentnode.set_node(self.name, newnode, overwrite=replace) ``` If the nodemaker learned how to upload stuff, that could probably turn into: ``` if mutable: req.content.seek(0) data = req.content.read() d = nodemaker.create_mutable_file(data) else: uploadable = FileHandle(req.content) # convergence? d = nodemaker.create_immutable_file(uploadable) d.addCallback(lambda newnode: self.parentnode.set_node(self.name, newnode, overwrite=replace) ``` As I get more comfortable with the Producer/Consumer framework, I see some places where I can get rid of the funky custom classes that I built (like `FileHandle` and `IUploadable`) and replace them with more normal things like file-like objects and `IProducer`s. I'm not yet sure I could do away with `IUploadable`, but it's worth exploring. If both `create_mutable_file` and `create_immutable_file` were defined to accept either a string, a Producer, or a file-like object, then that code could turn into: ``` if mutable: d = nodemaker.create_mutable_file(req.content) else: d = nodemaker.create_immutable_file(req.content) # convergence? d.addCallback(lambda newnode: self.parentnode.set_node(self.name, newnode, overwrite=replace) ```
Sign in to join this conversation.
No labels
c/code
c/code-dirnodes
c/code-encoding
c/code-frontend
c/code-frontend-cli
c/code-frontend-ftp-sftp
c/code-frontend-magic-folder
c/code-frontend-web
c/code-mutable
c/code-network
c/code-nodeadmin
c/code-peerselection
c/code-storage
c/contrib
c/dev-infrastructure
c/docs
c/operational
c/packaging
c/unknown
c/website
kw:2pc
kw:410
kw:9p
kw:ActivePerl
kw:AttributeError
kw:DataUnavailable
kw:DeadReferenceError
kw:DoS
kw:FileZilla
kw:GetLastError
kw:IFinishableConsumer
kw:K
kw:LeastAuthority
kw:Makefile
kw:RIStorageServer
kw:StringIO
kw:UncoordinatedWriteError
kw:about
kw:access
kw:access-control
kw:accessibility
kw:accounting
kw:accounting-crawler
kw:add-only
kw:aes
kw:aesthetics
kw:alias
kw:aliases
kw:aliens
kw:allmydata
kw:amazon
kw:ambient
kw:annotations
kw:anonymity
kw:anonymous
kw:anti-censorship
kw:api_auth_token
kw:appearance
kw:appname
kw:apport
kw:archive
kw:archlinux
kw:argparse
kw:arm
kw:assertion
kw:attachment
kw:auth
kw:authentication
kw:automation
kw:avahi
kw:availability
kw:aws
kw:azure
kw:backend
kw:backoff
kw:backup
kw:backupdb
kw:backward-compatibility
kw:bandwidth
kw:basedir
kw:bayes
kw:bbfreeze
kw:beta
kw:binaries
kw:binutils
kw:bitcoin
kw:bitrot
kw:blacklist
kw:blocker
kw:blocks-cloud-deployment
kw:blocks-cloud-merge
kw:blocks-magic-folder-merge
kw:blocks-merge
kw:blocks-raic
kw:blocks-release
kw:blog
kw:bom
kw:bonjour
kw:branch
kw:branding
kw:breadcrumbs
kw:brians-opinion-needed
kw:browser
kw:bsd
kw:build
kw:build-helpers
kw:buildbot
kw:builders
kw:buildslave
kw:buildslaves
kw:cache
kw:cap
kw:capleak
kw:captcha
kw:cast
kw:centos
kw:cffi
kw:chacha
kw:charset
kw:check
kw:checker
kw:chroot
kw:ci
kw:clean
kw:cleanup
kw:cli
kw:cloud
kw:cloud-backend
kw:cmdline
kw:code
kw:code-checks
kw:coding-standards
kw:coding-tools
kw:coding_tools
kw:collection
kw:compatibility
kw:completion
kw:compression
kw:confidentiality
kw:config
kw:configuration
kw:configuration.txt
kw:conflict
kw:connection
kw:connectivity
kw:consistency
kw:content
kw:control
kw:control.furl
kw:convergence
kw:coordination
kw:copyright
kw:corruption
kw:cors
kw:cost
kw:coverage
kw:coveralls
kw:coveralls.io
kw:cpu-watcher
kw:cpyext
kw:crash
kw:crawler
kw:crawlers
kw:create-container
kw:cruft
kw:crypto
kw:cryptography
kw:cryptography-lib
kw:cryptopp
kw:csp
kw:curl
kw:cutoff-date
kw:cycle
kw:cygwin
kw:d3
kw:daemon
kw:darcs
kw:darcsver
kw:database
kw:dataloss
kw:db
kw:dead-code
kw:deb
kw:debian
kw:debug
kw:deep-check
kw:defaults
kw:deferred
kw:delete
kw:deletion
kw:denial-of-service
kw:dependency
kw:deployment
kw:deprecation
kw:desert-island
kw:desert-island-build
kw:design
kw:design-review-needed
kw:detection
kw:dev-infrastructure
kw:devpay
kw:directory
kw:directory-page
kw:dirnode
kw:dirnodes
kw:disconnect
kw:discovery
kw:disk
kw:disk-backend
kw:distribute
kw:distutils
kw:dns
kw:do_http
kw:doc-needed
kw:docker
kw:docs
kw:docs-needed
kw:dokan
kw:dos
kw:download
kw:downloader
kw:dragonfly
kw:drop-upload
kw:duplicity
kw:dusty
kw:earth-dragon
kw:easy
kw:ec2
kw:ecdsa
kw:ed25519
kw:egg-needed
kw:eggs
kw:eliot
kw:email
kw:empty
kw:encoding
kw:endpoint
kw:enterprise
kw:enum34
kw:environment
kw:erasure
kw:erasure-coding
kw:error
kw:escaping
kw:etag
kw:etch
kw:evangelism
kw:eventual
kw:example
kw:excess-authority
kw:exec
kw:exocet
kw:expiration
kw:extensibility
kw:extension
kw:failure
kw:fedora
kw:ffp
kw:fhs
kw:figleaf
kw:file
kw:file-descriptor
kw:filename
kw:filesystem
kw:fileutil
kw:fips
kw:firewall
kw:first
kw:floatingpoint
kw:flog
kw:foolscap
kw:forward-compatibility
kw:forward-secrecy
kw:forwarding
kw:free
kw:freebsd
kw:frontend
kw:fsevents
kw:ftp
kw:ftpd
kw:full
kw:furl
kw:fuse
kw:garbage
kw:garbage-collection
kw:gateway
kw:gatherer
kw:gc
kw:gcc
kw:gentoo
kw:get
kw:git
kw:git-annex
kw:github
kw:glacier
kw:globalcaps
kw:glossary
kw:google-cloud-storage
kw:google-drive-backend
kw:gossip
kw:governance
kw:grid
kw:grid-manager
kw:gridid
kw:gridsync
kw:grsec
kw:gsoc
kw:gvfs
kw:hackfest
kw:hacktahoe
kw:hang
kw:hardlink
kw:heartbleed
kw:heisenbug
kw:help
kw:helper
kw:hint
kw:hooks
kw:how
kw:how-to
kw:howto
kw:hp
kw:hp-cloud
kw:html
kw:http
kw:https
kw:i18n
kw:i2p
kw:i2p-collab
kw:illustration
kw:image
kw:immutable
kw:impressions
kw:incentives
kw:incident
kw:init
kw:inlineCallbacks
kw:inotify
kw:install
kw:installer
kw:integration
kw:integration-test
kw:integrity
kw:interactive
kw:interface
kw:interfaces
kw:interoperability
kw:interstellar-exploration
kw:introducer
kw:introduction
kw:iphone
kw:ipkg
kw:iputil
kw:ipv6
kw:irc
kw:jail
kw:javascript
kw:joke
kw:jquery
kw:json
kw:jsui
kw:junk
kw:key-value-store
kw:kfreebsd
kw:known-issue
kw:konqueror
kw:kpreid
kw:kvm
kw:l10n
kw:lae
kw:large
kw:latency
kw:leak
kw:leasedb
kw:leases
kw:libgmp
kw:license
kw:licenss
kw:linecount
kw:link
kw:linux
kw:lit
kw:localhost
kw:location
kw:locking
kw:logging
kw:logo
kw:loopback
kw:lucid
kw:mac
kw:macintosh
kw:magic-folder
kw:manhole
kw:manifest
kw:manual-test-needed
kw:map
kw:mapupdate
kw:max_space
kw:mdmf
kw:memcheck
kw:memory
kw:memory-leak
kw:mesh
kw:metadata
kw:meter
kw:migration
kw:mime
kw:mingw
kw:minimal
kw:misc
kw:miscapture
kw:mlp
kw:mock
kw:more-info-needed
kw:mountain-lion
kw:move
kw:multi-users
kw:multiple
kw:multiuser-gateway
kw:munin
kw:music
kw:mutability
kw:mutable
kw:mystery
kw:names
kw:naming
kw:nas
kw:navigation
kw:needs-review
kw:needs-spawn
kw:netbsd
kw:network
kw:nevow
kw:new-user
kw:newcaps
kw:news
kw:news-done
kw:news-needed
kw:newsletter
kw:newurls
kw:nfc
kw:nginx
kw:nixos
kw:no-clobber
kw:node
kw:node-url
kw:notification
kw:notifyOnDisconnect
kw:nsa310
kw:nsa320
kw:nsa325
kw:numpy
kw:objects
kw:old
kw:openbsd
kw:openitp-packaging
kw:openssl
kw:openstack
kw:opensuse
kw:operation-helpers
kw:operational
kw:operations
kw:ophandle
kw:ophandles
kw:ops
kw:optimization
kw:optional
kw:options
kw:organization
kw:os
kw:os.abort
kw:ostrom
kw:osx
kw:osxfuse
kw:otf-magic-folder-objective1
kw:otf-magic-folder-objective2
kw:otf-magic-folder-objective3
kw:otf-magic-folder-objective4
kw:otf-magic-folder-objective5
kw:otf-magic-folder-objective6
kw:p2p
kw:packaging
kw:partial
kw:password
kw:path
kw:paths
kw:pause
kw:peer-selection
kw:performance
kw:permalink
kw:permissions
kw:persistence
kw:phone
kw:pickle
kw:pip
kw:pipermail
kw:pkg_resources
kw:placement
kw:planning
kw:policy
kw:port
kw:portability
kw:portal
kw:posthook
kw:pratchett
kw:preformance
kw:preservation
kw:privacy
kw:process
kw:profile
kw:profiling
kw:progress
kw:proxy
kw:publish
kw:pyOpenSSL
kw:pyasn1
kw:pycparser
kw:pycrypto
kw:pycrypto-lib
kw:pycryptopp
kw:pyfilesystem
kw:pyflakes
kw:pylint
kw:pypi
kw:pypy
kw:pysqlite
kw:python
kw:python3
kw:pythonpath
kw:pyutil
kw:pywin32
kw:quickstart
kw:quiet
kw:quotas
kw:quoting
kw:raic
kw:rainhill
kw:random
kw:random-access
kw:range
kw:raspberry-pi
kw:reactor
kw:readonly
kw:rebalancing
kw:recovery
kw:recursive
kw:redhat
kw:redirect
kw:redressing
kw:refactor
kw:referer
kw:referrer
kw:regression
kw:rekey
kw:relay
kw:release
kw:release-blocker
kw:reliability
kw:relnotes
kw:remote
kw:removable
kw:removable-disk
kw:rename
kw:renew
kw:repair
kw:replace
kw:report
kw:repository
kw:research
kw:reserved_space
kw:response-needed
kw:response-time
kw:restore
kw:retrieve
kw:retry
kw:review
kw:review-needed
kw:reviewed
kw:revocation
kw:roadmap
kw:rollback
kw:rpm
kw:rsa
kw:rss
kw:rst
kw:rsync
kw:rusty
kw:s3
kw:s3-backend
kw:s3-frontend
kw:s4
kw:same-origin
kw:sandbox
kw:scalability
kw:scaling
kw:scheduling
kw:schema
kw:scheme
kw:scp
kw:scripts
kw:sdist
kw:sdmf
kw:security
kw:self-contained
kw:server
kw:servermap
kw:servers-of-happiness
kw:service
kw:setup
kw:setup.py
kw:setup_requires
kw:setuptools
kw:setuptools_darcs
kw:sftp
kw:shared
kw:shareset
kw:shell
kw:signals
kw:simultaneous
kw:six
kw:size
kw:slackware
kw:slashes
kw:smb
kw:sneakernet
kw:snowleopard
kw:socket
kw:solaris
kw:space
kw:space-efficiency
kw:spam
kw:spec
kw:speed
kw:sqlite
kw:ssh
kw:ssh-keygen
kw:sshfs
kw:ssl
kw:stability
kw:standards
kw:start
kw:startup
kw:static
kw:static-analysis
kw:statistics
kw:stats
kw:stats_gatherer
kw:status
kw:stdeb
kw:storage
kw:streaming
kw:strports
kw:style
kw:stylesheet
kw:subprocess
kw:sumo
kw:survey
kw:svg
kw:symlink
kw:synchronous
kw:tac
kw:tahoe-*
kw:tahoe-add-alias
kw:tahoe-admin
kw:tahoe-archive
kw:tahoe-backup
kw:tahoe-check
kw:tahoe-cp
kw:tahoe-create-alias
kw:tahoe-create-introducer
kw:tahoe-debug
kw:tahoe-deep-check
kw:tahoe-deepcheck
kw:tahoe-lafs-trac-stream
kw:tahoe-list-aliases
kw:tahoe-ls
kw:tahoe-magic-folder
kw:tahoe-manifest
kw:tahoe-mkdir
kw:tahoe-mount
kw:tahoe-mv
kw:tahoe-put
kw:tahoe-restart
kw:tahoe-rm
kw:tahoe-run
kw:tahoe-start
kw:tahoe-stats
kw:tahoe-unlink
kw:tahoe-webopen
kw:tahoe.css
kw:tahoe_files
kw:tahoewapi
kw:tarball
kw:tarballs
kw:tempfile
kw:templates
kw:terminology
kw:test
kw:test-and-set
kw:test-from-egg
kw:test-needed
kw:testgrid
kw:testing
kw:tests
kw:throttling
kw:ticket999-s3-backend
kw:tiddly
kw:time
kw:timeout
kw:timing
kw:to
kw:to-be-closed-on-2011-08-01
kw:tor
kw:tor-protocol
kw:torsocks
kw:tox
kw:trac
kw:transparency
kw:travis
kw:travis-ci
kw:trial
kw:trickle
kw:trivial
kw:truckee
kw:tub
kw:tub.location
kw:twine
kw:twistd
kw:twistd.log
kw:twisted
kw:twisted-14
kw:twisted-trial
kw:twitter
kw:twn
kw:txaws
kw:type
kw:typeerror
kw:ubuntu
kw:ucwe
kw:ueb
kw:ui
kw:unclean
kw:uncoordinated-writes
kw:undeletable
kw:unfinished-business
kw:unhandled-error
kw:unhappy
kw:unicode
kw:unit
kw:unix
kw:unlink
kw:update
kw:upgrade
kw:upload
kw:upload-helper
kw:uri
kw:url
kw:usability
kw:use-case
kw:utf-8
kw:util
kw:uwsgi
kw:ux
kw:validation
kw:variables
kw:vdrive
kw:verify
kw:verlib
kw:version
kw:versioning
kw:versions
kw:video
kw:virtualbox
kw:virtualenv
kw:vista
kw:visualization
kw:visualizer
kw:vm
kw:volunteergrid2
kw:volunteers
kw:vpn
kw:wapi
kw:warners-opinion-needed
kw:warning
kw:weapi
kw:web
kw:web.port
kw:webapi
kw:webdav
kw:webdrive
kw:webport
kw:websec
kw:website
kw:websocket
kw:welcome
kw:welcome-page
kw:welcomepage
kw:wiki
kw:win32
kw:win64
kw:windows
kw:windows-related
kw:winscp
kw:workaround
kw:world-domination
kw:wrapper
kw:write-enabler
kw:wui
kw:x86
kw:x86-64
kw:xhtml
kw:xml
kw:xss
kw:zbase32
kw:zetuptoolz
kw:zfec
kw:zookos-opinion-needed
kw:zope
kw:zope.interface
p/blocker
p/critical
p/major
p/minor
p/normal
p/supercritical
p/trivial
r/cannot reproduce
r/duplicate
r/fixed
r/invalid
r/somebody else's problem
r/was already fixed
r/wontfix
r/worksforme
t/defect
t/enhancement
t/task
v/0.2.0
v/0.3.0
v/0.4.0
v/0.5.0
v/0.5.1
v/0.6.0
v/0.6.1
v/0.7.0
v/0.8.0
v/0.9.0
v/1.0.0
v/1.1.0
v/1.10.0
v/1.10.1
v/1.10.2
v/1.10a2
v/1.11.0
v/1.12.0
v/1.12.1
v/1.13.0
v/1.14.0
v/1.15.0
v/1.15.1
v/1.2.0
v/1.3.0
v/1.4.1
v/1.5.0
v/1.6.0
v/1.6.1
v/1.7.0
v/1.7.1
v/1.7β
v/1.8.0
v/1.8.1
v/1.8.2
v/1.8.3
v/1.8β
v/1.9.0
v/1.9.0-s3branch
v/1.9.0a1
v/1.9.0a2
v/1.9.0b1
v/1.9.1
v/1.9.2
v/1.9.2a1
v/cloud-branch
v/unknown
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: tahoe-lafs/trac#830
No description provided.