Rebase: p/opnfv-fuel: Allow Fuel commit override.
[armband.git] / patches / opnfv-fuel / 0010-deployment.py-stdout-not-consumed-when-deploying-cha.patch
1 From: Josep Puigdemont <josep.puigdemont@enea.com>
2 Date: Wed, 4 May 2016 14:27:23 +0200
3 Subject: [PATCH] deployment.py: stdout not consumed when deploying changes
4
5 During the automatic deployment, when the environment is ready to be
6 deployed, the deploy.py script will spawn a shell process that will
7 perform the command "fuel deploy-changes". The standard output of this
8 process is then piped to a "tee" process, which redirects the output
9 to the standard output of the shell process, and to a file named
10 cloud.log. The file is monitored by the deploy script to find out the
11 status of the deployment, and print it to the log file of the automatic
12 deployment script, including percentages for each node being
13 provisioned. However, the deploy script never consumes the standard
14 output of the shell process. If the shell process produces enough
15 output, its standard output buffer will fill up, thus making the tee
16 process block trying to write to its standard output, and the cloud.log
17 file will not be updated. At this point, the deploy process, which is
18 monitoring cloud.log, will not detect any progress in the deployment,
19 and eventually it will time out and assume the deployment failed,
20 although it might have finished fine after that.
21
22 The solution here is to remove the "tee" process from the shell command,
23 and instead redirect standard output to the cloud.log file.
24 Another solution would be to actually parse the standard output of the
25 shell command from the deploy script itself, but that would require a
26 bit more work, as reading a line at a time might block the script.
27
28 Finally, with this patch the cloud.log file won't be deleted unless the
29 shell process has already finished.
30
31 Change-Id: I03a77be42d220b1606e48fc4ca35e22d73a6e583
32 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
33 ---
34  deploy/cloud/deployment.py | 12 +++++++++---
35  1 file changed, 9 insertions(+), 3 deletions(-)
36
37 diff --git a/deploy/cloud/deployment.py b/deploy/cloud/deployment.py
38 index 306abf0..0127d2a 100644
39 --- a/deploy/cloud/deployment.py
40 +++ b/deploy/cloud/deployment.py
41 @@ -101,8 +101,8 @@ class Deployment(object):
42          LOG_FILE = 'cloud.log'
43  
44          log('Starting deployment of environment %s' % self.env_id)
45 -        run_proc('fuel --env %s deploy-changes | strings | tee %s'
46 -                 % (self.env_id, LOG_FILE))
47 +        p = run_proc('fuel --env %s deploy-changes | strings > %s'
48 +                     % (self.env_id, LOG_FILE))
49  
50          ready = False
51          for i in range(int(self.deploy_timeout)):
52 @@ -119,7 +119,13 @@ class Deployment(object):
53                  break
54              else:
55                  time.sleep(SLEEP_TIME)
56 -        delete(LOG_FILE)
57 +
58 +        p.poll()
59 +        if p.returncode == None:
60 +            log('The process deploying the changes has not yet finished.')
61 +            log('''The file %s won't be deleted''' % LOG_FILE)
62 +        else:
63 +            delete(LOG_FILE)
64  
65          if ready:
66              log('Environment %s successfully deployed' % self.env_id)