@@ -11,17 +11,29 @@ async function k8sCommand(ins, outs, context, cb) {
1111 // let cluster = await getCluster();
1212 // const token = await getGCPToken();
1313
14- // support for two clusters (cloud bursting)
15- // if 'HF_VAR_REMOTE_CLUSTER' is defined, we check where this job is assigned to:
16- // - the local cluster: we do nothing
17- // - the remote cluster: we set KUBECONFIG to load its configuration
18- var remoteClusterId = process . env . HF_VAR_REMOTE_CLUSTER ;
19- if ( remoteClusterId ) {
20- let partition = context . executor . partition ;
21- if ( partition == remoteClusterId ) {
22- // this will cause reading the kube_config of the remote cluster
23- process . env . KUBECONFIG = process . env . HF_VAR_KUBE_CONFIG_PATH || "./kube_config" ;
24- }
14+ // support for two (or more) clusters (for cloud bursting)
15+ // if 'partition' is defined, check if there is a custom config file
16+ // for that partition. This config file may override parameters of the job,
17+ // possibly even define a path to a different kube_config to be loaded
18+ let partition = context . executor . partition ;
19+ let partitionConfigDir = process . env . HF_VAR_PARTITION_CONFIG_DIR || "/opt/hyperflow/partitions" ;
20+ let partitionConfigFile = partitionConfigDir + "/" + "part." + partition + ".config.json" ;
21+
22+ // custom parameters for the job YAML template (will overwrite default values)
23+ var customParams = { } ;
24+ try {
25+ // if file exists, all configuration parameters will be read to 'customParams'
26+ let rawdata = fs . readFileSync ( partitionConfigFile ) ;
27+ customParams = JSON . parse ( rawdata ) ;
28+ } catch {
29+ }
30+ console . log ( partitionConfigFile ) ;
31+ console . log ( "CUSTOM..." , customParams ) ;
32+
33+ // Set kube_config path if overridden
34+ if ( customParams . kubeConfigPath ) {
35+ process . env . KUBECONFIG = customParams . kubeConfigPath ;
36+ console . log ( process . env . KUBECONFIG ) ;
2537 }
2638
2739 const kubeconfig = new k8s . KubeConfig ( ) ;
@@ -32,9 +44,6 @@ async function k8sCommand(ins, outs, context, cb) {
3244 job . ins = ins ;
3345 job . outs = outs ;
3446
35- // custom parameters to the job YAML template (will overwrite default values)
36- var customParams = { } ;
37-
3847 let jobExitCode = await submitK8sJob ( kubeconfig , job , context . taskId , context , customParams ) ;
3948
4049 let endTime = Date . now ( ) ;
0 commit comments