Skip to content

Commit c5b14fa

Browse files
committed
Merge branch 'hotfix/fix-0.3.1'
2 parents 2e7ab38 + 464e87a commit c5b14fa

File tree

12 files changed

+115
-46
lines changed

12 files changed

+115
-46
lines changed

plugins/nf-nomad/src/main/nextflow/nomad/builders/JobBuilder.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ class JobBuilder {
107107

108108
static protected Resources getResources(TaskRun task) {
109109
final DEFAULT_CPUS = 1
110-
final DEFAULT_MEMORY = "500.MB"
110+
final DEFAULT_MEMORY = "1.GB"
111111

112112
final taskCfg = task.getConfig()
113113
final taskCores = !taskCfg.get("cpus") ? DEFAULT_CPUS : taskCfg.get("cpus") as Integer
114-
final taskMemory = taskCfg.get("memory") ? new MemoryUnit( taskCfg.get("memory") as String ) : new MemoryUnit(DEFAULT_MEMORY)
114+
final taskMemory = new MemoryUnit( taskCfg.get("memory")?.toString() ?: DEFAULT_MEMORY)
115115

116116
final res = new Resources()
117117
.cores(taskCores)
@@ -313,4 +313,4 @@ class JobBuilder {
313313
}
314314

315315

316-
}
316+
}

plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadService.groovy

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,6 @@ class NomadService implements Closeable{
136136

137137

138138

139-
String getJobStatus(String jobId){
140-
try {
141-
Job job = safeExecutor.apply {
142-
jobsApi.getJob(jobId, config.jobOpts().region, config.jobOpts().namespace,
143-
null, null, null, null, null, null, null)
144-
}
145-
log.debug "[NOMAD] getJobStatus jobID=$job.ID; status=$job.status"
146-
job.status
147-
}catch (Exception e){
148-
log.debug("[NOMAD] getJobStatus Failed to get jobState ${jobId} -- Cause: ${e.message ?: e}", e)
149-
"unknown"
150-
}
151-
}
152-
153139
void kill(String jobId) {
154140
purgeJob(jobId, false)
155141
}

plugins/nf-nomad/src/main/nextflow/nomad/executor/NomadTaskHandler.groovy

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ class NomadTaskHandler extends TaskHandler implements FusionAwareTask {
102102
if(isSubmitted()) {
103103
def state = taskState0()
104104

105-
log.debug "[NOMAD] checkIfRunning task=$task.name; state=${state?.state}"
105+
log.debug "[NOMAD] checkIfRunning task=$task.name ; state=${state?.state}"
106106

107-
// include `terminated` state to allow the handler status to progress
108-
if( state && ( ["running","pending","unknown"].contains(state.state))){
107+
// if a state exists, include an array of states to determine task status
108+
if( state?.state && ( ["running","pending","unknown"].contains(state.state))){
109109
this.status = TaskStatus.RUNNING
110110
determineClientNode()
111111
return true
@@ -121,9 +121,10 @@ class NomadTaskHandler extends TaskHandler implements FusionAwareTask {
121121

122122
def state = taskState0()
123123

124-
log.debug "[NOMAD] checkIfCompleted task=$task.name; state=${state?.state}"
124+
log.debug "[NOMAD] checkIfCompleted task=$task.name ; state=${state?.state}"
125125

126-
if( state && ( ["dead","complete"].contains(state.state))){
126+
// if a state exists, include an array of states to determine task status
127+
if( state?.state && ( ["dead"].contains(state.state))){
127128
// finalize the task
128129
task.exitStatus = readExitFile()
129130
task.stdout = outputFile
@@ -157,9 +158,8 @@ class NomadTaskHandler extends TaskHandler implements FusionAwareTask {
157158
}
158159

159160
String submitTask() {
160-
log.debug "[NOMAD] Submitting task ${task.name} - work-dir=${task.workDirStr}"
161161
if (!task.container)
162-
throw new ProcessSubmitException("Missing container image for process `$task.processor.name`")
162+
throw new ProcessSubmitException("[NOMAD] Missing container image for process `$task.processor.name`")
163163

164164
def builder = createBashWrapper(task)
165165
builder.build()
@@ -172,7 +172,7 @@ class NomadTaskHandler extends TaskHandler implements FusionAwareTask {
172172
nomadService.submitTask(this.jobName, task, taskLauncher, taskEnv, debugPath())
173173

174174
// submit the task execution
175-
log.debug "[NOMAD] Submitted task ${task.name} with taskId=${this.jobName}"
175+
log.debug "[NOMAD] submitTask task=${task.name} ; taskId=${this.jobName} ; work-dir=${task.workDirStr}"
176176
// update the status
177177
this.status = TaskStatus.SUBMITTED
178178
}
@@ -219,7 +219,7 @@ class NomadTaskHandler extends TaskHandler implements FusionAwareTask {
219219
if (!status || delta >= 1_000) {
220220

221221
def newState = nomadService.getTaskState(jobName)
222-
log.debug "[NOMAD] taskState0 jobName=$jobName currentState=${state?.state} newState=${newState?.state}"
222+
log.debug "[NOMAD] taskState0 task=$jobName ; currentState=${state?.state} ; newState=${newState?.state}"
223223

224224
if (newState) {
225225
state = newState
@@ -244,12 +244,11 @@ class NomadTaskHandler extends TaskHandler implements FusionAwareTask {
244244
}
245245

246246

247-
248247
private void determineClientNode(){
249248
try {
250249
if ( !clientName )
251250
clientName = nomadService.getClientOfJob( jobName )
252-
log.debug "[NOMAD] determineClientNode: jobName:$jobName; clientName:$clientName"
251+
log.debug "[NOMAD] determineClientNode: jobName:$jobName ; clientName:$clientName"
253252
} catch ( Exception e ){
254253
log.debug ("[NOMAD] Unable to get the client name of job $jobName -- awaiting for a client to be assigned.")
255254
}

plugins/nf-nomad/src/test/nextflow/nomad/NomadDSLSpec.groovy renamed to plugins/nf-nomad/src/test/nextflow/nomad/MockNomadDSLSpec.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import okhttp3.mockwebserver.MockWebServer
2828
import okhttp3.mockwebserver.RecordedRequest
2929
import org.jetbrains.annotations.NotNull
3030
import org.pf4j.PluginDescriptorFinder
31+
import spock.lang.Requires
3132
import spock.lang.Shared
3233
import spock.lang.Timeout
3334
import test.Dsl2Spec
@@ -43,7 +44,8 @@ import java.util.jar.Manifest
4344
* @author : Jorge Aguilera <[email protected]>
4445
*/
4546
@Timeout(60)
46-
class NomadDSLSpec extends Dsl2Spec{
47+
@Requires({ System.getenv('NF_NOMAD_TEST_ENV') == 'mock' })
48+
class MockNomadDSLSpec extends Dsl2Spec{
4749
@Shared String pluginsMode
4850

4951
MockWebServer mockWebServer

plugins/nf-nomad/src/test/nextflow/nomad/executor/NomadSecretServiceSpec.groovy renamed to plugins/nf-nomad/src/test/nextflow/nomad/executor/MockNomadSecretServiceSpec.groovy

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,23 @@
1616
*/
1717
package nextflow.nomad.executor
1818

19-
import groovy.json.JsonOutput
20-
import groovy.json.JsonSlurper
21-
import nextflow.executor.Executor
19+
2220
import nextflow.nomad.config.NomadConfig
23-
import nextflow.processor.TaskBean
24-
import nextflow.processor.TaskConfig
25-
import nextflow.processor.TaskProcessor
26-
import nextflow.processor.TaskRun
27-
import nextflow.script.ProcessConfig
2821
import okhttp3.mockwebserver.MockResponse
2922
import okhttp3.mockwebserver.MockWebServer
23+
import spock.lang.Requires
3024
import spock.lang.Specification
3125

32-
import java.nio.file.Files
33-
import java.nio.file.Path
34-
3526
/**
3627
* Unit test for Nomad Service for Secrets requests
3728
*
3829
* Validate requests using a Mock WebServer
3930
*
4031
* @author : Jorge Aguilera <[email protected]>
4132
*/
42-
class NomadSecretServiceSpec extends Specification{
33+
34+
@Requires({ System.getenv('NF_NOMAD_TEST_ENV') == 'mock' })
35+
class MockNomadSecretServiceSpec extends Specification{
4336

4437
MockWebServer mockWebServer
4538

@@ -90,6 +83,7 @@ class NomadSecretServiceSpec extends Specification{
9083
recordedRequest2.path == "/v1/var/another%2FMySecret"
9184
}
9285

86+
@Requires({ System.getenv('NF_NOMAD_TEST_ENV') == 'mock' })
9387
void "should set a variable"(){
9488
given:
9589
def config = new NomadConfig(

plugins/nf-nomad/src/test/nextflow/nomad/executor/NomadServiceSpec.groovy renamed to plugins/nf-nomad/src/test/nextflow/nomad/executor/MockNomadServiceSpec.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import nextflow.processor.TaskRun
2727
import nextflow.script.ProcessConfig
2828
import okhttp3.mockwebserver.MockResponse
2929
import okhttp3.mockwebserver.MockWebServer
30+
import spock.lang.Requires
3031
import spock.lang.Specification
3132

3233
import java.nio.file.Files
@@ -39,7 +40,9 @@ import java.nio.file.Path
3940
*
4041
* @author : Jorge Aguilera <[email protected]>
4142
*/
42-
class NomadServiceSpec extends Specification{
43+
44+
@Requires({ System.getenv('NF_NOMAD_TEST_ENV') == 'mock' })
45+
class MockNomadServiceSpec extends Specification{
4346

4447
MockWebServer mockWebServer
4548

plugins/nf-nomad/src/test/nextflow/nomad/executor/NomadTaskHandlerSpec.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import java.nio.file.Path
3232
*
3333
* @author : Jorge Aguilera <[email protected]>
3434
*/
35+
3536
class NomadTaskHandlerSpec extends Specification{
3637

3738
void "a task should have a container"(){

plugins/nf-nomad/src/test/nextflow/nomad/models/JobConstraintsSpec.groovy renamed to plugins/nf-nomad/src/test/nextflow/nomad/models/MockJobConstraintsSpec.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import nextflow.processor.TaskRun
2929
import nextflow.script.ProcessConfig
3030
import okhttp3.mockwebserver.MockResponse
3131
import okhttp3.mockwebserver.MockWebServer
32+
import spock.lang.Requires
3233
import spock.lang.Specification
3334

34-
import java.nio.file.Files
3535
import java.nio.file.Path
3636

3737
/**
@@ -41,7 +41,9 @@ import java.nio.file.Path
4141
*
4242
* @author : Jorge Aguilera <[email protected]>
4343
*/
44-
class JobConstraintsSpec extends Specification{
44+
45+
@Requires({ System.getenv('NF_NOMAD_TEST_ENV') == 'mock' })
46+
class MockJobConstraintsSpec extends Specification{
4547

4648
MockWebServer mockWebServer
4749

validation/sun-nomadlab/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
kind: nomad
3+
dry_run: false
4+
configs:
5+
experiments:
6+
- job
7+
8+
# Signals to choose from
9+
signals:
10+
- SIGKILL
11+
12+
# Optional: namespace allowlist
13+
namespace_allowlist:
14+
- nf-nomad
15+
16+
# Optional: namespace denylist
17+
namespace_denylist:
18+
- default
19+
20+
# Optional: job type skip list
21+
job_type_skiplist:
22+
- system
23+
- service
24+
- sysbatch
25+
26+
# Optional: job name skip list
27+
# job_skiplist:
28+
# - my-job-name
29+
30+
# Optional: Add a meta tag in your nomad job "chaotic" = False to opt-out
31+
# job_meta_opt_key: chaotic

0 commit comments

Comments
 (0)