Zun

zun is not responsible for port clean, kuryr will do it.

Registered by Wang Changyu

the following explain the bug: https://bugs.launchpad.net/zun/+bug/1751933

when stop a container, network would unsetup first.
the following steps would be taken, when container disconnect from network
1. POST /NetworkDriver.RevokeExternalConnectivity
2. POST /NetworkDriver.Leave
3. POST /NetworkDriver.DeleteEndpoint
4. POST /IpamDriver.ReleaseAddress

on master branch of kuryr, let's check kuryr code on 4th step

@app.route('/IpamDriver.ReleaseAddress', methods=['POST'])
def ipam_release_address():
......
    try:
        fixed_ip = 'ip_address=' + str(rel_ip_address)
        all_ports = app.neutron.list_ports(fixed_ips=fixed_ip)
        for port in all_ports['ports']:
            tags = port.get('tags', [])
            if ((tags and lib_const.DEVICE_OWNER in tags) or
                    (not tags and port['name'] ==
                        utils.get_neutron_port_name(port['device_id']))):
                for tmp_subnet in subnets:
                    if (port['fixed_ips'][0]['subnet_id'] == tmp_subnet['id']):
                        app.neutron.delete_port(port['id'])
            elif tags and const.KURYR_EXISTING_NEUTRON_PORT in tags:
                updated_port = {'name': '', 'device_owner': '',
                                'device_id': '', 'binding:host_id': ''}
                app.neutron.update_port(port['id'], {'port': updated_port})
                _neutron_port_remove_tag(port['id'],
                                         const.KURYR_EXISTING_NEUTRON_PORT)
    except n_exceptions.NeutronClientException as ex:
        LOG.error("Error happened while fetching "
                  "and deleting port, %s", ex)
        raise

    return flask.jsonify(const.SCHEMA['SUCCESS'])

since the port was created in zun, port's tag would be marked as const.KURYR_EXISTING_NEUTRON_PORT, then the port would be cleanup.

when start a container, network would be setup first.
the flowing steps would be taken, when container connect to network
1. POST /IpamDriver.RequestAddress
2. POST /NetworkDriver.CreateEndpoint
3. POST /NetworkDriver.Join
4. POST /NetworkDriver.EndpointOperInfo
5. POST /NetworkDriver.EndpointOperInfo

on master branch of kuryr, let's check kuryr code on 2th step
there is a function invoked stack: _create_or_update_port ==> update_port
    def update_port(self, port, endpoint_id, interface_mac):
        """Updates port information and performs extra driver-specific actions.

        It returns the updated port dictionary after the required actions
        performed depending on the binding driver.

        :param port: a neutron port dictionary returned from
                             python-neutronclient
        :param endpoint_id: the ID of the endpoint as string
        :param interface_mac: the MAC address of the endpoint
        :returns: the updated Neutron port id dictionary as returned by
                  python-neutronclient
        """
        port['name'] = libnet_utils.get_neutron_port_name(endpoint_id)
        try:
            updated_port = {
                'name': port['name'],
                'device_owner': lib_const.DEVICE_OWNER,
                'binding:host_id': lib_utils.get_hostname(),
            }
            if not port.get('device_id'):
                updated_port['device_id'] = endpoint_id
            if interface_mac:
                updated_port['mac_address'] = interface_mac
            response_port = app.neutron.update_port(port['id'],
                                                    {'port': updated_port})

so, for the bug: https://bugs.launchpad.net/zun/+bug/1751933
when stop a container, the device_id(value: container_uuid) is wiped, then start the container, the endpoint of the docker as device_id will be written in port .

therefor, zun don't need to cleanup port.

Blueprint information

Status:
Complete
Approver:
Hongbin Lu
Priority:
Undefined
Drafter:
Wang Changyu
Direction:
Needs approval
Assignee:
Wang Changyu
Definition:
Superseded
Series goal:
None
Implementation:
Unknown
Milestone target:
None
Completed by
Wang Changyu

Related branches

Sprints

Whiteboard

Gerrit topic: https://review.openstack.org/#q,topic:bp/zun-do-not-need-to-cleanup-port,n,z

Addressed by: https://review.openstack.org/547941
    kuryr will cleanup port device_id when docker disconnect

(hongbin 2018-03-04): Hi Wang Changyu, I agree what you said until "so, for the bug: https://bugs.launchpad.net/zun/+bug/1751933 when stop a container, the device_id(value: container_uuid) is wiped, then start the container, the endpoint of the docker as device_id will be written in port ." Could you elaborate how "the endpoint of the docker as device_id will be written"? I have tested it and it looks the device_id won't be re-written after a stop and start.

(changyu 2018-03-05):yes, u r right. I will fix the bug in kuryr-libnetwork. thanks
https://bugs.launchpad.net/kuryr/+bug/1753357

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.