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,6 +210,7 @@ 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 ,
@@ -218,9 +219,14 @@ def apply(self, force=False):
218
219
)
219
220
print (f"AppWrapper: '{ name } ' has successfully been created" )
220
221
else :
221
- api_instance = crds .get (api_version = "ray.io/v1" , kind = "RayCluster" )
222
- self ._component_resources_apply (namespace , api_instance )
222
+ api_version = "ray.io/v1"
223
+ api_instance = crds .get (api_version = api_version , kind = "RayCluster" )
224
+ self ._component_resources_apply (
225
+ namespace = namespace , api_instance = api_instance
226
+ )
223
227
print (f"Ray Cluster: '{ name } ' has successfully been applied" )
228
+ except AttributeError as e :
229
+ raise RuntimeError (f"Failed to initialize DynamicClient: { e } " )
224
230
except Exception as e : # pragma: no cover
225
231
return _kube_api_error_handling (e )
226
232
@@ -806,7 +812,7 @@ def _apply_resources(
806
812
yamls , namespace : str , api_instance : client .CustomObjectsApi , force = False
807
813
):
808
814
api_instance .server_side_apply (
809
- field_manager = "cluster-manager" ,
815
+ field_manager = CF_SDK_FIELD_MANAGER ,
810
816
group = "ray.io" ,
811
817
version = "v1" ,
812
818
namespace = namespace ,
0 commit comments