|
145 | 145 | LOG = log.getLogger(__name__)
|
146 | 146 |
|
147 | 147 | MAX_BIND_TRIES = 10
|
| 148 | +MAX_PROVISIONING_TRIES = MAX_BIND_TRIES |
148 | 149 |
|
149 | 150 |
|
150 | 151 | SERVICE_PLUGINS_REQUIRED_DRIVERS = {
|
@@ -331,37 +332,55 @@ def _filter_extensions_by_mech_driver(self, aliases):
|
331 | 332 | [provisioning_blocks.PROVISIONING_COMPLETE])
|
332 | 333 | def _port_provisioned(self, rtype, event, trigger, payload=None):
|
333 | 334 | port_id = payload.resource_id
|
334 |
| - port = db.get_port(payload.context, port_id) |
335 |
| - port_binding = p_utils.get_port_binding_by_status_and_host( |
336 |
| - getattr(port, 'port_bindings', []), const.ACTIVE) |
337 |
| - if not port or not port_binding: |
338 |
| - LOG.debug("Port %s was deleted so its status cannot be updated.", |
339 |
| - port_id) |
340 |
| - return |
341 |
| - if port_binding.vif_type in (portbindings.VIF_TYPE_BINDING_FAILED, |
342 |
| - portbindings.VIF_TYPE_UNBOUND): |
343 |
| - # NOTE(kevinbenton): we hit here when a port is created without |
344 |
| - # a host ID and the dhcp agent notifies that its wiring is done |
345 |
| - LOG.debug("Port %s cannot update to ACTIVE because it " |
346 |
| - "is not bound.", port_id) |
347 |
| - return |
348 |
| - else: |
349 |
| - # port is bound, but we have to check for new provisioning blocks |
350 |
| - # one last time to detect the case where we were triggered by an |
351 |
| - # unbound port and the port became bound with new provisioning |
352 |
| - # blocks before 'get_port' was called above |
353 |
| - if provisioning_blocks.is_object_blocked(payload.context, port_id, |
354 |
| - resources.PORT): |
355 |
| - LOG.debug("Port %s had new provisioning blocks added so it " |
356 |
| - "will not transition to active.", port_id) |
| 335 | + for count in range(1, MAX_PROVISIONING_TRIES + 1): |
| 336 | + LOG.info('Attempt %(count)s to provision port %(port)s', |
| 337 | + {'count': count, 'port': port_id}) |
| 338 | + port = db.get_port(payload.context, port_id) |
| 339 | + port_bindings = getattr(port, 'port_bindings', []) |
| 340 | + port_binding = p_utils.get_port_binding_by_status_and_host( |
| 341 | + port_bindings, const.ACTIVE) |
| 342 | + |
| 343 | + if not port or not port_binding: |
| 344 | + LOG.debug("Port %s was deleted so its status cannot be " |
| 345 | + "updated.", port_id) |
357 | 346 | return
|
| 347 | + |
| 348 | + if port_binding.vif_type == portbindings.VIF_TYPE_BINDING_FAILED: |
| 349 | + LOG.debug('Port %s cannot update to ACTIVE because it failed.', |
| 350 | + port_id) |
| 351 | + return |
| 352 | + |
| 353 | + if port_binding.vif_type == portbindings.VIF_TYPE_UNBOUND: |
| 354 | + # NOTE(kevinbenton): we hit here when a port is created without |
| 355 | + # a host ID and the dhcp agent notifies that its wiring is done |
| 356 | + LOG.debug('Port %s cannot update to ACTIVE because it ' |
| 357 | + 'is not bound.', port_id) |
| 358 | + if count == MAX_PROVISIONING_TRIES: |
| 359 | + return |
| 360 | + |
| 361 | + # Wait 0.5 seconds before checking again if the port is bound. |
| 362 | + # We could hit this during a live-migration. |
| 363 | + greenthread.sleep(0.5) |
| 364 | + continue |
| 365 | + |
| 366 | + break |
| 367 | + |
| 368 | + # port is bound, but we have to check for new provisioning blocks |
| 369 | + # one last time to detect the case where we were triggered by an |
| 370 | + # unbound port and the port became bound with new provisioning |
| 371 | + # blocks before 'get_port' was called above |
| 372 | + if provisioning_blocks.is_object_blocked(payload.context, port_id, |
| 373 | + resources.PORT): |
| 374 | + LOG.debug("Port %s had new provisioning blocks added so it " |
| 375 | + "will not transition to active.", port_id) |
| 376 | + return |
| 377 | + |
358 | 378 | if not port.admin_state_up:
|
359 | 379 | LOG.debug("Port %s is administratively disabled so it will "
|
360 | 380 | "not transition to active.", port_id)
|
361 | 381 | return
|
362 | 382 |
|
363 |
| - host_migrating = agent_rpc.migrating_to_host( |
364 |
| - getattr(port, 'port_bindings', [])) |
| 383 | + host_migrating = agent_rpc.migrating_to_host(port_bindings) |
365 | 384 | if (host_migrating and cfg.CONF.nova.live_migration_events and
|
366 | 385 | self.nova_notifier):
|
367 | 386 | send_nova_event = bool(trigger ==
|
|
0 commit comments