Merge "Fix postgresql database creation failures from prepare func"

This commit is contained in:
Zuul 2023-08-04 05:28:09 +00:00 committed by Gerrit Code Review
commit 651cee350f
3 changed files with 11 additions and 4 deletions

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Fix potential PostgreSQL database creation failures from the instance create API

View File

@ -201,6 +201,8 @@ common_opts = [
'change.'),
cfg.IntOpt('state_change_poll_time', default=3,
help='Interval between state change poll requests (seconds).'),
cfg.IntOpt('state_healthy_counts', default=5,
help='consecutive success db connections for status HEALTHY'),
cfg.IntOpt('agent_heartbeat_time', default=10,
help='Maximum time (in seconds) for the Guest Agent to reply '
'to a heartbeat request.'),

View File

@ -290,15 +290,15 @@ class BaseDbStatus(object):
# outside.
loop = True
# We need 3 (by default) consecutive success db connections for status
# We need 5 (by default) consecutive success db connections for status
# 'HEALTHY'
healthy_count = 0
state_healthy_counts = CONF.state_healthy_counts - 1
while loop:
self.status = self.get_actual_db_status()
if self.status == status:
if (status == service_status.ServiceStatuses.HEALTHY and
healthy_count < 2):
healthy_count < state_healthy_counts):
healthy_count += 1
time.sleep(CONF.state_change_poll_time)
continue
@ -310,7 +310,8 @@ class BaseDbStatus(object):
# should we remain in this loop? this is the thing
# that emulates the do-while construct.
loop = (time.time() < end_time)
# reset the healthy_count
healthy_count = 0
# no point waiting if our time is up and we're
# just going to error out anyway.
if loop: