Use replace rather than patch for most resources
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Lauri Võsandi 2022-09-13 10:20:40 +03:00
parent 088112bcd4
commit bd9fd49705

View File

@ -105,7 +105,7 @@ async def apply_changes(operator, item, v1, revision, apps_api, api_instance):
# Generate Services
for name, body in transform_template(operator["spec"].get("services", [])):
try:
await v1.patch_namespaced_service(name, namespace, body)
await v1.replace_namespaced_service(name, namespace, body)
logger.info("Updated service %s/%s", namespace, name)
except client.exceptions.ApiException:
await v1.create_namespaced_service(namespace, body)
@ -114,7 +114,7 @@ async def apply_changes(operator, item, v1, revision, apps_api, api_instance):
# Generate ConfigMaps
for name, body in transform_template(operator["spec"].get("configmaps", [])):
try:
await v1.patch_namespaced_config_map(name, namespace, body)
await v1.replace_namespaced_config_map(name, namespace, body)
logger.info("Updated configmap %s/%s", namespace, name)
except client.exceptions.ApiException:
await v1.create_namespaced_config_map(namespace, body)
@ -125,7 +125,7 @@ async def apply_changes(operator, item, v1, revision, apps_api, api_instance):
if replicas:
body["spec"]["replicas"] = replicas
try:
await apps_api.patch_namespaced_deployment(name, namespace, body)
await apps_api.replace_namespaced_deployment(name, namespace, body)
logger.info("Updated deployment %s/%s", namespace, name)
except client.exceptions.ApiException:
await apps_api.create_namespaced_deployment(namespace, body)
@ -136,7 +136,7 @@ async def apply_changes(operator, item, v1, revision, apps_api, api_instance):
if replicas:
body["spec"]["replicas"] = replicas
try:
await apps_api.patch_namespaced_stateful_set(name, namespace, body)
await apps_api.replace_namespaced_stateful_set(name, namespace, body)
logger.info("Updated statefulset %s/%s", namespace, name)
except client.exceptions.ApiException:
await apps_api.create_namespaced_stateful_set(namespace, body)