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

Allow different services to use the same host-mode port #2177

Merged
merged 1 commit into from
May 11, 2017

Conversation

aaronlehmann
Copy link
Collaborator

Relax the validation in controlapi to allow two services to use the same host-mode published port.

Add a scheduler filter so that tasks from these services land on different nodes.

cc @aboch @pvnovarese @aluzzardi @dongluochen

@codecov
Copy link

codecov bot commented May 10, 2017

Codecov Report

Merging #2177 into master will increase coverage by 0.19%.
The diff coverage is 85.93%.

@@            Coverage Diff            @@
##           master   #2177      +/-   ##
=========================================
+ Coverage   59.91%   60.1%   +0.19%     
=========================================
  Files         119     119              
  Lines       19709   19762      +53     
=========================================
+ Hits        11808   11878      +70     
+ Misses       6558    6541      -17     
  Partials     1343    1343

@aboch
Copy link

aboch commented May 11, 2017

Looks good to me

// If the publish mode is host, it is better to leave the collision check
// to the scheduler, given multiple services with same port in host publish
// mode can coexist.
if pc.PublishMode == api.PublishModeHost {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to add the same check at line 539?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed, thanks

@dongluochen
Copy link
Contributor

How do you handle mode host conflicts with mode ingress? If a port is already taken by mode ingress, do you fail the new request for mode host? And vice versa?

@aaronlehmann
Copy link
Collaborator Author

How do you handle mode host conflicts with mode ingress? If a port is already taken by mode ingress, do you fail the new request for mode host? And vice versa?

Currently the PR does not do this, but we could disallow host-mode ports from conflicting with ingress ports.

@dongluochen
Copy link
Contributor

Agree. I think mode host and mode ingress conflicts should fail right away.

Relax the validation in controlapi to allow two services to use the same
host-mode published port.

Add a scheduler filter so that tasks from these services land on
different nodes.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
@aaronlehmann
Copy link
Collaborator Author

@dongluochen: Updated, PTAL

switch pc.PublishMode {
case api.PublishModeHost:
if _, ok := ingressPorts[pcToStruct(pc)]; ok {
return grpc.Errorf(codes.InvalidArgument, "port '%d' is already in use by service '%s' (%s) as a host-published port", pc.PublishedPort, service.Spec.Annotations.Name, service.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

as a host-published port

should be as an ingress port.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe it is correct as is. Since we are in the api.PublishModeHost case, this is a newly-added ingress port conflicting with an existing host-published port.

_, ingressConflict := ingressPorts[pcToStruct(pc)]
_, hostModeConflict := hostModePorts[pcToStruct(pc)]
if ingressConflict || hostModeConflict {
return grpc.Errorf(codes.InvalidArgument, "port '%d' is already in use by service '%s' (%s) as an ingress port", pc.PublishedPort, service.Spec.Annotations.Name, service.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

as an ingress port

Should remove this.

Copy link
Collaborator Author

@aaronlehmann aaronlehmann May 11, 2017

Choose a reason for hiding this comment

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

I think you are confusing the new service (which the maps reflect) with the existing services we iterate over.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right.

@aaronlehmann aaronlehmann merged commit 1ede4f8 into moby:master May 11, 2017
@aaronlehmann aaronlehmann deleted the duplicate-host-mode-ports branch May 11, 2017 20:35
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.

None yet

4 participants