diff --git a/magnum_cluster_api/driver.py b/magnum_cluster_api/driver.py index e931b764..9228a883 100644 --- a/magnum_cluster_api/driver.py +++ b/magnum_cluster_api/driver.py @@ -257,7 +257,7 @@ def resize_cluster( machine.obj["metadata"]["annotations"][ "cluster.x-k8s.io/delete-machine" ] = "yes" - machine.update() + utils.kube_apply_patch(machine) self._update_nodegroup(context, cluster, nodegroup) @@ -347,7 +347,8 @@ def create_nodegroup( current_generation = resources.Cluster( context, self.k8s_api, cluster ).get_observed_generation() - cluster_resource.update() + utils.kube_apply_patch(cluster_resource) + self.wait_capi_cluster_reconciliation_start( context, cluster, current_generation ) @@ -454,7 +455,7 @@ def _update_nodegroup( current_generation = resources.Cluster( context, self.k8s_api, cluster ).get_observed_generation() - cluster_resource.update() + utils.kube_apply_patch(cluster_resource) self.wait_capi_cluster_reconciliation_start( context, cluster, current_generation ) @@ -492,7 +493,7 @@ def delete_nodegroup( current_generation = resources.Cluster( context, self.k8s_api, cluster ).get_observed_generation() - cluster_resource.update() + utils.kube_apply_patch(cluster_resource) self.wait_capi_cluster_reconciliation_start( context, cluster, current_generation ) diff --git a/magnum_cluster_api/utils.py b/magnum_cluster_api/utils.py index fb51632c..a6c556a7 100644 --- a/magnum_cluster_api/utils.py +++ b/magnum_cluster_api/utils.py @@ -467,3 +467,20 @@ def get_keystone_auth_default_policy(cluster: magnum_objects.Cluster): return json.loads(f.read()) except Exception: return default_policy + +def kube_apply_patch(resource): + resp = resource.api.patch( + **resource.api_kwargs( + headers={ + "Content-Type": "application/apply-patch+yaml", + }, + params={ + "fieldManager": "atmosphere-operator", + "force": True, + }, + data=json.dumps(resource.obj), + ) + ) + + resource.api.raise_for_status(resp) + resource.set_obj(resp.json())