Mercurial > bitten > bitten-test
comparison bitten/master.py @ 284:ddc93fe34cad
Fix a bug in the build master (introduced in [289]) where multiple slaves matching the same target platform would potentially start the same build. This is done by setting the build to `IN_PROGRESS` as soon as the build initiation is sent, as opposed to when the slave accepts the build request.
author | cmlenz |
---|---|
date | Fri, 14 Oct 2005 21:12:45 +0000 |
parents | 33625fa61d6c |
children | 6abd43d0cd8a |
comparison
equal
deleted
inserted
replaced
282:3950b8141e85 | 284:ddc93fe34cad |
---|---|
145 self.channel.send_rpy(msgno, beep.Payload(xml)) | 145 self.channel.send_rpy(msgno, beep.Payload(xml)) |
146 | 146 |
147 def send_initiation(self, queue, build): | 147 def send_initiation(self, queue, build): |
148 log.info('Initiating build of "%s" on slave %s', build.config, | 148 log.info('Initiating build of "%s" on slave %s', build.config, |
149 self.name) | 149 self.name) |
150 | |
151 build.slave = self.name | |
152 build.slave_info.update(self.info) | |
153 build.status = Build.IN_PROGRESS | |
154 build.update() | |
150 self.building = True | 155 self.building = True |
156 | |
151 config = BuildConfig.fetch(queue.env, build.config) | 157 config = BuildConfig.fetch(queue.env, build.config) |
152 | 158 |
153 def handle_reply(cmd, msgno, ansno, payload): | 159 def handle_reply(cmd, msgno, ansno, payload): |
154 if cmd == 'ERR': | 160 if cmd == 'ERR': |
155 if payload.content_type == beep.BEEP_XML: | 161 if payload.content_type == beep.BEEP_XML: |
157 if elem.name == 'error': | 163 if elem.name == 'error': |
158 log.warning('Slave %s refused build request: %s (%d)', | 164 log.warning('Slave %s refused build request: %s (%d)', |
159 self.name, elem.gettext(), | 165 self.name, elem.gettext(), |
160 int(elem.attr['code'])) | 166 int(elem.attr['code'])) |
161 self.building = False | 167 self.building = False |
168 self._build_aborted(queue, build) | |
162 return | 169 return |
163 | 170 |
164 elem = xmlio.parse(payload.body) | 171 elem = xmlio.parse(payload.body) |
165 if elem.name != 'proceed': | 172 if elem.name != 'proceed': |
166 raise beep.ProtocolError(500) | 173 raise beep.ProtocolError(500) |
210 if elem.name == 'error': | 217 if elem.name == 'error': |
211 log.warning('Slave %s refused to start build: %s (%d)', | 218 log.warning('Slave %s refused to start build: %s (%d)', |
212 self.name, elem.gettext(), | 219 self.name, elem.gettext(), |
213 int(elem.attr['code'])) | 220 int(elem.attr['code'])) |
214 self.building = False | 221 self.building = False |
222 self._build_aborted(queue, build) | |
215 | 223 |
216 elif cmd == 'ANS': | 224 elif cmd == 'ANS': |
217 if payload.content_type != beep.BEEP_XML: | 225 if payload.content_type != beep.BEEP_XML: |
218 raise beep.ProtocolError(500) | 226 raise beep.ProtocolError(500) |
219 elem = xmlio.parse(payload.body) | 227 elem = xmlio.parse(payload.body) |
237 content_type='application/zip', | 245 content_type='application/zip', |
238 content_disposition=snapshot_name) | 246 content_disposition=snapshot_name) |
239 self.channel.send_msg(message, handle_reply=handle_reply) | 247 self.channel.send_msg(message, handle_reply=handle_reply) |
240 | 248 |
241 def _build_started(self, queue, build, elem, timestamp_delta=None): | 249 def _build_started(self, queue, build, elem, timestamp_delta=None): |
242 build.slave = self.name | |
243 build.slave_info.update(self.info) | |
244 build.started = int(_parse_iso_datetime(elem.attr['time'])) | 250 build.started = int(_parse_iso_datetime(elem.attr['time'])) |
245 if timestamp_delta: | 251 if timestamp_delta: |
246 build.started -= timestamp_delta | 252 build.started -= timestamp_delta |
247 build.status = Build.IN_PROGRESS | |
248 build.update() | 253 build.update() |
249 | 254 |
250 log.info('Slave %s started build %d ("%s" as of [%s])', | 255 log.info('Slave %s started build %d ("%s" as of [%s])', |
251 self.name, build.id, build.config, build.rev) | 256 self.name, build.id, build.config, build.rev) |
252 for listener in BuildSystem(queue.env).listeners: | 257 for listener in BuildSystem(queue.env).listeners: |