File tree Expand file tree Collapse file tree 5 files changed +51
-8
lines changed
plugins/nf-cws/src/main/nextflow/cws/k8s Expand file tree Collapse file tree 5 files changed +51
-8
lines changed Original file line number Diff line number Diff line change @@ -112,10 +112,12 @@ k8s {
112112
113113| Attribute | Required | Explanation |
114114| :----------------------| ----------| -------------------------------------------------------------------------------------------------|
115- | localPath | yes | Host path for the local mount
116- | localStorageMountPath | no | Container path for the local mount
117- | storage.copyStrategy | no | Strategy to copy the files between nodes - currently only supports 'ftp' (and its alias 'copy')
118- | storage.workdir | no | Working directory to use - must be inside of the locally mounted directory
115+ | localPath | yes | Host path for the local mount |
116+ | localStorageMountPath | no | Container path for the local mount |
117+ | storage.copyStrategy | no | Strategy to copy the files between nodes - currently only supports 'ftp' (and its alias 'copy') |
118+ | storage.workdir | no | Working directory to use - must be inside of the locally mounted directory |
119+ | storage.cpu | no | CPU to use for daemons running on all nodes, default: empty - no limits |
120+ | storage.memory | no | Memory to use for daemons running on all nodes, default: 256Mi |
119121
120122### Tracing
121123
Original file line number Diff line number Diff line change @@ -94,6 +94,18 @@ class CWSK8sClient extends K8sClient {
9494 configCreate0(spec)
9595 }
9696
97+ K8sResponseJson podDelete (String name ) {
98+ try {
99+ return super . podDelete( name )
100+ } catch ( Exception e ) {
101+ log. warn " Failed to delete pod '$name ' -- cause: ${ e.message ?: e} "
102+ if ( ' returned an error code=404' in e. message ) {
103+ return null
104+ }
105+ throw e
106+ }
107+ }
108+
97109 /**
98110 * Get the memory of a pod that has been adapted by the CWS
99111 * @param podName The name of the pod
Original file line number Diff line number Diff line change @@ -180,5 +180,17 @@ class CWSK8sConfig extends K8sConfig {
180180 String getCmd () {
181181 target. cmd as String
182182 }
183+
184+ Double getCpu () {
185+ if ( target. cpu ) {
186+ return target. cpu as double
187+ }
188+ return null
189+ }
190+
191+ String getMemory () {
192+ target. memory as String ?: ' 256Mi'
193+ }
194+
183195 }
184196}
Original file line number Diff line number Diff line change @@ -272,19 +272,33 @@ class CWSK8sExecutor extends K8sExecutor implements ExtensionPoint {
272272 mounts << claim
273273 }
274274
275+ CWSK8sConfig.Storage storage = (k8sConfig as CWSK8sConfig ). getStorage()
276+
275277 String name = " mount-${ session.runName.replace('_', '-')} "
278+ def resources = [
279+ limits : [
280+ memory : storage. getMemory()
281+ ],
282+ requests : [
283+ memory : storage. getMemory()
284+ ]
285+ ]
286+ if ( storage. getCpu() ) {
287+ (resources. limits as Map ). put( ' cpu' , storage. getCpu() )
288+ (resources. requests as Map ). put( ' cpu' , storage. getCpu() )
289+ }
276290 def spec = [
277291 containers : [ [
278292 name : name,
279293 image : (k8sConfig as CWSK8sConfig ). getStorage(). getImageName(),
280294 volumeMounts : mounts,
281- imagePullPolicy : ' IfNotPresent'
295+ imagePullPolicy : ' IfNotPresent' ,
296+ resources : resources
282297 ] ],
283298 volumes : volumes,
284299 serviceAccount : client. config. serviceAccount
285300 ]
286301
287- CWSK8sConfig.Storage storage = (k8sConfig as CWSK8sConfig ). getStorage()
288302 if ( storage. getNodeSelector() )
289303 spec. put( ' nodeSelector' , storage. getNodeSelector(). toSpec() as Serializable )
290304
@@ -299,8 +313,8 @@ class CWSK8sExecutor extends K8sExecutor implements ExtensionPoint {
299313 namespace : k8sConfig. getNamespace() ?: ' default'
300314 ],
301315 spec : [
302- restartPolicy : ' Always' ,
303316 template : [
317+ restartPolicy : ' Always' ,
304318 metadata : [
305319 labels : [
306320 name : name,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import groovy.transform.CompileStatic
55import groovy.util.logging.Slf4j
66import nextflow.cws.CWSConfig
77import nextflow.cws.SchedulerClient
8+ import nextflow.exception.ProcessRetryableException
89import nextflow.executor.BashWrapperBuilder
910import nextflow.extension.GroupKey
1011import nextflow.file.FileHolder
@@ -198,7 +199,9 @@ class CWSK8sTaskHandler extends K8sTaskHandler {
198199 try {
199200 return super . checkIfRunning()
200201 } catch ( Exception e) {
201- log. error(" Error checking if task is running" , e)
202+ if ( e instanceof ProcessRetryableException ) {
203+ throw new RuntimeException ( " Exception while checking if task is running" , e )
204+ }
202205 throw e
203206 }
204207 }
You can’t perform that action at this time.
0 commit comments