Skip to content

Commit a28a0c5

Browse files
Improvements
2 parents d19f91c + 00d25dc commit a28a0c5

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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

plugins/nf-cws/src/main/nextflow/cws/k8s/CWSK8sClient.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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

plugins/nf-cws/src/main/nextflow/cws/k8s/CWSK8sConfig.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

plugins/nf-cws/src/main/nextflow/cws/k8s/CWSK8sExecutor.groovy

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff 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,

plugins/nf-cws/src/main/nextflow/cws/k8s/CWSK8sTaskHandler.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import groovy.transform.CompileStatic
55
import groovy.util.logging.Slf4j
66
import nextflow.cws.CWSConfig
77
import nextflow.cws.SchedulerClient
8+
import nextflow.exception.ProcessRetryableException
89
import nextflow.executor.BashWrapperBuilder
910
import nextflow.extension.GroupKey
1011
import 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
}

0 commit comments

Comments
 (0)