@@ -262,47 +262,52 @@ def create(spec: Dict[str, Any], name: str, namespace: str, **_: Any) -> Dict[st
262
262
core_api .create_namespaced_config_map (
263
263
namespace , config_cm_body , _request_timeout = _REQUEST_TIMEOUT
264
264
)
265
+ logging .info ("Created CONFIG ConfigMap %s" , cm_name )
265
266
267
+ cm_name = f"bp-{ name } "
266
268
bp_cm_body = {
267
269
"apiVersion" : "v1" ,
268
270
"kind" : "ConfigMap" ,
269
- "metadata" : {"name" : f"bp- { name } " , "labels" : {"app" : name }},
271
+ "metadata" : {"name" : cm_name , "labels" : {"app" : name }},
270
272
"data" : {".bash_profile" : _BASH_PROFILE },
271
273
}
272
274
kopf .adopt (bp_cm_body )
273
275
try :
274
276
core_api .create_namespaced_config_map (
275
277
namespace , bp_cm_body , _request_timeout = _REQUEST_TIMEOUT
276
278
)
279
+ logging .info ("Created BP ConfigMap (%s)" , cm_name )
277
280
except kubernetes .client .exceptions .ApiException as ex :
278
281
if ex .status != 409 or ex .reason != "Conflict" :
279
282
raise ex
280
283
# Warn, but ignore and return a valid 'create' response now.
281
- logging .warning (
282
- "Got ApiException [409/Conflict] creating BP ConfigMap. Ignoring"
284
+ logging .info (
285
+ "Got 409/Conflict creating BP ConfigMap %s. Ignoring - object already present" ,
286
+ cm_name ,
283
287
)
284
288
289
+ cm_name = f"startup-{ name } "
285
290
startup_cm_body = {
286
291
"apiVersion" : "v1" ,
287
292
"kind" : "ConfigMap" ,
288
- "metadata" : {"name" : f"startup- { name } " , "labels" : {"app" : name }},
293
+ "metadata" : {"name" : cm_name , "labels" : {"app" : name }},
289
294
"data" : {"start.sh" : _NOTEBOOK_STARTUP },
290
295
}
291
296
kopf .adopt (startup_cm_body )
292
297
try :
293
298
core_api .create_namespaced_config_map (
294
299
namespace , startup_cm_body , _request_timeout = _REQUEST_TIMEOUT
295
300
)
301
+ logging .info ("Created STARTUP ConfigMap (%s)" , cm_name )
296
302
except kubernetes .client .exceptions .ApiException as ex :
297
303
if ex .status != 409 or ex .reason != "Conflict" :
298
304
raise ex
299
305
# Warn, but ignore and return a valid 'create' response now.
300
- logging .warning (
301
- "Got ApiException [409/Conflict] creating STARTUP ConfigMap. Ignoring"
306
+ logging .info (
307
+ "Got 409/Conflict creating STARTUP ConfigMap %s. Ignoring - object already present" ,
308
+ cm_name ,
302
309
)
303
310
304
- logging .info ("Created ConfigMaps" )
305
-
306
311
# Deployment
307
312
# ----------
308
313
@@ -420,16 +425,16 @@ def create(spec: Dict[str, Any], name: str, namespace: str, **_: Any) -> Dict[st
420
425
apps_api .create_namespaced_deployment (
421
426
namespace , deployment_body , _request_timeout = _REQUEST_TIMEOUT
422
427
)
428
+ logging .info ("Created Deployment %s" , name )
423
429
except kubernetes .client .exceptions .ApiException as ex :
424
430
if ex .status != 409 or ex .reason != "Conflict" :
425
431
raise ex
426
432
# Warn, but ignore and return a valid 'create' response now.
427
- logging .warning (
428
- "Got ApiException [409/Conflict] creating CONFIG ConfigMap. Ignoring"
433
+ logging .info (
434
+ "Got 409/Conflict creating Deployment %s. Ignoring - object already present" ,
435
+ name ,
429
436
)
430
437
431
- logging .info ("Created deployment" )
432
-
433
438
# Service
434
439
# -------
435
440
@@ -458,16 +463,16 @@ def create(spec: Dict[str, Any], name: str, namespace: str, **_: Any) -> Dict[st
458
463
core_api .create_namespaced_service (
459
464
namespace , service_body , _request_timeout = _REQUEST_TIMEOUT
460
465
)
466
+ logging .info ("Created Service %s" , name )
461
467
except kubernetes .client .exceptions .ApiException as ex :
462
468
if ex .status != 409 or ex .reason != "Conflict" :
463
469
raise ex
464
470
# Warn, but ignore and return a valid 'create' response now.
465
- logging .warning (
466
- "Got ApiException [409/Conflict] creating CONFIG ConfigMap. Ignoring"
471
+ logging .info (
472
+ "Got 409/Conflict creating Service %s. Ignoring - object already present" ,
473
+ name ,
467
474
)
468
475
469
- logging .info ("Created service" )
470
-
471
476
# Ingress
472
477
# -------
473
478
@@ -518,18 +523,20 @@ def create(spec: Dict[str, Any], name: str, namespace: str, **_: Any) -> Dict[st
518
523
ext_api .create_namespaced_ingress (
519
524
namespace , ingress_body , _request_timeout = _REQUEST_TIMEOUT
520
525
)
526
+ logging .info ("Created Ingress %s" , name )
521
527
except kubernetes .client .exceptions .ApiException as ex :
522
528
if ex .status != 409 or ex .reason != "Conflict" :
523
529
raise ex
524
530
# Warn, but ignore and return a valid 'create' response now.
525
- logging .warning (
526
- "Got ApiException [409/Conflict] creating CONFIG ConfigMap. Ignoring"
531
+ logging .info (
532
+ "Got 409/Conflict creating Ingress %s. Ignoring - object already present" ,
533
+ name ,
527
534
)
528
535
529
- logging .info ("Created ingress" )
530
-
531
536
# Done
532
537
# ----
538
+ logging .info ("Success! (name=%s namespace=%s)" , name , namespace )
539
+
533
540
return {
534
541
"notebook" : {
535
542
"url" : f"http://{ ingress_domain } { ingress_path } ?token={ token } " ,
0 commit comments