HomeMesosphereNo notifications. 4 unresolved issues.

Enable port-mapping for Mesos container in Marathon on multiple container networks
ClosedAll Users

Authored by timcharper on Apr 5 2017, 9:33 AM.

Details

Summary

This change adds support for port mappings with multiple container networks by adding the "networkName" field to portMapping. When multiple container networks are specified, this field is required for any portMapping whose hostPort is defined. If only one network is defined, it is optional.

Test Plan

create cluster with multiple container networks. launch container with app that binds on different networks.

Diff Detail

Repository
rMARATHON marathon
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
There are a very large number of changes, so older changes are hidden. Show Older Changes
This revision now requires changes to proceed.Apr 18 2017, 2:26 AM
jdef requested changes to this revision.Apr 18 2017, 3:43 AM

mostly requesting changes because I think we dropped support for port DI for apps w/ host networking

src/main/scala/mesosphere/mesos/PortDiscovery.scala
17

this will be difficult without taking into account servicePort and requirePorts. let's chat about how to move forward

28

where's the implicit reader object for PortDefinition?

89

I think we're getting away from using for constructs in favor of map/flatMap

120

this func lost support for portDefinitions? that's not right...

src/test/scala/mesosphere/UnitTest.scala
80

nit: can we have a better name for template .. like message?

src/test/scala/mesosphere/mesos/PortDiscoveryTest.scala
170

nice. can we have a test for app w/ host networking (that uses PortDefinition)? I suspect adding one (without changing any of the DI generation code) will fail because of the missing support for PortDefinition

timcharper updated this revision to Diff 2703.Apr 18 2017, 7:59 AM

fix host ports DI generation

timcharper updated this revision to Diff 2704.Apr 18 2017, 8:09 AM

tuple reader was the worst idea ever

jenkins requested changes to this revision.Apr 18 2017, 8:11 AM
This revision now requires changes to proceed.Apr 18 2017, 8:11 AM
timcharper updated this revision to Diff 2705.Apr 18 2017, 8:15 AM

some comments

timcharper updated this revision to Diff 2706.Apr 18 2017, 8:22 AM
timcharper marked 6 inline comments as done.

code comment

jenkins requested changes to this revision.Apr 18 2017, 8:23 AM
This revision now requires changes to proceed.Apr 18 2017, 8:23 AM
timcharper updated this revision to Diff 2707.Apr 18 2017, 8:24 AM
timcharper marked 3 inline comments as done.

update UnitTest containerViolation param name

src/main/scala/mesosphere/mesos/PortDiscovery.scala
28

added

89

we should update our contributing.md file, in which it explicitly says:

BAD:
xs.flatMap(_.flatMap(_.map(_.z))) // replace with a for comprehension
171
timcharper updated this revision to Diff 2708.Apr 18 2017, 8:26 AM
timcharper marked 2 inline comments as done.

another commentr

timcharper updated this revision to Diff 2709.Apr 18 2017, 8:27 AM
timcharper marked 2 inline comments as done.

...

timcharper marked 5 inline comments as done.Apr 18 2017, 8:28 AM
jenkins requested changes to this revision.Apr 18 2017, 8:28 AM
This revision now requires changes to proceed.Apr 18 2017, 8:28 AM
jdef added a comment.Apr 18 2017, 3:24 PM

changeset looks great. minor changes requested

docs/docs/networking.md
148

nice

src/main/scala/mesosphere/marathon/state/Container.scala
72

only requirements apply when hostPort is set (networkNames must be a single-item list) and there are multiple networks in use by the app/pod. there's not enough "context" in this class to add a require or assume assertion because we don't have the list of networks used by the app/pod. but cleaning up the comment a bit would be appreciated

90

I think we need the equivalent of this (uniqueProtocols) for the RAML ContainerPortMapping validator in AppValidation

src/main/scala/mesosphere/mesos/PortDiscovery.scala
89

agreed. JIRA?

157

nit: s not needed, no substitution

timcharper marked 7 inline comments as done.Apr 18 2017, 6:24 PM
timcharper added inline comments.
src/main/scala/mesosphere/marathon/state/Container.scala
72

I see what you're saying. Yes, the context is a single PortMapping here, and the requirement concern is wider.

90

I don't think we do.

In RAML, it's an enum. Only three values are allowed:

docs/docs/rest-api/public/api/v2/types/stringTypes.raml

  39 |   NetworkProtocol:
  40 |     type: string
  41 |     enum: [tcp, udp, "udp,tcp"]
  42 |     description: Protocol of the port (tcp, udp)
  43 |     default: tcp
  44 |   TaskLostBehavior:
src/main/scala/mesosphere/mesos/PortDiscovery.scala
89
89

great; earlier, we discussed only rejecting style changes that were documented. Does that apply in this case?

timcharper updated this revision to Diff 2719.Apr 18 2017, 6:25 PM
timcharper marked 2 inline comments as done.

rebase; integrate changes

jenkins requested changes to this revision.Apr 18 2017, 6:25 PM
This revision now requires changes to proceed.Apr 18 2017, 6:25 PM
jdef accepted this revision.Apr 18 2017, 8:49 PM
                  *     .--.
                       / /  `
      +               | |
             '         \ \__,
         *          +   '--'  *
             +   /\
+              .'  '.   *
       *      /======\      +
             ;:.  _   ;
             |:. (_)  |
             |:.  _   |
   +         |:. (_)  |          *
             ;:.      ;
           .' \:.    / `.
          / .-'':._.'`-. \
          |/    /||\    \|
    jgs _..--"""````"""--.._
  _.-'``                    ``'-._
-'                                '-
src/main/scala/mesosphere/marathon/state/Container.scala
90

you're right. thanks for keeping me honest :)

src/main/scala/mesosphere/mesos/PortDiscovery.scala
89

i won't reject for this

aquamatthias accepted this revision.Apr 19 2017, 2:26 PM

Thanks!
James already did a great job in reviewing this PR.
Nice tests as well.

timcharper updated this revision to Diff 2755.Apr 19 2017, 9:57 PM

disable retry test logic in attempt to get sane pass / fail behavior

jenkins requested changes to this revision.Apr 19 2017, 9:58 PM
This revision now requires changes to proceed.Apr 19 2017, 9:58 PM
timcharper updated this revision to Diff 2760.Apr 19 2017, 10:52 PM

bring back retry-on-failed

This revision is now accepted and ready to land.Apr 19 2017, 10:54 PM
jenkins requested changes to this revision.Apr 19 2017, 10:54 PM
This revision now requires changes to proceed.Apr 19 2017, 10:54 PM
This revision was automatically updated to reflect the committed changes.