-
Notifications
You must be signed in to change notification settings - Fork 781
Add resourceAllocation field to trace record #6973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,9 +103,7 @@ class TraceRecord implements Serializable { | |
| vol_ctxt: 'num', // -- /proc/$pid/status field 'voluntary_ctxt_switches' | ||
| inv_ctxt: 'num', // -- /proc/$pid/status field 'nonvoluntary_ctxt_switches' | ||
| hostname: 'str', | ||
| cpu_model: 'str', | ||
| accelerator: 'num', | ||
| accelerator_type: 'str' | ||
| cpu_model: 'str' | ||
| ] | ||
|
|
||
| static public Map<String,Closure<String>> FORMATTER = [ | ||
|
|
@@ -125,6 +123,7 @@ class TraceRecord implements Serializable { | |
| transient private ContainerMeta containerMeta | ||
| transient private Integer numSpotInterruptions | ||
| transient private String logStreamId | ||
| transient private Map<String,Object> resourceAllocation | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not blocking, but the naming is a bit awkward. how about |
||
|
|
||
| /** | ||
| * Convert the given value to a string | ||
|
|
@@ -638,4 +637,12 @@ class TraceRecord implements Serializable { | |
| void setContainerMeta(ContainerMeta meta) { | ||
| this.containerMeta = meta | ||
| } | ||
|
|
||
| Map<String,Object> getResourceAllocation() { | ||
| return resourceAllocation | ||
| } | ||
|
|
||
| void setResourceAllocation(Map<String,Object> value) { | ||
| this.resourceAllocation = value | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -233,11 +233,13 @@ class SeqeraTaskHandlerTest extends Specification { | |
| .type('m5.large') | ||
| .zone('us-east-1a') | ||
| .priceModel(SchedPriceModel.SPOT) | ||
| def resources = new ResourceRequirement().cpuShares(2048).memoryMiB(4096) | ||
| def attempt = new TaskAttempt() | ||
| .index(1) | ||
| .nativeId('arn:aws:ecs:us-east-1:123:task/abc') | ||
| .status(SchedTaskStatus.SUCCEEDED) | ||
| .machineInfo(machineInfo) | ||
| .resources(resources) | ||
| handler.cachedTaskState = new SchedTaskState() | ||
| .id('tsk-xyz789') | ||
| .attempts([attempt]) | ||
|
|
@@ -252,6 +254,7 @@ class SeqeraTaskHandlerTest extends Specification { | |
| trace.getMachineInfo().type == 'm5.large' | ||
| trace.getNumSpotInterruptions() == 2 | ||
| trace.getLogStreamId() == 'log-stream-xyz' | ||
| trace.getResourceAllocation() == [cpuShares: 2048, memoryMiB: 4096] | ||
| trace.getExecutorName() == 'seqera/aws' | ||
| } | ||
|
|
||
|
|
@@ -579,11 +582,92 @@ class SeqeraTaskHandlerTest extends Specification { | |
| result == [MY_VAR: 'my_val', SHARED_KEY: 'fusion_val'] | ||
| } | ||
|
|
||
| def 'should return null for getResourceAllocation when cachedTaskState is null'() { | ||
| given: | ||
| def handler = createHandler() | ||
|
|
||
| expect: | ||
| handler.getResourceAllocation() == null | ||
| } | ||
|
|
||
| def 'should return allocated resources from last task attempt'() { | ||
| given: | ||
| def handler = createHandler() | ||
| def resources = new ResourceRequirement() | ||
| .cpuShares(2048) | ||
| .memoryMiB(4096) | ||
| def attempt = new TaskAttempt() | ||
| .index(1) | ||
| .nativeId('task-1') | ||
| .status(SchedTaskStatus.SUCCEEDED) | ||
| .resources(resources) | ||
| handler.cachedTaskState = new SchedTaskState().attempts([attempt]) | ||
|
|
||
| when: | ||
| def result = handler.getResourceAllocation() | ||
|
|
||
| then: | ||
| result != null | ||
| result.cpuShares == 2048 | ||
| result.memoryMiB == 4096 | ||
| } | ||
|
|
||
| def 'should use last attempt resources when multiple attempts exist'() { | ||
| given: | ||
| def handler = createHandler() | ||
| def resources1 = new ResourceRequirement().cpuShares(1024).memoryMiB(2048) | ||
| def resources2 = new ResourceRequirement().cpuShares(4096).memoryMiB(8192) | ||
| def attempt1 = new TaskAttempt().index(1).nativeId('task-1').status(SchedTaskStatus.FAILED).resources(resources1) | ||
| def attempt2 = new TaskAttempt().index(2).nativeId('task-2').status(SchedTaskStatus.SUCCEEDED).resources(resources2) | ||
| handler.cachedTaskState = new SchedTaskState().attempts([attempt1, attempt2]) | ||
|
|
||
| when: | ||
| def result = handler.getResourceAllocation() | ||
|
|
||
| then: | ||
| result.cpuShares == 4096 | ||
| result.memoryMiB == 8192 | ||
| } | ||
|
|
||
| def 'should fallback to taskState resourceRequirement when no attempts'() { | ||
| given: | ||
| def handler = createHandler() | ||
| def resources = new ResourceRequirement().cpuShares(1024).memoryMiB(2048).time('1h') | ||
| handler.cachedTaskState = new SchedTaskState() | ||
| .attempts([]) | ||
| .resourceAllocation(resources) | ||
|
|
||
| when: | ||
| def result = handler.getResourceAllocation() | ||
|
|
||
| then: | ||
| result.cpuShares == 1024 | ||
| result.memoryMiB == 2048 | ||
| result.time == '1h' | ||
| } | ||
|
|
||
| def 'should fallback to taskState resourceRequirement when last attempt has no resources'() { | ||
| given: | ||
| def handler = createHandler() | ||
| def attempt = new TaskAttempt().index(1).nativeId('task-1').status(SchedTaskStatus.SUCCEEDED) | ||
| def resources = new ResourceRequirement().cpuShares(512).memoryMiB(1024) | ||
| handler.cachedTaskState = new SchedTaskState() | ||
| .attempts([attempt]) | ||
| .resourceAllocation(resources) | ||
|
|
||
| when: | ||
| def result = handler.getResourceAllocation() | ||
|
|
||
| then: | ||
| result.cpuShares == 512 | ||
| result.memoryMiB == 1024 | ||
| } | ||
|
|
||
| def 'should return granted time from resource requirement'() { | ||
| given: | ||
| def handler = createHandler() | ||
| handler.cachedTaskState = new SchedTaskState() | ||
| .resourceRequirement(new ResourceRequirement().time('2h')) | ||
| .resourceAllocation(new ResourceRequirement().time('2h')) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should |
||
|
|
||
| expect: | ||
| handler.getGrantedTime() == Duration.of('2h').toMillis() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields denoted the requested accelerators. Now that you are moving them into the allocated resources, will they denote the accelerators allocated by sched?