Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Fixes #1829 - Only override acceptedResourceRoles when supplied in up…
Browse files Browse the repository at this point in the history
…date
  • Loading branch information
Peter Kolloch committed Jul 31, 2015
1 parent 5c6b2cc commit a8e7b87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/mesosphere/marathon/api/v2/AppUpdate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ case class AppUpdate(
dependencies.map(_.map(_.canonicalPath(app.id))).getOrElse(app.dependencies),
upgradeStrategy.getOrElse(app.upgradeStrategy),
labels.getOrElse(app.labels),
acceptedResourceRoles,
acceptedResourceRoles.orElse(app.acceptedResourceRoles),
version.getOrElse(Timestamp.now())
)

Expand Down
12 changes: 11 additions & 1 deletion src/test/scala/mesosphere/marathon/api/v2/AppUpdateTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import javax.validation.Validation
import mesosphere.marathon.MarathonSpec
import mesosphere.marathon.health.HealthCheck
import mesosphere.marathon.state.Container._
import mesosphere.marathon.state.{ Container, PathId, Timestamp, UpgradeStrategy }
import mesosphere.marathon.state.{ AppDefinition, Container, PathId, Timestamp, UpgradeStrategy }
import mesosphere.marathon.state.PathId._
import org.apache.mesos.{ Protos => mesos }

Expand Down Expand Up @@ -140,4 +140,14 @@ class AppUpdateTest extends MarathonSpec {
AppUpdate(cmd = Some("foo"), version = Some(Timestamp.now()))
}
}

test("acceptedResourceRoles of update is only applied when != None") {
val app = AppDefinition(id = PathId("withAcceptedRoles"), acceptedResourceRoles = Some(Set("a")))

val unchanged = AppUpdate().apply(app).copy(version = app.version)
assert(unchanged == app)

val changed = AppUpdate(acceptedResourceRoles = Some(Set("b"))).apply(app).copy(version = app.version)
assert(changed == app.copy(acceptedResourceRoles = Some(Set("b"))))
}
}

0 comments on commit a8e7b87

Please sign in to comment.