Skip to content

Commit ce44855

Browse files
committed
migrate to server side-apply
1 parent 2f7d17e commit ce44855

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

docker/mongodb-kubernetes-tests/kubeobject/customobject.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ def create(self) -> CustomObject:
116116

117117
def update(self) -> CustomObject:
118118
"""Updates the object in Kubernetes. Deleting keys is done by setting them to None"""
119-
return create_or_update(self)
119+
self.patch()
120+
return self
120121

121122
def patch(self, field_manager: str = "e2e-tests") -> CustomObject:
122123
"""Apply the object in Kubernetes using server-side apply.
@@ -326,26 +327,3 @@ def get_crd_names(
326327

327328
if found:
328329
return crd
329-
330-
331-
def create_or_update(resource: CustomObject) -> CustomObject:
332-
"""
333-
Tries to create the resource. If resource already exists (resulting in 409 Conflict),
334-
then it updates it instead using server-side apply.
335-
336-
Server-side apply (SSA) with force=True handles conflicts automatically by taking
337-
ownership of conflicting fields, eliminating the need for client-side merge retries.
338-
"""
339-
if not resource.bound:
340-
try:
341-
resource.create()
342-
except client.ApiException as e:
343-
if e.status != 409:
344-
raise e
345-
# Resource already exists, use SSA to update it
346-
resource.patch()
347-
else:
348-
# SSA with force=True handles conflicts automatically
349-
resource.patch()
350-
351-
return resource

docker/mongodb-kubernetes-tests/kubetester/kubetester.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def _server_side_apply(
6666
)
6767

6868
return result.to_dict()
69+
70+
6971
from tests import test_logger
7072

7173
TRACER = trace.get_tracer("evergreen-agent")

0 commit comments

Comments
 (0)