@@ -79,19 +79,29 @@ def __init__(
7979 self .image = image
8080 self .port = port
8181 self .path = path
82- self .cvmfs_repos = cvmfs_repos or [],
82+ self .cvmfs_repos = ( cvmfs_repos or [],)
8383 self .image_pull_secrets = []
8484 metadata = client .V1ObjectMeta (
8585 name = deployment_name ,
8686 labels = {"reana_workflow_mode" : "session" },
8787 )
8888 self ._session_container = client .V1Container (
89- name = self .deployment_name , image = self .image , env = [], volume_mounts = [], ports = [client .V1ContainerPort (container_port = self .port )]
89+ name = self .deployment_name ,
90+ image = self .image ,
91+ env = [],
92+ volume_mounts = [],
93+ ports = [client .V1ContainerPort (container_port = self .port )],
9094 )
9195 containers = [self ._session_container ]
92- if ( REANA_DATASTORE_ENABLED ) :
96+ if REANA_DATASTORE_ENABLED :
9397 self ._s3_container = client .V1Container (
94- name = "datastore" , image = REANA_DATASTORE_IMAGE , env = [], volume_mounts = [], ports = [], image_pull_policy = "Always" , lifecycle = []
98+ name = "datastore" ,
99+ image = REANA_DATASTORE_IMAGE ,
100+ env = [],
101+ volume_mounts = [],
102+ ports = [],
103+ image_pull_policy = "Always" ,
104+ lifecycle = [],
95105 )
96106 containers .append (self ._s3_container )
97107
@@ -229,55 +239,58 @@ def setup_s3_storage(self):
229239 volume_name = "s3-mounts"
230240
231241 volume = client .V1Volume (
232- name = volume_name ,
233- empty_dir = client .V1EmptyDirVolumeSource ()
242+ name = volume_name , empty_dir = client .V1EmptyDirVolumeSource ()
234243 )
235244
236245 volume_mount = client .V1VolumeMount (
237246 name = volume_name ,
238247 mount_path = "/data/s3/" ,
239- mount_propagation = "HostToContainer"
248+ mount_propagation = "HostToContainer" ,
240249 )
241250
242251 self ._session_container .volume_mounts .append (volume_mount )
243252
244253 volume_mount = client .V1VolumeMount (
245- name = volume_name ,
246- mount_path = "/s3-data" ,
247- mount_propagation = "Bidirectional"
254+ name = volume_name , mount_path = "/s3-data" , mount_propagation = "Bidirectional"
248255 )
249256
250257 self ._s3_container .volume_mounts .append (volume_mount )
251258
252259 self ._pod_spec .volumes .append (volume )
253260
254261 def setup_s3_sidecar (self ):
255- """Add the sidecar for s3 mounts"""
262+ """Add the sidecar for s3 mounts. """
256263 # Define the volume mount for /dev/fuse
257264 fuse_volume_mount = client .V1VolumeMount (
258- name = "fuse-device" ,
259- mount_path = "/dev/fuse"
265+ name = "fuse-device" , mount_path = "/dev/fuse"
260266 )
261267
262268 # Define the volume for /dev/fuse
263- fuse_volume = client .V1HostPathVolumeSource (
264- path = "/dev/fuse"
265- )
269+ fuse_volume = client .V1HostPathVolumeSource (path = "/dev/fuse" )
266270
267271 # Append the volume mount and volume to the session container and pod spec
268272 self ._s3_container .volume_mounts .append (fuse_volume_mount )
269- self ._pod_spec .volumes .append (client .V1Volume (name = "fuse-device" , host_path = fuse_volume ))
273+ self ._pod_spec .volumes .append (
274+ client .V1Volume (name = "fuse-device" , host_path = fuse_volume )
275+ )
270276
271277 security_context = client .V1SecurityContext (
272- run_as_user = 0 , allow_privilege_escalation = True , capabilities = client .V1Capabilities (add = ["SYS_ADMIN" ]), privileged = True
278+ run_as_user = 0 ,
279+ allow_privilege_escalation = True ,
280+ capabilities = client .V1Capabilities (add = ["SYS_ADMIN" ]),
281+ privileged = True ,
273282 )
274283 self ._s3_container .security_context = security_context
275284
276285 # adding umount for correct termination
277286 lifecycle_dict = {
278287 "preStop" : {
279288 "exec" : {
280- "command" : ["/bin/sh" , "-c" , "xargs umount -l < /etc/active_mounts.txt || true" ]
289+ "command" : [
290+ "/bin/sh" ,
291+ "-c" ,
292+ "xargs umount -l < /etc/active_mounts.txt || true" ,
293+ ]
281294 }
282295 }
283296 }
@@ -304,9 +317,7 @@ def add_environment_variable(self, name, value):
304317
305318 def add_run_with_root_permissions (self ):
306319 """Run interactive session with root."""
307- security_context = client .V1SecurityContext (
308- run_as_user = 0 , privileged = True
309- )
320+ security_context = client .V1SecurityContext (run_as_user = 0 , privileged = True )
310321 self ._session_container .security_context = security_context
311322
312323 def add_user_secrets (self ):
@@ -337,7 +348,7 @@ def add_user_secrets(self):
337348 self ._session_container .env = session_env
338349
339350 # mount s3 secretes
340- if ( REANA_DATASTORE_ENABLED ) :
351+ if REANA_DATASTORE_ENABLED :
341352 self ._s3_container .env = s3_env
342353
343354 def get_deployment_objects (self ):
@@ -397,7 +408,7 @@ def build_interactive_jupyter_deployment_k8s_objects(
397408 deployment_builder .add_command_arguments (command_args )
398409 deployment_builder .add_reana_shared_storage ()
399410 deployment_builder .add_image_pull_secrets ()
400- if ( REANA_DATASTORE_ENABLED ) :
411+ if REANA_DATASTORE_ENABLED :
401412 deployment_builder .setup_s3_sidecar ()
402413 deployment_builder .setup_s3_storage ()
403414 if cvmfs_repos :
0 commit comments