Skip to content

Commit

Permalink
Disabled external networking for ScirGcloud jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
prioux committed Feb 17, 2025
1 parent 7d68f4e commit 8cb9638
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions BrainPortal/lib/scir_gcloud_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ def terminate(jid) #:nodoc:
return
end

# Fetches the project from the Bourreau level config; cannot fetch from tool config level
# within a ScirSession; not used yet
def gcloud_project
ScirGcloudBatch.extract_config_value('GCLOUD_PROJECT', Scir.cbrain_config[:extra_qsub_args])
end

# Fetches the location from the Bourreau level config; cannot fetch from tool config level
# within a ScirSession
def gcloud_location
Expand Down Expand Up @@ -120,6 +126,10 @@ def qsubout_to_jid(txt) #:nodoc:

class JobTemplate < Scir::JobTemplate #:nodoc:

def gcloud_project
get_config_value_from_extra_qsubs('GCLOUD_PROJECT')
end

def gcloud_location
get_config_value_from_extra_qsubs('GCLOUD_LOCATION')
end
Expand All @@ -128,10 +138,6 @@ def gcloud_compute_image_basename
get_config_value_from_extra_qsubs('GCLOUD_IMAGE_BASENAME')
end

def gcloud_project
get_config_value_from_extra_qsubs('GCLOUD_PROJECT')
end

# This method should not be overriden
def full_compute_node_image_name
"projects/#{gcloud_project}/global/images/#{gcloud_compute_image_basename}"
Expand Down Expand Up @@ -168,7 +174,11 @@ def qsub_command #:nodoc:
gname = gname[0..50] if gname.size > 50
gname = gname + DateTime.now.strftime("-%H%M%S") # this should be good enough

command = "gcloud batch jobs submit #{gname} --location #{gcloud_location} "
command = "gcloud batch jobs submit #{gname} "
command += "--location #{gcloud_location} "
command += "--network projects/#{gcloud_project}/global/networks/default "
command += "--subnetwork projects/#{gcloud_project}/regions/#{gcloud_location}/subnetworks/default "
command += "--no-external-ip-address "

script_name = self.arg[0]
script_command = ""
Expand Down

0 comments on commit 8cb9638

Please sign in to comment.