Skip to content

Commit

Permalink
Merge 06ff421 into 116dd19
Browse files Browse the repository at this point in the history
  • Loading branch information
meichstedt committed Aug 30, 2016
2 parents 116dd19 + 06ff421 commit 6e46f27
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
21 changes: 9 additions & 12 deletions src/main/scala/mesosphere/marathon/state/AppDefinition.scala
Expand Up @@ -7,7 +7,7 @@ import com.wix.accord.combinators.GeneralPurposeCombinators
import com.wix.accord.dsl._
import mesosphere.marathon.Protos.Constraint
import mesosphere.marathon.Protos.HealthCheckDefinition.Protocol
import mesosphere.marathon.state.Container.{ Mesos, MesosAppC, MesosDocker }
import mesosphere.marathon.state.Container.Docker
// scalastyle:off
import mesosphere.marathon.api.serialization.{ ContainerSerializer, EnvVarRefSerializer, PortDefinitionSerializer, ResidencySerializer, SecretsSerializer }
// scalastyle:on
Expand Down Expand Up @@ -684,18 +684,15 @@ object AppDefinition extends GeneralPurposeCombinators {
(appDef.isResident is false) or (appDef.upgradeStrategy is UpgradeStrategy.validForResidentTasks)
}

private val complyWithGpuRules: Validator[AppDefinition] = conditional[AppDefinition](_.gpus > 0) {
isTrue[AppDefinition]("GPU resources only work with the Mesos containerizer") { app =>
app.container.exists{
_ match {
case _: MesosDocker => true
case _: MesosAppC => true
case _: Mesos => true
case _ => false
private val complyWithGpuRules: Validator[AppDefinition] =
conditional[AppDefinition](_.gpus > 0) {
isTrue[AppDefinition]("GPU resources only work with the Mesos containerizer") { app =>
app.container match {
case Some(_: Docker) => false
case _ => true
}
}
} and featureEnabled(Features.GPU_RESOURCES)
}
} and featureEnabled(Features.GPU_RESOURCES)
}

private val complyWithConstraintRules: Validator[Constraint] = new Validator[Constraint] {
import Constraint.Operator._
Expand Down
Expand Up @@ -430,6 +430,13 @@ class AppDefinitionTest extends MarathonSpec with Matchers {
)

shouldNotViolate(app, "/", "GPU resources only work with the Mesos containerizer")

app = correct.copy(
gpus = 1,
container = None
)

shouldNotViolate(app, "/", "GPU resources only work with the Mesos containerizer")
}

test("SerializationRoundtrip empty") {
Expand Down
Expand Up @@ -62,7 +62,7 @@ class ExpungeOverdueLostTasksActorTest extends MarathonSpec with GivenWhenThen w

test("a unreachable task with more then 24 hours with no status update should be killed") {
Given("one unreachable, one running tasks")
val running = MarathonTestHelper.minimalRunning("/running1".toPath, since= Timestamp.apply(0))
val running = MarathonTestHelper.minimalRunning("/running1".toPath, since = Timestamp.apply(0))
val unreachable = MarathonTestHelper.minimalUnreachableTask("/running2".toPath, since = Timestamp.apply(0))

taskTracker.tasksByApp()(any[ExecutionContext]) returns Future.successful(TasksByApp.forTasks(running, unreachable))
Expand Down

0 comments on commit 6e46f27

Please sign in to comment.