Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
add sched idle
Browse files Browse the repository at this point in the history
  • Loading branch information
sargun committed Jun 6, 2018
1 parent 9c0cc71 commit 7a00f08
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
19 changes: 13 additions & 6 deletions executor/mock/jobrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type JobInput struct {
// IgnoreLaunchGuard sets the V3 engine flag on the job
IgnoreLaunchGuard bool
// Batch sets batch mode on the task
Batch bool
Batch string
// StopTimeoutSeconds is the duration we wait after SIGTERM for the container to exit
KillWaitSeconds uint32
}
Expand Down Expand Up @@ -194,11 +194,18 @@ func (jobRunner *JobRunner) StartJob(jobInput *JobInput) *JobRunResponse {
NetworkConfigInfo: &titus.ContainerInfo_NetworkConfigInfo{
EniLabel: protobuf.String("1"),
},
IamProfile: protobuf.String("arn:aws:iam::0:role/DefaultContainerRole"),
Capabilities: jobInput.Capabilities,
TitusProvidedEnv: env,
IgnoreLaunchGuard: protobuf.Bool(jobInput.IgnoreLaunchGuard),
Batch: protobuf.Bool(jobInput.Batch),
IamProfile: protobuf.String("arn:aws:iam::0:role/DefaultContainerRole"),
Capabilities: jobInput.Capabilities,
TitusProvidedEnv: env,
IgnoreLaunchGuard: protobuf.Bool(jobInput.IgnoreLaunchGuard),
PassthroughAttributes: make(map[string]string),
}

if jobInput.Batch != "" {
ci.Batch = protobuf.Bool(true)
}
if jobInput.Batch == "idle" {
ci.PassthroughAttributes["titusParameter.agent.batchPriority"] = "idle"
}

if jobInput.KillWaitSeconds > 0 {
Expand Down
16 changes: 15 additions & 1 deletion executor/mock/standalone/standalone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func TestStandalone(t *testing.T) {
testOOMKill,
testSchedBatch,
testSchedNormal,
testSchedIdle,
}
for _, fun := range testFunctions {
fullName := runtime.FuncForPC(reflect.ValueOf(fun).Pointer()).Name()
Expand Down Expand Up @@ -584,7 +585,7 @@ func testSchedBatch(t *testing.T, jobID string) {
Version: ubuntu.tag,
Entrypoint: `/bin/bash -c 'schedtool 0 | grep SCHED_BATCH | grep 19'`,
JobID: jobID,
Batch: true,
Batch: "true",
}
if !mock.RunJobExpectingSuccess(ji) {
t.Fail()
Expand All @@ -602,3 +603,16 @@ func testSchedNormal(t *testing.T, jobID string) {
t.Fail()
}
}

func testSchedIdle(t *testing.T, jobID string) {
ji := &mock.JobInput{
ImageName: ubuntu.name,
Version: ubuntu.tag,
Entrypoint: `/bin/bash -c 'schedtool 0 | grep SCHED_IDLE'`,
JobID: jobID,
Batch: "idle",
}
if !mock.RunJobExpectingSuccess(ji) {
t.Fail()
}
}
6 changes: 5 additions & 1 deletion executor/runtime/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,11 @@ func (r *DockerRuntime) dockerConfig(c *runtimeTypes.Container, binds []string,
}

if c.TitusInfo.GetBatch() {
c.Env["TITUS_BATCH"] = "true"
if c.TitusInfo.GetPassthroughAttributes()["titusParameter.agent.batchPriority"] == "idle" {
c.Env["TITUS_BATCH"] = "idle"
} else {
c.Env["TITUS_BATCH"] = "true"
}
}

// This must got after all setup
Expand Down

0 comments on commit 7a00f08

Please sign in to comment.