Skip to content

Commit

Permalink
Expose process queue as K8s pod label [ci fast]
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso committed Dec 5, 2022
1 parent 9951fcd commit 4df8c8d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ class K8sTaskHandler extends TaskHandler implements FusionAwareTask {
result.'nextflow.io/taskName' = task.getName()
result.'nextflow.io/processName' = task.getProcessor().getName()
result.'nextflow.io/sessionId' = "uuid-${executor.getSession().uniqueId}" as String
if( task.config.queue )
result.'nextflow.io/queue' = task.config.queue
return result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,38 @@ class K8sTaskHandlerTest extends Specification {
labels.'nextflow.io/taskName' == 'hello-world-1'
labels.'nextflow.io/sessionId' instanceof String
labels.'nextflow.io/sessionId' == "uuid-${uuid.toString()}".toString()
and:
!labels.containsKey('nextflow.io/queue')
}

def 'should return process queue as a label'() {
given:
def uuid = UUID.randomUUID()
def task = Mock(TaskRun)
def exec = Mock(K8sExecutor)
def proc = Mock(TaskProcessor)
def sess = Mock(Session)
def handler = Spy(new K8sTaskHandler(executor: exec))

when:
def labels = handler.getLabels(task)
then:
handler.getRunName() >> 'pedantic-joe'
task.getName() >> 'hello-world-1'
task.getProcessor() >> proc
task.getConfig() >> new TaskConfig(queue: 'him-mem-queue')
proc.getName() >> 'hello-proc'
exec.getSession() >> sess
sess.getUniqueId() >> uuid
exec.getK8sConfig() >> [:]
and:
labels.'nextflow.io/queue' == 'him-mem-queue'
and:
labels.'nextflow.io/app' == 'nextflow'
labels.'nextflow.io/processName' == 'hello-proc'
labels.'nextflow.io/taskName' == 'hello-world-1'
labels.'nextflow.io/sessionId' instanceof String
labels.'nextflow.io/sessionId' == "uuid-${uuid.toString()}".toString()
}

def 'should delete pod if complete' () {
Expand Down

0 comments on commit 4df8c8d

Please sign in to comment.