unable to unset gateway_ip on existing subnet

Bug #1178273 reported by Anthony Woods
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
Armando Migliaccio
Grizzly
Fix Released
Low
Gary Kotton
python-neutronclient
Fix Released
Low
Armando Migliaccio

Bug Description

A subnet can be configured without a gateway_ip if the gateway_ip is set to null when the subnet is initially created. However it is not possible to change the gateway_ip to null for an existing subnet.

Trying to unset a subnet's gateway_ip/set it to null, results in a 'failed to detect a valid IP address from None' QuantumError.

This can be easily corrected with the attached diff

Tags: l3-ipam-dhcp
Revision history for this message
Anthony Woods (awoods-0) wrote :
Changed in quantum:
assignee: nobody → Armando Migliaccio (armando-migliaccio)
tags: added: grizzly-backport-potential l3-ipam-dhcp
Changed in quantum:
status: New → Confirmed
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

Anthony,

I can confirm the issue, however I am not sure that your fix does the trick.

Can you give more details on your environment (e.g. version of quantum, plugin backend, steps to repro)?

Thanks,
Armando

Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

Actually, I'd be more interested in the debug output of your python-quantumclient command. If you used curl is fine too, then I would be interested in the request body :)

Revision history for this message
Anthony Woods (awoods-0) wrote :

I am using grizzly packages from ubuntu-cloud.archive.canonical.com

192.168.1.0/24 subnet with gateway currently set to 192.168.1.1

failure response:

~# curl -i http://localhost:9696/v2.0/subnets/6ac6f745-a926-4333-b1db-a0c601cd47a8.json -X PUT -H "User-Agent: python-quantumclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: b7d237fbff4e4bf2bf549e6123b7264a" -d '{"subnet": {"gateway_ip": null}}'
HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=UTF-8
Content-Length: 65
Date: Mon, 13 May 2013 22:51:06 GMT

{"QuantumError": "failed to detect a valid IP address from None"}

After patch

~# curl -i http://localhost:9696/v2.0/subnets/6ac6f745-a926-4333-b1db-a0c601cd47a8.json -X PUT -H "User-Agent: python-quantumclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: b7d237fbff4e4bf2bf549e6123b7264a" -d '{"subnet": {"gateway_ip": null}}'
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 371
Date: Mon, 13 May 2013 22:55:35 GMT

{"subnet": {"name": "", "enable_dhcp": true, "network_id": "be3aa212-ada4-48d4-b800-994c8fe559c6", "tenant_id": "d4c63419b4754f3eaeaa039c048a19fc", "dns_nameservers": [], "allocation_pools": [{"start": "192.168.1.2", "end": "192.168.1.254"}], "host_routes": [], "ip_version": 4, "gateway_ip": null, "cidr": "192.168.1.0/24", "id": "6ac6f745-a926-4333-b1db-a0c601cd47a8"}}

Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

Cool, thanks for your response.

I think that the required change will probably need to be more sophisticated than the one you showed (and I advised against hot-fixing your quantum server this way); reason being, the dhcp agent's behavior might be unexpected, especially if there was a port already associated with the gateway ip.

I also noticed that by using the quantum client, I am unable to reset the gateway-ip, as None or null do not parse correctly (they end up being marshalled into a string). I will follow that up with the client-side of the project, but for now, I think it would be sensible to gather more input/opinion from whom is more experienced with dhcp than I am, as I suspect that _removing_ a gateway from an existing subnet is not something that was initially planned.

Changed in quantum:
status: Confirmed → Opinion
Revision history for this message
Anthony Woods (awoods-0) wrote :

In my tests the DHCP agent correctly handles the Subnet change and calls the reload_allocations method of the DHCP driver. In the default linux.dhcp driver, reload_allocations results in the dnsmasq config being completey regenerated, and the DNSMASQ process being sent a HUP signal.

Though the quantum python client does not support setting the gateway_ip to null, Horizon does and actually has a checkbox for unsetting the gateway_ip. Horizon returning the quantumError is how i discovered this bug in the first place.

The patch was based on the logic from the subnet_create() method, which only calls the _validate_gw_out_of_pools() method if gateway_ip is not None.

With all this said, I am of course more then happy for others with greater experience with Quantum and its components to make suggestions.

Revision history for this message
Anthony Woods (awoods-0) wrote :

Though the DHCP agent should work as expected, the L3_Agent may be were problems could arise.

We do not currently use the L3_agent in our environment, so i cant comment on what problems my patch may introduce.

Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

Anthony,

Thanks for following up. There's definitely scope for doing something :)

As you said, if Horizon allows to clear the gateway on a subnet and that's not being honored by Quantum, something need to be straighten up. It's just a matter of determining the best course of action.

Cheers,
Armando

Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

If we call quantum subnet-update with --gateway-ip=None (the command does not support the --no-gateway option), the value is marshaled and sent as a string. I haven't seen what a request would look like when sent with Horizon, but I think that something can be improved with arguments parsing.

Changed in python-quantumclient:
status: New → Confirmed
Changed in quantum:
status: Opinion → Confirmed
Changed in python-quantumclient:
assignee: nobody → Armando Migliaccio (armando-migliaccio)
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :
Changed in neutron:
status: Confirmed → Fix Committed
Changed in python-neutronclient:
status: Confirmed → Fix Committed
status: Fix Committed → Invalid
status: Invalid → Fix Committed
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/grizzly)

Fix proposed to branch: stable/grizzly
Review: https://review.openstack.org/39266

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/grizzly)

Reviewed: https://review.openstack.org/39266
Committed: http://github.com/openstack/neutron/commit/e4f150d2a2f95db797f6540e5676d477f2d4e780
Submitter: Jenkins
Branch: stable/grizzly

commit e4f150d2a2f95db797f6540e5676d477f2d4e780
Author: armando-migliaccio <email address hidden>
Date: Tue Jul 9 19:08:49 2013 -0700

    Allow gateway address to be unset for an existing subnet

    Validation of the gateway IP address was taken place even
    if the gateway IP was set to None; this was causing an
    AddrFormatError exception to be raised by method
    '_validate_gw_out_of_pools'. With this change we skip
    the validation in case the gateway is set to None.

    Fixes bug #1178273

    Change-Id: Ib84378a4fd2cefdbbcacce695abbfaf82c647dd3
    (cherry picked from commit 40a5853970cdd1555dfb5ebce81c6babf2e445da)

tags: added: in-stable-grizzly
Changed in neutron:
milestone: none → havana-3
Changed in python-neutronclient:
milestone: none → 3.0.0
Changed in neutron:
importance: Undecided → Low
Changed in python-neutronclient:
importance: Undecided → Low
Alan Pevec (apevec)
tags: removed: grizzly-backport-potential in-stable-grizzly
Thierry Carrez (ttx)
Changed in neutron:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: havana-3 → 2013.2
Akihiro Motoki (amotoki)
Changed in python-neutronclient:
milestone: 3.0.0 → none
Akihiro Motoki (amotoki)
Changed in python-neutronclient:
milestone: none → 2.2.1-2.2.6
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.