Skip to content

Commit 0dd893f

Browse files
authored
Don't persist additional job arguments. (#797)
Job arguments which are generated just before a job is launched should not be persisted to the state store. This resolves #779 and #794.
1 parent 1421bad commit 0dd893f

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

src/main/scala/org/apache/mesos/chronos/scheduler/jobs/TaskManager.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,7 @@ class TaskManager @Inject()(
173173
jobsObserver.apply(JobExpired(jobOption.get, taskId))
174174
None
175175
} else {
176-
val jobArguments = TaskUtils.getJobArgumentsForTaskId(taskId)
177-
var job = jobOption.get
178-
179-
if (jobArguments != null && !jobArguments.isEmpty) {
180-
job = JobUtils.getJobWithArguments(job, jobArguments)
181-
}
182-
183-
Some(taskId, job)
176+
Some(taskId, jobOption.get)
184177
}
185178
}
186179
}

src/main/scala/org/apache/mesos/chronos/scheduler/mesos/MesosTaskBuilder.scala

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ import org.apache.mesos.Protos.ContainerInfo.DockerInfo
99
import org.apache.mesos.Protos.Environment.Variable
1010
import org.apache.mesos.Protos._
1111
import org.apache.mesos.chronos.scheduler.config.SchedulerConfiguration
12-
import org.apache.mesos.chronos.scheduler.jobs.{
13-
BaseJob,
14-
ContainerType,
15-
Fetch,
16-
TaskUtils
17-
}
12+
import org.apache.mesos.chronos.scheduler.jobs.{Volume => _, _}
1813

1914
import scala.collection.JavaConverters._
2015
import scala.collection.Map
@@ -86,22 +81,30 @@ class MesosTaskBuilder @Inject()(val conf: SchedulerConfiguration) {
8681
if (job.executor.nonEmpty) {
8782
appendExecutorData(taskInfo, job, environment, uriCommand)
8883
} else {
84+
val jobArguments = TaskUtils.getJobArgumentsForTaskId(taskId.getValue)
85+
val jobWithCommand = if (jobArguments != null && !jobArguments.isEmpty) {
86+
JobUtils.getJobWithArguments(job, jobArguments)
87+
} else {
88+
job
89+
}
90+
8991
val command = CommandInfo.newBuilder()
90-
if (job.command.startsWith("http") || job.command.startsWith("ftp")) {
92+
if (jobWithCommand.command.startsWith("http") || jobWithCommand.command
93+
.startsWith("ftp")) {
9194
val uri1 = CommandInfo.URI
9295
.newBuilder()
93-
.setValue(job.command)
96+
.setValue(jobWithCommand.command)
9497
.setExecutable(true)
9598
.build()
9699

97100
command
98101
.addUris(uri1)
99-
.setValue(
100-
"\"." + job.command.substring(job.command.lastIndexOf("/")) + "\"")
102+
.setValue("\"." + jobWithCommand.command.substring(
103+
jobWithCommand.command.lastIndexOf("/")) + "\"")
101104
.setEnvironment(environment)
102105
} else {
103-
val jobHasCmd = !job.command.isEmpty
104-
if (jobHasCmd) command.setValue(job.command)
106+
val jobHasCmd = !jobWithCommand.command.isEmpty
107+
if (jobHasCmd) command.setValue(jobWithCommand.command)
105108

106109
command
107110
.setShell(job.shell)

0 commit comments

Comments
 (0)