Create host state for determing initial inventory complete

Add host inv_state attribute to allow determination of when the
initial inventory collection has been completed.

Update references which were using disks/pvs as proxy for inventory
completion to reference the host inv_state attribute.

Description of issue (from Bug 1837097):
The system inventory agent needs to explicitly indicate that inventory
collection has finished for each host.  The current method for
determining whether a host has been inventoried successfully is to
wait for the disk/pv list to be non-empty.

That worked well until recently when the host file system feature
was merged.  The system inventory agent now collects/creates host file
systems after the disk list is populated so a provisioning system
waiting on the disk list will move ahead to unlock the  node
prematurely before the host file systems have been created and reported
to system inventory.  This can lead to undefined behavior either on
the system being provisioned or the provisioning system that is
configuring the target system.

If we do not fix this properly with an explicit/deterministic flag then
we will trip over this issue each time someone adds a new inventory
collection step to the end of the system inventory agent's
initial process loop.

Change-Id: Ibe590055a3e2c6b312a92c1afc445f7c14d87e2f
Closes-bug: 1837097
Depends-On: https://review.opendev.org/#/c/672772/
Signed-off-by: John Kung <john.kung@windriver.com>
This commit is contained in:
John Kung 2019-07-25 10:35:22 -04:00
parent a6540a3593
commit e517877188
2 changed files with 11 additions and 35 deletions

View File

@ -1,2 +1,2 @@
SRC_DIR="src"
TIS_PATCH_VER=4
TIS_PATCH_VER=5

View File

@ -832,51 +832,27 @@ def populate_controller_config(client):
return controller
def wait_disk_config(client, host):
count = 0
def wait_initial_inventory_complete(client, host):
for _ in range(constants.SYSTEM_CONFIG_TIMEOUT / 10):
try:
disks = client.sysinv.idisk.list(host.uuid)
if disks and count == len(disks):
return disks
count = len(disks)
host = client.sysinv.ihost.get('controller-0')
if host and (host.inv_state ==
sysinv_constants.INV_STATE_INITIAL_INVENTORIED):
return host
except Exception:
pass
if disks:
time.sleep(1) # We don't need to wait that long
else:
time.sleep(10)
time.sleep(10)
else:
raise ConfigFail('Timeout waiting for controller disk '
'configuration')
def wait_pv_config(client, host):
count = 0
for _ in range(constants.SYSTEM_CONFIG_TIMEOUT / 10):
try:
pvs = client.sysinv.ipv.list(host.uuid)
if pvs and count == len(pvs):
return pvs
count = len(pvs)
except Exception:
pass
if pvs:
time.sleep(1) # We don't need to wait that long
else:
time.sleep(10)
else:
raise ConfigFail('Timeout waiting for controller PV '
'configuration')
raise ConfigFail('Timeout waiting for controller inventory '
'completion')
def inventory_config_complete_wait(client, controller):
# Wait for sysinv-agent to populate disks and PVs
# Wait for sysinv-agent to populate initial inventory
if not INITIAL_POPULATION:
return
wait_disk_config(client, controller)
wait_pv_config(client, controller)
wait_initial_inventory_complete(client, controller)
def populate_default_storage_backend(client, controller):