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

Rmirica/add port mapping #119

Merged
merged 4 commits into from
Sep 2, 2016

Conversation

mrares
Copy link
Contributor

@mrares mrares commented Aug 31, 2016

I gave a shot at this naive implementation of a portMapping allocator.

It expects a "ports":[{"containerPort":<internal port>, "protocol": "<protocol>"}] definition in the task POST json.

It will select the first available ports from the mesos offer and allocate them accordingly.

I've abandoned the attempt to write an offer matcher for port-range (I don't expect this to be a problem in practice but this should be solved)

@mrares mrares mentioned this pull request Aug 31, 2016
@keis
Copy link
Collaborator

keis commented Aug 31, 2016

Thank @mrares I'll take a look at this later today.

Also looks like you got some rewritten old commits in the PR could you rebase on top of master and drop those?

var portResources []*mesos.Value_Range
var portMapping []*mesos.ContainerInfo_DockerInfo_PortMapping

if(len(task.Ports) > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a quite big block of code to inline in this function we should try to break it up.

For an initial suggestion it could be broken down into these steps (which each could be their own function)

  • a) Get N ports from an offer
  • b) Construct portMappings from the ports definition and a list of ports
  • c) Construct ranges resource of ports from list of ports

as an added bonus a could also be reused to implement the matcher

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem I had was with C... if it's not done in the same context as A it may lead to non-overlapping ranges (ie: you get offer (3001:3003),(3007:3010) and you need 5 ports, the list will be [3001, 2, 3, 7, 8] and the resulting range (3001, 3008) which will violate the offer)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course a helper function that finds contiguous sequences in a list would do...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. that's true. However reconstructing that into two ranges by finding sequences should be doable. There's also the really simple method of mapping that into 5 1-length ranges like (3001-3001, 3002-3002, ...) which I think would still be legal?

@mrares mrares force-pushed the rmirica/add_portMapping branch from 043bee4 to a704135 Compare September 1, 2016 06:49
@alde
Copy link
Contributor

alde commented Sep 1, 2016

Hi, sorry that my merge introduced some conflicts in your branch, but I think they should be fairly easily solvable.

I tried to reduce the complexity of the CreateTaskInfo function and make it easier to follow.

@mrares mrares force-pushed the rmirica/add_portMapping branch from 07ec553 to a939dfa Compare September 2, 2016 07:04
@mrares
Copy link
Contributor Author

mrares commented Sep 2, 2016

I solved the conflicts, factored out the buildPorts function

@keis
Copy link
Collaborator

keis commented Sep 2, 2016

Ok. great stuff @mrares

Some final points, could you remove the commented block in matcher.go and squash it to the commit that introduces that and then update the readme with the new api?

@mrares
Copy link
Contributor Author

mrares commented Sep 2, 2016

Sure, question about the API though, should I stay with containerPort (the underlying name in the mesos API) or change it to container_port for consistency with the eremetic api?

@mrares mrares force-pushed the rmirica/add_portMapping branch from a939dfa to 58c2dc5 Compare September 2, 2016 07:39
@keis
Copy link
Collaborator

keis commented Sep 2, 2016

ah good point. we should go with the snake_case version

On Fri, 2 Sep 2016, 09:37 Rares Mirica, [email protected] wrote:

Sure, question about the API though, should I stay with containerPort (the
underlying name in the mesos API) or change it to container_port for
consistency with the eremetic api?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#119 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAHohhKp_6O6Z5OXF4oc8BDazqzKw0cYks5ql9IngaJpZM4Jxr-D
.

@mrares mrares force-pushed the rmirica/add_portMapping branch from 58c2dc5 to 4e481f2 Compare September 2, 2016 07:52
@mrares
Copy link
Contributor Author

mrares commented Sep 2, 2016

done

@keis
Copy link
Collaborator

keis commented Sep 2, 2016

LGTM

@keis keis merged commit 2b36c09 into eremetic-framework:master Sep 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants