[mariadb] Remove useless retries on conflics during cm update
The retries were originally added at [0] but they were never working. We pass fixed revision that we would like to see during patch to avoid race condition, into the safe_update_configmap. We can't organize retries inside function as it will require change of the original revision which may happen only at upper layer. Revert patch partially. [0] https://review.opendev.org/c/openstack/openstack-helm-infra/+/788886 Change-Id: I81850d5e534a3cfb3c4993275757c244caec8be9
This commit is contained in:
parent
ef707fa3f3
commit
13a683b9c2
@ -15,7 +15,7 @@ apiVersion: v1
|
||||
appVersion: v10.6.7
|
||||
description: OpenStack-Helm MariaDB
|
||||
name: mariadb
|
||||
version: 0.2.56
|
||||
version: 0.2.57
|
||||
home: https://mariadb.com/kb/en/
|
||||
icon: http://badges.mariadb.org/mariadb-badge-180x60.png
|
||||
sources:
|
||||
|
@ -331,33 +331,26 @@ def safe_update_configmap(configmap_dict, configmap_patch):
|
||||
# ensure nothing else has modified the confimap since we read it.
|
||||
configmap_patch['metadata']['resourceVersion'] = configmap_dict[
|
||||
'metadata']['resource_version']
|
||||
try:
|
||||
api_response = k8s_api_instance.patch_namespaced_config_map(
|
||||
name=state_configmap_name,
|
||||
namespace=pod_namespace,
|
||||
body=configmap_patch)
|
||||
return True
|
||||
except kubernetes.client.rest.ApiException as error:
|
||||
if error.status == 409:
|
||||
# This status code indicates a collision trying to write to the
|
||||
# config map while another instance is also trying the same.
|
||||
logger.warning("Collision writing configmap: {0}".format(error))
|
||||
# This often happens when the replicas were started at the same
|
||||
# time, and tends to be persistent. Sleep with some random
|
||||
# jitter value briefly to break the synchronization.
|
||||
naptime = secretsGen.uniform(0.8,1.2)
|
||||
time.sleep(naptime)
|
||||
else:
|
||||
logger.error("Failed to set configmap: {0}".format(error))
|
||||
return error
|
||||
|
||||
# Retry up to 8 times in case of 409 only. Each retry has a ~1 second
|
||||
# sleep in between so do not want to exceed the roughly 10 second
|
||||
# write interval per cm update.
|
||||
for i in range(8):
|
||||
try:
|
||||
api_response = k8s_api_instance.patch_namespaced_config_map(
|
||||
name=state_configmap_name,
|
||||
namespace=pod_namespace,
|
||||
body=configmap_patch)
|
||||
return True
|
||||
except kubernetes.client.rest.ApiException as error:
|
||||
if error.status == 409:
|
||||
# This status code indicates a collision trying to write to the
|
||||
# config map while another instance is also trying the same.
|
||||
logger.warning("Collision writing configmap: {0}".format(error))
|
||||
# This often happens when the replicas were started at the same
|
||||
# time, and tends to be persistent. Sleep with some random
|
||||
# jitter value briefly to break the synchronization.
|
||||
naptime = secretsGen.uniform(0.8,1.2)
|
||||
time.sleep(naptime)
|
||||
else:
|
||||
logger.error("Failed to set configmap: {0}".format(error))
|
||||
return error
|
||||
logger.info("Retry writing configmap attempt={0} sleep={1}".format(
|
||||
i+1, naptime))
|
||||
return True
|
||||
|
||||
def set_configmap_annotation(key, value):
|
||||
"""Update a configmap's annotations via patching.
|
||||
|
@ -72,4 +72,5 @@ mariadb:
|
||||
- 0.2.54 Improve leader election on cold start
|
||||
- 0.2.55 Improve python3 compatibility
|
||||
- 0.2.56 Stop running threads on sigkill
|
||||
- 0.2.57 Remove useless retries on conflicts during cm update
|
||||
...
|
||||
|
Loading…
x
Reference in New Issue
Block a user