Skip to content

Commit

Permalink
Merge pull request #4 from criteo-forks/partialUpdate
Browse files Browse the repository at this point in the history
Make sure networkBandwidth can be specified in all scenarii
  • Loading branch information
clems4ever authored Sep 12, 2018
2 parents d8a5d97 + 34c44d3 commit d547cb9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/scala/mesosphere/marathon/raml/AppConversion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ trait AppConversion extends ConstraintConversion with EnvVarConversion with Heal
maxLaunchDelaySeconds = service.whenOrElse(_.hasMaxLaunchDelay, m => (m.getMaxLaunchDelay / 1000L).toInt, App.DefaultMaxLaunchDelaySeconds),
mem = resourcesMap.getOrElse(Resource.MEM, App.DefaultMem),
gpus = resourcesMap.get(Resource.GPUS).fold(App.DefaultGpus)(_.toInt),
networkBandwidth = resourcesMap.get(Resource.NETWORK_BANDWIDTH).fold(App.DefaultNetworkBandwidth)(_.toInt),
ipAddress = service.when(_.hasOBSOLETEIpAddress, _.getOBSOLETEIpAddress.toRaml).orElse(App.DefaultIpAddress),
networks = service.whenOrElse(_.getNetworksCount > 0, _.getNetworksList.toRaml, App.DefaultNetworks),
ports = None, // not stored in protobuf
Expand Down Expand Up @@ -384,6 +385,7 @@ trait AppConversion extends ConstraintConversion with EnvVarConversion with Heal
mem = Some(app.mem),
disk = Some(app.disk),
gpus = Some(app.gpus),
networkBandwidth = Some(app.networkBandwidth),
executor = Some(app.executor),
constraints = Some(app.constraints),
fetch = Some(app.fetch),
Expand Down
7 changes: 6 additions & 1 deletion src/main/scala/mesosphere/marathon/state/AppDefinition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ case class AppDefinition(
val memResource = ScalarResource(Resource.MEM, resources.mem)
val diskResource = ScalarResource(Resource.DISK, resources.disk)
val gpusResource = ScalarResource(Resource.GPUS, resources.gpus.toDouble)
val networkBandwidthResource = ScalarResource(Resource.NETWORK_BANDWIDTH, resources.networkBandwidth.toDouble)
val appLabels = labels.map {
case (key, value) =>
mesos.Parameter.newBuilder
Expand All @@ -161,6 +162,7 @@ case class AppDefinition(
.addResources(memResource)
.addResources(diskResource)
.addResources(gpusResource)
.addResources(networkBandwidthResource)
.addAllHealthChecks(healthChecks.map(_.toProto).asJava)
.setUpgradeStrategy(upgradeStrategy.toProto)
.addAllDependencies(dependencies.map(_.toString).asJava)
Expand Down Expand Up @@ -262,7 +264,8 @@ case class AppDefinition(
cpus = resourcesMap.getOrElse(Resource.CPUS, this.resources.cpus),
mem = resourcesMap.getOrElse(Resource.MEM, this.resources.mem),
disk = resourcesMap.getOrElse(Resource.DISK, this.resources.disk),
gpus = resourcesMap.getOrElse(Resource.GPUS, this.resources.gpus.toDouble).toInt
gpus = resourcesMap.getOrElse(Resource.GPUS, this.resources.gpus.toDouble).toInt,
networkBandwidth = resourcesMap.getOrElse(Resource.NETWORK_BANDWIDTH, this.resources.networkBandwidth.toDouble).toInt
),
env = envMap ++ envRefs,
fetch = proto.getCmd.getUrisList.map(FetchUri.fromProto)(collection.breakOut),
Expand Down Expand Up @@ -559,6 +562,7 @@ object AppDefinition extends GeneralPurposeCombinators {
appDef.instances should be >= 0
appDef.resources.disk as "disk" should be >= 0.0
appDef.resources.gpus as "gpus" should be >= 0
appDef.resources.networkBandwidth as "networkBandwidth" should be >= 0
appDef.secrets is valid(Secret.secretsValidator)
appDef.secrets is empty or featureEnabled(enabledFeatures, Features.SECRETS)
appDef.env is valid(EnvVarValue.envValidator)
Expand Down Expand Up @@ -606,6 +610,7 @@ object AppDefinition extends GeneralPurposeCombinators {
from.resources.mem == to.resources.mem &&
from.resources.disk == to.resources.disk &&
from.resources.gpus == to.resources.gpus &&
from.resources.networkBandwidth == to.resources.networkBandwidth &&
from.hostPorts.flatten.toSet == to.hostPorts.flatten.toSet &&
from.requirePorts == to.requirePorts
}
Expand Down

0 comments on commit d547cb9

Please sign in to comment.