Fix 'dictionary changed size during iteration'
The Python "RuntimeError: dictionary changed size during iteration" has been seen on some points, e.g. when creating a strategy. It occurs when the size of a dictionary is changed during iterating over it. To fix this error is needed to add a '.copy()' method to create a shallow copy of the dictionary. Test Plan: PASS: Apply these changes and create a strategy. Verify the strategy is being created successfully. Same test has been done for other sections. Closes-Bug: 1999069 Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com> Change-Id: I3f6dc0e27547d6439a2d14e9ba8ee6dd4f68e8be
This commit is contained in:
parent
e2c5d33fab
commit
40679dc464
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2013-2020 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2022 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -726,7 +726,7 @@ class UpdateiStoragePools(forms.SelfHandlingForm):
|
||||
STORAGE_VALUES['object_pool_gib'] = \
|
||||
str(storage_config._object_pool_gib)
|
||||
|
||||
for key in data.keys():
|
||||
for key in data.copy().keys():
|
||||
data[key] = str(data[key])
|
||||
|
||||
LOG.info("initial send_to_sysinv=%s", send_to_sysinv)
|
||||
|
@ -222,7 +222,7 @@ class CreateCloudStrategyForm(forms.SelfHandlingForm):
|
||||
def handle(self, request, data):
|
||||
try:
|
||||
# convert keys to use dashes
|
||||
for k in data.keys():
|
||||
for k in data.copy().keys():
|
||||
if 'subcloud_group' in k or 'cloud_name' in k:
|
||||
continue
|
||||
elif '_' in k:
|
||||
@ -340,7 +340,7 @@ class CreateCloudPatchConfigForm(forms.SelfHandlingForm):
|
||||
|
||||
def handle(self, request, data):
|
||||
try:
|
||||
for k in data.keys():
|
||||
for k in data.copy().keys():
|
||||
if '_' in k:
|
||||
data[k.replace('_', '-')] = data[k]
|
||||
del data[k]
|
||||
|
Loading…
Reference in New Issue
Block a user