Skip to content

Fixing error with host network mode on upgrade from pre 17.06 versions#2244

Merged
aaronlehmann merged 1 commit into
moby:masterfrom
abhi:net_host
Jun 13, 2017
Merged

Fixing error with host network mode on upgrade from pre 17.06 versions#2244
aaronlehmann merged 1 commit into
moby:masterfrom
abhi:net_host

Conversation

@abhi
Copy link
Copy Markdown
Contributor

@abhi abhi commented Jun 12, 2017

This commit contains the following fixes:

  1. On upgrade from pre 17.06 version services created with net=host
    were failing because the swarm was not aware of host network being
    created. The fix added takes care of this by creating network if
    the store does not contain predefined networks

  2. On a cluster with upgraded 17.06 version of docker swarm manager
    the daemon panics while trying to access IPAM driver in the createNetworkRequest on
    the nodes with pre 17.06 versions. In order to avoid panics empty struct is passed
    with network attachment. This does not have any function impact.

Signed-off-by: Abhinandan Prativadi abhi@docker.com

@mavenugo
Copy link
Copy Markdown
Contributor

Thanks @abhinandanpb .

LGTM

This PR prevents worker panic running older versions (17.05 and lower) when the user executes docker service create --network=host xxxxxx.

@abhi abhi force-pushed the net_host branch 2 times, most recently from deae917 to 49819a2 Compare June 12, 2017 23:51
Comment thread manager/manager.go Outdated
log.G(ctx).WithError(err).Error("failed to create predefined network " + p.Name)
}
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rather than duplicate this code, let's move the creation of predefined networks outside the if/else.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 13, 2017

Codecov Report

Merging #2244 into master will decrease coverage by 0.11%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master    #2244      +/-   ##
==========================================
- Coverage   60.41%   60.29%   -0.12%     
==========================================
  Files         124      124              
  Lines       20248    20221      -27     
==========================================
- Hits        12233    12193      -40     
- Misses       6642     6657      +15     
+ Partials     1373     1371       -2

n.DriverState = &api.Driver{
Name: d.name,
}
n.IPAM = &api.IPAMOptions{Driver: &api.Driver{}}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment about why this is necessary?

Also, I'm not sure this should be done at allocation time. That leaves a window where it could crash an earlier version. Shouldn't it be done at the time the network is created?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Actually, maybe it's okay if n.IPAM is nil before allocation. I guess previous versions would not attempt to use it on an unallocated network. Can you confirm?

@abhi abhi force-pushed the net_host branch 2 times, most recently from 0863ead to 0066e4f Compare June 13, 2017 00:36
@abhi abhi force-pushed the net_host branch 4 times, most recently from 31ed250 to 59624ab Compare June 13, 2017 15:42
This commit contains the following fixes:
1) On upgrade from pre 17.06 version services created with net=host
were failing because the swarm was not aware of host network being
created. The fix added takes care of this by creating network if
the store does not contain predefined networks

2) On a cluster with upgraded 17.06 version of docker swarm manager
the daemon panics while trying to access IPAM driver in the createNetworkRequest on
the nodes with pre 17.06 versions. In order to avoid panics empty struct is passed
with network attachment. This does not have any function impact.

Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
@aaronlehmann
Copy link
Copy Markdown
Collaborator

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants