[ 
https://issues.apache.org/jira/browse/LIBCLOUD-90?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tomaz Muraus resolved LIBCLOUD-90.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 0.5.1

> ScriptDeployment fails-slow and swallows errors
> -----------------------------------------------
>
>                 Key: LIBCLOUD-90
>                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-90
>             Project: Libcloud
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 0.5.0
>            Reporter: Paul Oswald
>            Priority: Minor
>             Fix For: 0.5.1
>
>
> If you create a ScriptDeployment object by passing in a file instead of a 
> str, and then pass that to deploy_node you get a failure with an unhelpful 
> message. There are a few problems here: 1.) the ScriptDeployment should 
> ensure that the arguments are in a format it can handle on __init__ before it 
> gets to run when it's too late and the node has already been created. 2.) an 
> error in this part of the code will throw an exception that will be caught, 
> swallowed and re-thrown as a DeploymentError without any indication of the 
> underlying problem 3.) the ScriptDeployment could be improved by allowing it 
> to handle a file type object by just calling file.read() on it.
> You can reproduce this by doing something like this:
>     script = ScriptDeployment(open("/".join([root, "bin", 
> os.path.expanduser("bootstrap.sh")])))
>     node = cloud.deploy_node(name="test-name", image=69, size=1, 
> deploy=script)    
> To fix it, you just need to do this:
>     script = ScriptDeployment(open("/".join([root, "bin", 
> os.path.expanduser("bootstrap.sh")])).read())
> The underlying stack trace thrown from paramiko when you send in a file is:
>     Traceback (most recent call last):
>       File 
> "/Users/poswald/.virtualenvs/myproj/lib/python2.6/site-packages/fabric/main.py",
>  line 551, in main
>         commands[name](*args, **kwargs)
>       File "/Users/poswald/Projects/hats/fabfile.py", line 289, in provision
>         node = cloud.deploy_node(name=name, image=image, size=size, 
> deploy=script, ssh_timeout=300)
>       File 
> "/Users/poswald/.virtualenvs/myproj/lib/python2.6/site-packages/libcloud/compute/base.py",
>  line 564, in deploy_node
>         n = kwargs["deploy"].run(node, client)
>       File 
> "/Users/poswald/.virtualenvs/myproj/lib/python2.6/site-packages/libcloud/compute/deployment.py",
>  line 94, in run
>         client.put(path=self.name, chmod=755, contents=self.script)
>       File 
> "/Users/poswald/.virtualenvs/myproj/lib/python2.6/site-packages/libcloud/compute/ssh.py",
>  line 158, in put
>         ak.write(contents)
>       File 
> "/Users/poswald/.virtualenvs/myproj/lib/python2.6/site-packages/paramiko/file.py",
>  line 314, in write
>         self._write_all(data)
>       File 
> "/Users/poswald/.virtualenvs/myproj/lib/python2.6/site-packages/paramiko/file.py",
>  line 434, in _write_all
>         while len(data) > 0:
>     TypeError: object of type 'file' has no len()
> The relevant code is in 
> https://github.com/apache/libcloud/blob/trunk/libcloud/compute/base.py#L564

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to