airalab / robonomics_comm

Robonomics communication package stack for ROS-enabled cyber-physical systems
BSD 3-Clause "New" or "Revised" License
19 stars 11 forks source link

Executor ipfs.add returns a list but should dict #8

Closed khssnv closed 6 years ago

khssnv commented 6 years ago

Hi. I use liability node with default launch parameters. On result publishing I've got an exception you may find on a screenshot above. Whats wrong?

image

ipfs version 0.4.15 NixOS 18.09.git.a50a99a

khssnv commented 6 years ago

Can't reproduce. Another try with printing ipfs.add output to log finished fine. image

akru commented 6 years ago

You are free to reopen if you are reproduce it in the future.

khssnv commented 6 years ago

I just got this error again in the same environment. We should check ipfsapi add realization behavior or runtime check what it returns kinda like:

add_output = self.ipfs.add(result_file)
msg.result = add_output['Hash'] if type(add_output) == dict else add_output[0]['Hash']
akru commented 6 years ago

Could you provide ipfs returned values in both cases?

khssnv commented 6 years ago

IPFS API unfolds original provider response from a list to dict if it contains just one item. But if an error occurs while provider proceeding request it returns a list with two item (expected dict and a message dict) even if we add one file. You can see the returned values below. I've open an issue in IPFS API repository, maybe they know a better place for error messages.

No errors (returns dict as expected):

>>> ipfsapi.connect('http://127.0.0.1', 5001).add('./myfile')
{'Name': 'myfile', 'Hash': 'QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH', 'Size': '6'}

With a error (returns a list with error message):

>>> ipfsapi.connect('http://127.0.0.1', 5001).add('./myfile')
[{'Name': 'myfile', 'Hash': 'QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH', 'Size': '6'},
{'Message': 'cannot store pin state: write /var/lib/ipfs/datastore/000014.log: no space left on device', 'Code': 0, 'Type': 'error'}]
khssnv commented 6 years ago

Please consider my PR to prevent liability node crashes in a such situation: https://github.com/airalab/robonomics_comm/pull/12

akru commented 6 years ago

Is stored with error file available on your node? Or we need to store file again?

khssnv commented 6 years ago

If you mean a file I try to add, yes it becomes available by IPFS after adding it. No need to add it again. The only trouble is to get its hash in a proper way.

akru commented 6 years ago

Ok, nice, thanks for your work!