Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Marathon base version to 1.11 #7219

Merged
merged 3 commits into from Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/scala/mesosphere/marathon/BuildInfo.scala
Expand Up @@ -8,7 +8,7 @@ import mesosphere.marathon.io.IO

case object BuildInfo {
private val marathonJar = "\\bmesosphere\\.marathon\\.marathon-[0-9.]+".r
val DefaultBuildVersion = SemVer(1, 10, 0, Some("SNAPSHOT"))
val DefaultBuildVersion = SemVer(1, 11, 0, Some("SNAPSHOT"))

/**
* sbt-native-package provides all of the files as individual JARs. By default, `getResourceAsStream` returns the
Expand Down
145 changes: 0 additions & 145 deletions src/main/scala/mesosphere/marathon/api/EndpointsHelper.scala

This file was deleted.

30 changes: 3 additions & 27 deletions src/main/scala/mesosphere/marathon/api/v2/AppNormalization.scala
Expand Up @@ -205,18 +205,6 @@ object AppNormalization {
else c
}

def sanitizeAcceptedResourceRoles(app: App, effectiveRole: String): Option[Set[String]] = {
app.acceptedResourceRoles.map { roles =>
val sanitized = roles.filter(role => role == "*" || role == effectiveRole)

// This method is only called when [[DeprecatedFeatures.sanitizeAcceptedResourceRoles]] is ON. In this
// case we not only filter out invalid roles, but also fallback to the default (*) one. Note that acceptedResourceRoles
// is about reservations and NOT allocation, so the default one is (*) and not (--mesos_role)
if (sanitized.isEmpty) Set(ResourceRole.Unreserved)
else sanitized
}
}

def maybeDropPortMappings(c: Container, networks: Seq[Network]): Container =
// empty networks Seq defaults to host-mode later on, so consider it now as indicating host-mode networking
if (networks.exists(_.mode == NetworkMode.Host) || networks.isEmpty) c.copy(portMappings = None) else c
Expand Down Expand Up @@ -323,16 +311,7 @@ object AppNormalization {
Normalization { app =>
val role = app.role.getOrElse(config.defaultRole)

// sanitize accepted resource roles if enabled
val acceptedResourceRoles =
if (config.sanitizeAcceptedResourceRoles) {
sanitizeAcceptedResourceRoles(app, role)
} else app.acceptedResourceRoles

app.copy(
role = Some(role),
acceptedResourceRoles = acceptedResourceRoles
)
app.copy(role = Some(role))
}

def forPostValidation(config: Config): Normalization[App] =
Expand Down Expand Up @@ -368,16 +347,14 @@ object AppNormalization {
def mesosBridgeName: String
def enabledFeatures: Set[String]
def defaultRole: Role
def sanitizeAcceptedResourceRoles: Boolean
}

/** static app normalization configuration */
case class Configuration(
defaultNetworkName: Option[String],
override val mesosBridgeName: String,
enabledFeatures: Set[String],
defaultRole: Role,
sanitizeAcceptedResourceRoles: Boolean
defaultRole: Role
) extends Config {}

object Configuration {
Expand All @@ -386,8 +363,7 @@ object AppNormalization {
config.defaultNetworkName.toOption,
config.mesosBridgeName(),
config.availableFeatures,
defaultRole,
config.availableDeprecatedFeatures.isEnabled(DeprecatedFeatures.sanitizeAcceptedResourceRoles)
defaultRole
)
}

Expand Down
30 changes: 1 addition & 29 deletions src/main/scala/mesosphere/marathon/api/v2/AppTasksResource.scala
Expand Up @@ -5,8 +5,7 @@ import javax.inject.Inject
import javax.servlet.http.HttpServletRequest
import javax.ws.rs._
import javax.ws.rs.container.{AsyncResponse, Suspended}
import javax.ws.rs.core.{Context, MediaType, Response}
import mesosphere.marathon.api.EndpointsHelper.ListTasks
import javax.ws.rs.core.{Context, MediaType}
import mesosphere.marathon.api._
import mesosphere.marathon.core.appinfo.EnrichedTask
import mesosphere.marathon.core.group.GroupManager
Expand Down Expand Up @@ -81,33 +80,6 @@ class AppTasksResource @Inject() (
.map(_.iterator.flatten.toVector)
}

@GET
@Produces(Array(RestResource.TEXT_PLAIN_LOW))
def indexTxt(
@PathParam("appId") appId: String,
@DefaultValue("") @QueryParam("containerNetworks") containerNetworks: String = "",
@Context req: HttpServletRequest,
@Suspended asyncResponse: AsyncResponse
): Unit =
sendResponse(asyncResponse) {
async {
if (config.availableDeprecatedFeatures.isEnabled(DeprecatedFeatures.textPlainTasks)) {
implicit val identity = await(authenticatedAsync(req))
val id = appId.toAbsolutePath
val instancesBySpec = await(instanceTracker.instancesBySpec)
withAuthorization(ViewRunSpec, groupManager.app(id), unknownApp(id)) { app =>
val data = ListTasks(instancesBySpec, Seq(app))
ok(EndpointsHelper.appsToEndpointString(data, containerNetworks.split(",").toSet))
}
} else {
status(
Response.Status.NOT_ACCEPTABLE,
s"The text/plain output is deprecated. It can be enabled via ${DeprecatedFeatures.textPlainTasks.key}."
)
}
}
}

@DELETE
def deleteMany(
@PathParam("appId") appId: String,
Expand Down
15 changes: 3 additions & 12 deletions src/main/scala/mesosphere/marathon/api/v2/PodNormalization.scala
Expand Up @@ -27,18 +27,15 @@ object PodNormalization {
/** dynamic pod normalization configuration, useful for migration and/or testing */
trait Config extends NetworkNormalization.Config {
def roleSettings: RoleSettings
def sanitizeAcceptedResourceRoles: Boolean
}

case class Configuration(defaultNetworkName: Option[String], roleSettings: RoleSettings, sanitizeAcceptedResourceRoles: Boolean)
extends Config
case class Configuration(defaultNetworkName: Option[String], roleSettings: RoleSettings) extends Config

object Configuration {
def apply(config: MarathonConf, roleSettings: RoleSettings): Config =
Configuration(
config.defaultNetworkName.toOption,
roleSettings,
config.availableDeprecatedFeatures.isEnabled(DeprecatedFeatures.sanitizeAcceptedResourceRoles)
roleSettings
)
}

Expand Down Expand Up @@ -106,13 +103,7 @@ object PodNormalization {
val normalized = if (hasPersistentVolumes) {
Some(normalizeUpgradeAndUnreachableStrategy(pod))
} else pod.scheduling

// sanitize accepted resource roles if enabled
if (config.sanitizeAcceptedResourceRoles) {
normalized.map { scheduling =>
scheduling.copy(placement = sanitizeAcceptedResourceRoles(scheduling.placement, effectiveRole))
}
} else normalized
normalized
}

def apply(config: Config): Normalization[Pod] =
Expand Down
28 changes: 1 addition & 27 deletions src/main/scala/mesosphere/marathon/api/v2/TasksResource.scala
Expand Up @@ -8,8 +8,7 @@ import javax.servlet.http.HttpServletRequest
import javax.ws.rs._
import javax.ws.rs.container.{AsyncResponse, Suspended}
import javax.ws.rs.core.{Context, MediaType, Response}
import mesosphere.marathon.api.EndpointsHelper.ListTasks
import mesosphere.marathon.api.{EndpointsHelper, TaskKiller, _}
import mesosphere.marathon.api.{TaskKiller, _}
import mesosphere.marathon.core.appinfo.EnrichedTask
import mesosphere.marathon.core.condition.Condition
import mesosphere.marathon.core.group.GroupManager
Expand Down Expand Up @@ -89,31 +88,6 @@ class TasksResource @Inject() (
}
}

@GET
@Produces(Array(RestResource.TEXT_PLAIN_LOW))
def indexTxt(
@DefaultValue("") @QueryParam("containerNetworks") containerNetworks: String = "",
@Context req: HttpServletRequest,
@Suspended asyncResponse: AsyncResponse
): Unit =
sendResponse(asyncResponse) {
async {
if (config.availableDeprecatedFeatures.isEnabled(DeprecatedFeatures.textPlainTasks)) {
implicit val identity = await(authenticatedAsync(req))
val instancesBySpec = await(instanceTracker.instancesBySpec)
val rootGroup = groupManager.rootGroup()
val data = ListTasks(instancesBySpec, rootGroup.transitiveApps.iterator.filter(app => isAuthorized(ViewRunSpec, app)).toSeq)

ok(EndpointsHelper.appsToEndpointString(data, containerNetworks.split(",").toSet))
} else {
status(
Response.Status.NOT_ACCEPTABLE,
s"The text/plain output is deprecated. It can be enabled via ${DeprecatedFeatures.textPlainTasks.key}."
)
}
}
}

@POST
@Produces(Array(MediaType.APPLICATION_JSON))
@Consumes(Array(MediaType.APPLICATION_JSON))
Expand Down