59
59
from kubernetes .client .rest import ApiException
60
60
import warnings
61
61
62
+ CF_SDK_FIELD_MANAGER = "codeflare-sdk"
63
+
62
64
63
65
class Cluster :
64
66
"""
@@ -89,11 +91,9 @@ def __init__(self, config: ClusterConfiguration):
89
91
cluster_up_down_buttons (self )
90
92
91
93
def get_dynamic_client (self ): # pragma: no cover
92
- """Return a dynamic client, optionally mocked in tests."""
93
94
return DynamicClient (get_api_client ())
94
95
95
96
def config_check (self ):
96
- """Return a dynamic client, optionally mocked in tests."""
97
97
return config_check ()
98
98
99
99
@property
@@ -201,7 +201,7 @@ def apply(self, force=False):
201
201
crds = self .get_dynamic_client ().resources
202
202
if self .config .appwrapper :
203
203
api_version = "workload.codeflare.dev/v1beta2"
204
- api_instance = crds .get (api_version , kind = "AppWrapper" )
204
+ api_instance = crds .get (api_version = api_version , kind = "AppWrapper" )
205
205
# defaulting body to resource_yaml
206
206
body = self .resource_yaml
207
207
if self .config .write_to_file :
@@ -210,17 +210,24 @@ def apply(self, force=False):
210
210
aw = yaml .load (f , Loader = yaml .FullLoader )
211
211
body = aw
212
212
api_instance .server_side_apply (
213
+ field_manager = CF_SDK_FIELD_MANAGER ,
213
214
group = "workload.codeflare.dev" ,
214
215
version = "v1beta2" ,
215
216
namespace = namespace ,
216
217
plural = "appwrappers" ,
217
218
body = body ,
219
+ force_conflicts = force ,
218
220
)
219
221
print (f"AppWrapper: '{ name } ' has successfully been created" )
220
222
else :
221
- api_instance = crds .get (api_version = "ray.io/v1" , kind = "RayCluster" )
222
- self ._component_resources_apply (namespace , api_instance )
223
+ api_version = "ray.io/v1"
224
+ api_instance = crds .get (api_version = api_version , kind = "RayCluster" )
225
+ self ._component_resources_apply (
226
+ namespace = namespace , api_instance = api_instance
227
+ )
223
228
print (f"Ray Cluster: '{ name } ' has successfully been applied" )
229
+ except AttributeError as e :
230
+ raise RuntimeError (f"Failed to initialize DynamicClient: { e } " )
224
231
except Exception as e : # pragma: no cover
225
232
return _kube_api_error_handling (e )
226
233
@@ -806,7 +813,7 @@ def _apply_resources(
806
813
yamls , namespace : str , api_instance : client .CustomObjectsApi , force = False
807
814
):
808
815
api_instance .server_side_apply (
809
- field_manager = "cluster-manager" ,
816
+ field_manager = CF_SDK_FIELD_MANAGER ,
810
817
group = "ray.io" ,
811
818
version = "v1" ,
812
819
namespace = namespace ,
0 commit comments