Merge lp:~gandelman-a/ubuntu/oneiric/swift/lp836922 into lp:~ubuntu-server-dev/swift/diablo

Proposed by Adam Gandelman
Status: Merged
Merged at revision: 51
Proposed branch: lp:~gandelman-a/ubuntu/oneiric/swift/lp836922
Merge into: lp:~ubuntu-server-dev/swift/diablo
Diff against target: 278 lines (+261/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/backport-change-swift-ring-builder-exit-codes (+253/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~gandelman-a/ubuntu/oneiric/swift/lp836922
Reviewer Review Type Date Requested Status
Chuck Short Pending
Review via email: mp+77582@code.launchpad.net

Description of the change

This patch makes swift-ring-builder exit with standard return codes (ie, 0 == success) which will make maintenance of juju charms and any other user scripts easier to maintain and later essex upgrades less painful.

To post a comment you must log in.
52. By Adam Gandelman

Update release tag to 'UNRELEASED'

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-09-22 15:41:07 +0000
3+++ debian/changelog 2011-09-29 21:53:23 +0000
4@@ -1,3 +1,10 @@
5+swift (1.4.3-0ubuntu2) UNRELEASED; urgency=low
6+
7+ * debian/patches/backport-change-swift-ring-builder-exit-codes: Standardize
8+ exit codes now to reduce hassles after future upgrades (LP: #836922)
9+
10+ -- Adam Gandelman <adamg@canonical.com> Thu, 29 Sep 2011 11:14:46 -0700
11+
12 swift (1.4.3-0ubuntu1) oneiric; urgency=low
13
14 [Chuck Short]
15
16=== added file 'debian/patches/backport-change-swift-ring-builder-exit-codes'
17--- debian/patches/backport-change-swift-ring-builder-exit-codes 1970-01-01 00:00:00 +0000
18+++ debian/patches/backport-change-swift-ring-builder-exit-codes 2011-09-29 21:53:23 +0000
19@@ -0,0 +1,253 @@
20+Description: Changes swift-ring-builder exit codes
21+Author: Mark Gius <launchpad@markgius.com>
22+Status: Merged upstream
23+Commit: 1ad31af887cd6cdda180239e732f7eb6da8e301b
24+Origin: https://github.com/openstack/swift/commit/1ad31af887cd6cdda180239e732f7eb6da8e301b
25+Bug: LP #836922
26+diff --git a/bin/swift-ring-builder b/bin/swift-ring-builder
27+index 787a251..7522ea6 100755
28+--- a/bin/swift-ring-builder
29++++ b/bin/swift-ring-builder
30+@@ -1,4 +1,4 @@
31+-#!/usr/bin/python -uO
32++#! /usr/bin/env python
33+ # Copyright (c) 2010-2011 OpenStack, LLC.
34+ #
35+ # Licensed under the Apache License, Version 2.0 (the "License");
36+@@ -28,9 +28,9 @@ from swift.common.ring import RingBuilder
37+
38+
39+ MAJOR_VERSION = 1
40+-MINOR_VERSION = 2
41+-EXIT_RING_CHANGED = 0
42+-EXIT_RING_UNCHANGED = 1
43++MINOR_VERSION = 3
44++EXIT_SUCCESS = 0
45++EXIT_WARNING = 1
46+ EXIT_ERROR = 2
47+
48+
49+@@ -146,7 +146,7 @@ swift-ring-builder <builder_file> create <part_power> <replicas>
50+ """
51+ if len(argv) < 6:
52+ print Commands.create.__doc__.strip()
53+- exit(EXIT_RING_UNCHANGED)
54++ exit(EXIT_ERROR)
55+ builder = RingBuilder(int(argv[3]), int(argv[4]), int(argv[5]))
56+ backup_dir = pathjoin(dirname(argv[1]), 'backups')
57+ try:
58+@@ -157,7 +157,7 @@ swift-ring-builder <builder_file> create <part_power> <replicas>
59+ pickle.dump(builder.to_dict(), open(pathjoin(backup_dir,
60+ '%d.' % time() + basename(argv[1])), 'wb'), protocol=2)
61+ pickle.dump(builder.to_dict(), open(argv[1], 'wb'), protocol=2)
62+- exit(EXIT_RING_CHANGED)
63++ exit(EXIT_SUCCESS)
64+
65+ def default():
66+ """
67+@@ -195,7 +195,7 @@ swift-ring-builder <builder_file>
68+ (dev['id'], dev['zone'], dev['ip'], dev['port'],
69+ dev['device'], dev['weight'], dev['parts'], balance,
70+ dev['meta'])
71+- exit(EXIT_RING_UNCHANGED)
72++ exit(EXIT_SUCCESS)
73+
74+ def search():
75+ """
76+@@ -206,7 +206,7 @@ swift-ring-builder <builder_file> search <search-value>
77+ print Commands.search.__doc__.strip()
78+ print
79+ print search_devs.__doc__.strip()
80+- exit(EXIT_RING_UNCHANGED)
81++ exit(EXIT_ERROR)
82+ devs = search_devs(builder, argv[3])
83+ if not devs:
84+ print 'No matching devices found'
85+@@ -228,7 +228,7 @@ swift-ring-builder <builder_file> search <search-value>
86+ (dev['id'], dev['zone'], dev['ip'], dev['port'],
87+ dev['device'], dev['weight'], dev['parts'], balance,
88+ dev['meta'])
89+- exit(EXIT_RING_UNCHANGED)
90++ exit(EXIT_SUCCESS)
91+
92+ def list_parts():
93+ """
94+@@ -244,7 +244,7 @@ swift-ring-builder <builder_file> list_parts <search-value> [<search-value>] ..
95+ print Commands.list_parts.__doc__.strip()
96+ print
97+ print search_devs.__doc__.strip()
98+- exit(EXIT_RING_UNCHANGED)
99++ exit(EXIT_ERROR)
100+ devs = []
101+ for arg in argv[3:]:
102+ devs.extend(search_devs(builder, arg) or [])
103+@@ -262,7 +262,7 @@ swift-ring-builder <builder_file> list_parts <search-value> [<search-value>] ..
104+ for index, parts in enumerate(matches):
105+ for part in parts:
106+ print '%9d %7d' % (part, builder.replicas - index)
107+- exit(EXIT_RING_UNCHANGED)
108++ exit(EXIT_SUCCESS)
109+
110+ def add():
111+ """
112+@@ -274,7 +274,7 @@ swift-ring-builder <builder_file> add z<zone>-<ip>:<port>/<device_name>_<meta>
113+ """
114+ if len(argv) < 5:
115+ print Commands.add.__doc__.strip()
116+- exit(EXIT_RING_UNCHANGED)
117++ exit(EXIT_ERROR)
118+
119+ if not argv[3].startswith('z'):
120+ print 'Invalid add value: %s' % argv[3]
121+@@ -348,7 +348,7 @@ swift-ring-builder <builder_file> add z<zone>-<ip>:<port>/<device_name>_<meta>
122+ print 'Device z%s-%s:%s/%s_"%s" with %s weight got id %s' % \
123+ (zone, ip, port, device_name, meta, weight, next_dev_id)
124+ pickle.dump(builder.to_dict(), open(argv[1], 'wb'), protocol=2)
125+- exit(EXIT_RING_UNCHANGED)
126++ exit(EXIT_SUCCESS)
127+
128+ def set_weight():
129+ """
130+@@ -361,7 +361,7 @@ swift-ring-builder <builder_file> set_weight <search-value> <weight>
131+ print Commands.set_weight.__doc__.strip()
132+ print
133+ print search_devs.__doc__.strip()
134+- exit(EXIT_RING_UNCHANGED)
135++ exit(EXIT_ERROR)
136+ devs = search_devs(builder, argv[3])
137+ weight = float(argv[4])
138+ if not devs:
139+@@ -381,7 +381,7 @@ swift-ring-builder <builder_file> set_weight <search-value> <weight>
140+ print 'd%(id)sz%(zone)s-%(ip)s:%(port)s/%(device)s_"%(meta)s" ' \
141+ 'weight set to %(weight)s' % dev
142+ pickle.dump(builder.to_dict(), open(argv[1], 'wb'), protocol=2)
143+- exit(EXIT_RING_UNCHANGED)
144++ exit(EXIT_SUCCESS)
145+
146+ def set_info():
147+ """
148+@@ -398,7 +398,7 @@ swift-ring-builder <builder_file> set_info <search-value>
149+ print Commands.set_info.__doc__.strip()
150+ print
151+ print search_devs.__doc__.strip()
152+- exit(EXIT_RING_UNCHANGED)
153++ exit(EXIT_ERROR)
154+ devs = search_devs(builder, argv[3])
155+ change_value = argv[4]
156+ change = []
157+@@ -463,7 +463,7 @@ swift-ring-builder <builder_file> set_info <search-value>
158+ dev[key] = value
159+ print 'Device %s is now %s' % (orig_dev_string, format_device(dev))
160+ pickle.dump(builder.to_dict(), open(argv[1], 'wb'), protocol=2)
161+- exit(EXIT_RING_UNCHANGED)
162++ exit(EXIT_SUCCESS)
163+
164+ def remove():
165+ """
166+@@ -479,7 +479,7 @@ swift-ring-builder <builder_file> remove <search-value>
167+ print Commands.remove.__doc__.strip()
168+ print
169+ print search_devs.__doc__.strip()
170+- exit(EXIT_RING_UNCHANGED)
171++ exit(EXIT_ERROR)
172+ devs = search_devs(builder, argv[3])
173+ if not devs:
174+ print 'No matching devices found'
175+@@ -499,7 +499,7 @@ swift-ring-builder <builder_file> remove <search-value>
176+ 'marked for removal and will be removed next rebalance.' \
177+ % dev
178+ pickle.dump(builder.to_dict(), open(argv[1], 'wb'), protocol=2)
179+- exit(EXIT_RING_UNCHANGED)
180++ exit(EXIT_SUCCESS)
181+
182+ def rebalance():
183+ """
184+@@ -514,14 +514,15 @@ swift-ring-builder <builder_file> rebalance
185+ print 'No partitions could be reassigned.'
186+ print 'Either none need to be or none can be due to ' \
187+ 'min_part_hours [%s].' % builder.min_part_hours
188+- exit(EXIT_RING_UNCHANGED)
189++ exit(EXIT_WARNING)
190+ if not devs_changed and abs(last_balance - balance) < 1:
191+ print 'Cowardly refusing to save rebalance as it did not change ' \
192+ 'at least 1%.'
193+- exit(EXIT_RING_UNCHANGED)
194++ exit(EXIT_WARNING)
195+ builder.validate()
196+ print 'Reassigned %d (%.02f%%) partitions. Balance is now %.02f.' % \
197+ (parts, 100.0 * parts / builder.parts, balance)
198++ status = EXIT_SUCCESS
199+ if balance > 5:
200+ print '-' * 79
201+ print 'NOTE: Balance of %.02f indicates you should push this ' % \
202+@@ -529,6 +530,7 @@ swift-ring-builder <builder_file> rebalance
203+ print ' ring, wait at least %d hours, and rebalance/repush.' \
204+ % builder.min_part_hours
205+ print '-' * 79
206++ status = EXIT_WARNING
207+ ts = time()
208+ pickle.dump(builder.get_ring().to_dict(),
209+ GzipFile(pathjoin(backup_dir, '%d.' % ts +
210+@@ -538,7 +540,7 @@ swift-ring-builder <builder_file> rebalance
211+ pickle.dump(builder.get_ring().to_dict(), GzipFile(ring_file, 'wb'),
212+ protocol=2)
213+ pickle.dump(builder.to_dict(), open(argv[1], 'wb'), protocol=2)
214+- exit(EXIT_RING_CHANGED)
215++ exit(status)
216+
217+ def validate():
218+ """
219+@@ -546,7 +548,7 @@ swift-ring-builder <builder_file> validate
220+ Just runs the validation routines on the ring.
221+ """
222+ builder.validate()
223+- exit(EXIT_RING_UNCHANGED)
224++ exit(EXIT_SUCCESS)
225+
226+ def write_ring():
227+ """
228+@@ -568,12 +570,12 @@ swift-ring-builder <builder_file> write_ring
229+ GzipFile(pathjoin(backup_dir, '%d.' % time() +
230+ basename(ring_file)), 'wb'), protocol=2)
231+ pickle.dump(ring_data.to_dict(), GzipFile(ring_file, 'wb'), protocol=2)
232+- exit(EXIT_RING_CHANGED)
233++ exit(EXIT_SUCCESS)
234+
235+ def pretend_min_part_hours_passed():
236+ builder.pretend_min_part_hours_passed()
237+ pickle.dump(builder.to_dict(), open(argv[1], 'wb'), protocol=2)
238+- exit(EXIT_RING_UNCHANGED)
239++ exit(EXIT_SUCCESS)
240+
241+ def set_min_part_hours():
242+ """
243+@@ -584,12 +586,12 @@ swift-ring-builder <builder_file> set_min_part_hours <hours>
244+ """
245+ if len(argv) < 4:
246+ print Commands.set_min_part_hours.__doc__.strip()
247+- exit(EXIT_RING_UNCHANGED)
248++ exit(EXIT_ERROR)
249+ builder.change_min_part_hours(int(argv[3]))
250+ print 'The minimum number of hours before a partition can be ' \
251+ 'reassigned is now set to %s' % argv[3]
252+ pickle.dump(builder.to_dict(), open(argv[1], 'wb'), protocol=2)
253+- exit(EXIT_RING_UNCHANGED)
254++ exit(EXIT_SUCCESS)
255+
256+
257+ if __name__ == '__main__':
258+@@ -609,9 +611,11 @@ if __name__ == '__main__':
259+ for line in wrap(' '.join(cmds), 79, initial_indent='Quick list: ',
260+ subsequent_indent=' '):
261+ print line
262+- print 'Exit codes: 0 = ring changed, 1 = ring did not change, ' \
263+- '2 = error'
264+- exit(EXIT_RING_UNCHANGED)
265++ print ('Exit codes: 0 = operation successful\n'
266++ ' 1 = operation completed with warnings\n' \
267++ ' 2 = error'
268++ )
269++ exit(EXIT_SUCCESS)
270+
271+ if exists(argv[1]):
272+ try:
273
274=== added file 'debian/patches/series'
275--- debian/patches/series 1970-01-01 00:00:00 +0000
276+++ debian/patches/series 2011-09-29 21:53:23 +0000
277@@ -0,0 +1,1 @@
278+backport-change-swift-ring-builder-exit-codes

Subscribers

People subscribed via source and target branches