Merge lp:~cbjchen/charms/trusty/nova-compute/my_ip_setting into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next

Proposed by Liang Chen
Status: Merged
Approved by: Edward Hope-Morley
Approved revision: 88
Merged at revision: 91
Proposed branch: lp:~cbjchen/charms/trusty/nova-compute/my_ip_setting
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
Diff against target: 104 lines (+33/-2)
5 files modified
hooks/nova_compute_context.py (+18/-1)
hooks/nova_compute_utils.py (+3/-1)
templates/havana/nova.conf (+1/-0)
templates/juno/nova.conf (+1/-0)
unit_tests/test_nova_compute_contexts.py (+10/-0)
To merge this branch: bzr merge lp:~cbjchen/charms/trusty/nova-compute/my_ip_setting
Reviewer Review Type Date Requested Status
Edward Hope-Morley Approve
Review via email: mp+241975@code.launchpad.net

Description of the change

The default value for my_ip can be problematic. The ip address assocated with the NIC leading to the default gateway may not be the desired one for openstack service communication. Setting it to the unit private-address, so that all the inter service communications use the same network - we alreay use the unit private-address as service endpoint IPs. This patch creates a dedicate context for the host_ip, because it doesn't seem to naturally fit into any existing ones.

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

UOSCI bot says:
charm_lint_check #1108 nova-compute-next for cbjchen mp241975
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option os-data-network has no default value
  I: config.yaml: option config-flags has no default value
  I: config.yaml: option instances-path has no default value
  W: config.yaml: option disable-neutron-security-groups has no default value
  I: config.yaml: option migration-auth-type has no default value

Full lint test output: http://paste.ubuntu.com/9057630/
Build: http://10.98.191.181:8080/job/charm_lint_check/1108/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

UOSCI bot says:
charm_unit_test #942 nova-compute-next for cbjchen mp241975
    UNIT OK: passed

UNIT Results (max last 5 lines):
  nova_compute_hooks 132 13 90% 79, 97-98, 125, 191, 249, 254-255, 261, 265-268
  nova_compute_utils 228 110 52% 163-219, 227, 232-235, 270-272, 279, 283-286, 294-302, 306, 315-324, 337-356, 382-383, 387-388, 407-428, 445-455, 469-470, 475-476
  TOTAL 571 193 66%
  Ran 57 tests in 3.409s
  OK (SKIP=5)

Full unit test output: http://paste.ubuntu.com/9057632/
Build: http://10.98.191.181:8080/job/charm_unit_test/942/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

UOSCI bot says:
charm_amulet_test #450 nova-compute-next for cbjchen mp241975
    AMULET OK: passed

AMULET Results (max last 5 lines):
  juju-test.conductor.15-basic-trusty-icehouse RESULT :
  juju-test.conductor DEBUG : Tearing down osci-sv07 juju environment
  juju-test.conductor DEBUG : Calling "juju destroy-environment -y osci-sv07"
  WARNING cannot delete security group "juju-osci-sv07-0". Used by another environment?
  juju-test INFO : Results: 3 passed, 0 failed, 0 errored

Full amulet test output: http://paste.ubuntu.com/9057805/
Build: http://10.98.191.181:8080/job/charm_amulet_test/450/

87. By Liam Young

[mthaddon,r=gnuoy] Allow for disk_cachemodes to be set via a config option

Revision history for this message
Edward Hope-Morley (hopem) wrote :

Liang, as discussed earlier can you conform whether or not this is supposed to be used in the same way as in nova-cloud-controller (to which my_ip support was added a few commits back) which uses bing_host for my_ip.

Revision history for this message
Liang Chen (cbjchen) wrote :
Download full text (3.5 KiB)

Hi Edward,

Here is the official definition of this config option.
# IP address of this host (string value)
#my_ip=10.0.0.1

I think they are used in the same way - as the IP address of the host. It's used in several different places. Below is a rough summary of its usage on both compute and controller nodes.

========================= compute usage =========================
./nova/compute/resource_tracker.py:60:CONF.import_opt('my_ip', 'nova.netconf')
./nova/compute/resource_tracker.py:278: metrics_info['host_ip'] = CONF.my_ip
./nova/compute/resource_tracker.py:301: resources['host_ip'] = CONF.my_ip

update resource info in the database - compute_nodes.host_ip

./nova/virt/libvirt/driver.py:266:CONF.import_opt('my_ip', 'nova.netconf')
./nova/virt/libvirt/driver.py:1160: connector = {'ip': CONF.my_ip,
./nova/virt/libvirt/driver.py:2389: return CONF.my_ip

used as an argument when terminating a volume connection - volume drivers may or may not use it,
and also used to compare with migration destination host to see if a storage is shared with the destination while migrating disk

./nova/virt/hyperv/hostops.py:32:CONF.import_opt('my_ip', 'nova.netconf')
./nova/virt/hyperv/hostops.py:175: host_ip = CONF.my_ip

has reference to it, but doesn't seem to use it anymore

./nova/virt/hyperv/volumeops.py:55:CONF.import_opt('my_ip', 'nova.netconf')
./nova/virt/hyperv/volumeops.py:203: 'ip': CONF.my_ip,

used while composing volume connection param dictionary

./nova/virt/baremetal/driver.py:76:CONF.import_opt('my_ip', 'nova.netconf')

has reference to it, but doesn't seem to use it anymore

./nova/virt/baremetal/volume_driver.py:198: 'ip': CONF.my_ip,

used while composing volume connection param dictionary

./nova/virt/baremetal/pxe.py:356: 'opt_value': CONF.my_ip},
./nova/virt/baremetal/pxe.py:358: 'opt_value': CONF.my_ip}

used as a option for dhcp while creating an instance

./nova/virt/vmwareapi/vmops.py:70:CONF.import_opt('my_ip', 'nova.netconf')
./nova/virt/vmwareapi/vmops.py:101: self._base_folder = '%s%s' % (CONF.my_ip,

========================= controller usage =========================

used as part of the base folder name for image cache

./nova/network/linux_net.py:62: default='$my_ip',
./nova/network/linux_net.py:108: default='$my_ip',
./nova/network/linux_net.py:138:CONF.import_opt('my_ip', 'nova.netconf')

used as default values for routing_source_ip(Public IP of network host) and metadata_host(The IP address for the metadata API server)

./nova/network/manager.py:108: default='$my_ip',
./nova/network/manager.py:169:CONF.import_opt('my_ip', 'nova.netconf')

used as default values for vpn_ip(Public IP for the cloudpipe VPN servers)

./nova/image/s3.py:48: default='$my_ip',
./nova/image/s3.py:71:CONF.import_opt('my_ip', 'nova.netconf')

used as a parameter while creating connection with s3 compatible service - swfit

./nova/image/glance.py:44: default='$my_ip',
./nova/image/glance.py:76:CONF.import_opt('my_ip', 'nova.netconf')

used as default value of glance_ho...

Read more...

Revision history for this message
Edward Hope-Morley (hopem) wrote :

Thanks Liang, this makes sense. I think we will need to fix this as well:

http://bazaar.launchpad.net/~openstack-charmers/charms/trusty/nova-cloud-controller/trunk/view/head:/templates/icehouse/nova.conf#L27

Also, we will need to make sure this plays well with network splits.

Revision history for this message
Liang Chen (cbjchen) wrote :

Hi Edward,
As we discussed, I will make the patch for nova-cc as well after making sure the nova-compute patch works. Thanks.

Revision history for this message
Liang Chen (cbjchen) wrote :

Needs to take config('prefer-ipv6') into consideration. will update

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

UOSCI bot says:
charm_lint_check #1235 nova-compute-next for cbjchen mp241975
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option config-flags has no default value
  I: config.yaml: option instances-path has no default value
  W: config.yaml: option disable-neutron-security-groups has no default value
  I: config.yaml: option migration-auth-type has no default value
  I: config.yaml: option disk-cachemodes has no default value

Full lint test output: http://paste.ubuntu.com/9253227/
Build: http://10.98.191.181:8080/job/charm_lint_check/1235/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

UOSCI bot says:
charm_unit_test #1069 nova-compute-next for cbjchen mp241975
    UNIT OK: passed

UNIT Results (max last 5 lines):
  nova_compute_hooks 132 13 90% 79, 97-98, 125, 191, 249, 254-255, 261, 265-268
  nova_compute_utils 228 110 52% 163-219, 227, 232-235, 270-272, 279, 283-286, 294-302, 306, 315-324, 337-356, 382-383, 387-388, 407-428, 445-455, 469-470, 475-476
  TOTAL 575 194 66%
  Ran 58 tests in 3.325s
  OK (SKIP=5)

Full unit test output: http://paste.ubuntu.com/9253228/
Build: http://10.98.191.181:8080/job/charm_unit_test/1069/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

UOSCI bot says:
charm_amulet_test #538 nova-compute-next for cbjchen mp241975
    AMULET OK: passed

AMULET Results (max last 5 lines):
  juju-test.conductor DEBUG : Tearing down osci-sv05 juju environment
  juju-test.conductor DEBUG : Calling "juju destroy-environment -y osci-sv05"
  WARNING cannot delete security group "juju-osci-sv05-0". Used by another environment?
  WARNING cannot delete security group "juju-osci-sv05". Used by another environment?
  juju-test INFO : Results: 3 passed, 0 failed, 0 errored

Full amulet test output: http://paste.ubuntu.com/9253500/
Build: http://10.98.191.181:8080/job/charm_amulet_test/538/

Revision history for this message
Edward Hope-Morley (hopem) wrote :

I've tested this works fine for ipv4 but needs fixing for ipv6 case. See inline comment.

review: Needs Fixing
88. By Liang Chen <email address hidden>

set my_ip to unit private-address

[cbjchen,r=]
The default value for my_ip can be problematic.
The ip assocated with the NIC leading to the
default gateway may not be the desired one for
openstack service communication. Setting it to
the unit private-address, so that all the inter
service communications use the same network -
we alreay use the unit private-address as
service endpoint IPs.

Revision history for this message
Liang Chen (cbjchen) wrote :

Hi Edward,
Thanks for the comment. Patch updated accordingly.

Revision history for this message
Edward Hope-Morley (hopem) wrote :

Thanks liang. lgtm, approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/nova_compute_context.py'
2--- hooks/nova_compute_context.py 2014-11-25 15:10:52 +0000
3+++ hooks/nova_compute_context.py 2014-12-03 23:25:03 +0000
4@@ -17,7 +17,12 @@
5
6 from charmhelpers.contrib.openstack.utils import get_host_ip, os_release
7 from charmhelpers.contrib.network.ovs import add_bridge
8-from charmhelpers.contrib.network.ip import get_address_in_network
9+
10+from charmhelpers.contrib.network.ip import (
11+ get_address_in_network,
12+ get_ipv6_addr,
13+ format_ipv6_addr,
14+)
15
16 # This is just a label and it must be consistent across
17 # nova-compute nodes to support live migration.
18@@ -394,3 +399,15 @@
19 ctxt['disable_neutron_security_groups'] = \
20 config('disable-neutron-security-groups')
21 return ctxt
22+
23+
24+class HostIPContext(context.OSContextGenerator):
25+ def __call__(self):
26+ ctxt = {}
27+ if config('prefer-ipv6'):
28+ host_ip = get_ipv6_addr()[0]
29+ else:
30+ host_ip = get_host_ip(unit_get('private-address'))
31+ if host_ip:
32+ ctxt['host_ip'] = format_ipv6_addr(host_ip) or host_ip
33+ return ctxt
34
35=== modified file 'hooks/nova_compute_utils.py'
36--- hooks/nova_compute_utils.py 2014-11-28 14:31:49 +0000
37+++ hooks/nova_compute_utils.py 2014-12-03 23:25:03 +0000
38@@ -43,6 +43,7 @@
39 NovaComputeCephContext,
40 NeutronComputeContext,
41 InstanceConsoleContext,
42+ HostIPContext,
43 )
44
45 CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
46@@ -89,7 +90,8 @@
47 interface='nova-ceilometer',
48 service='nova',
49 config_file=NOVA_CONF),
50- InstanceConsoleContext(), ],
51+ InstanceConsoleContext(),
52+ HostIPContext(), ],
53 },
54 }
55
56
57=== modified file 'templates/havana/nova.conf'
58--- templates/havana/nova.conf 2014-11-12 14:47:04 +0000
59+++ templates/havana/nova.conf 2014-12-03 23:25:03 +0000
60@@ -21,6 +21,7 @@
61 enabled_apis=ec2,osapi_compute,metadata
62 auth_strategy=keystone
63 compute_driver=libvirt.LibvirtDriver
64+my_ip = {{ host_ip }}
65
66 {% include "parts/database" %}
67
68
69=== modified file 'templates/juno/nova.conf'
70--- templates/juno/nova.conf 2014-11-25 15:10:52 +0000
71+++ templates/juno/nova.conf 2014-12-03 23:25:03 +0000
72@@ -21,6 +21,7 @@
73 enabled_apis=ec2,osapi_compute,metadata
74 auth_strategy=keystone
75 compute_driver=libvirt.LibvirtDriver
76+my_ip = {{ host_ip }}
77
78 {% include "parts/database" %}
79
80
81=== modified file 'unit_tests/test_nova_compute_contexts.py'
82--- unit_tests/test_nova_compute_contexts.py 2014-11-25 14:44:46 +0000
83+++ unit_tests/test_nova_compute_contexts.py 2014-12-03 23:25:03 +0000
84@@ -15,6 +15,7 @@
85 'log',
86 'os_release',
87 '_save_flag_file',
88+ 'unit_get',
89 ]
90
91 QUANTUM_CONTEXT = {
92@@ -203,3 +204,12 @@
93 with patch.object(qplugin, '_ensure_packages'):
94 self.assertEquals({'disable_neutron_security_groups': False},
95 qplugin())
96+
97+ @patch('subprocess.call')
98+ def test_host_IP_context(self, _call):
99+ self.log = fake_log
100+ self.unit_get.return_value = '172.24.0.79'
101+ host_ip = context.HostIPContext()
102+ self.assertEquals(
103+ {'host_ip': '172.24.0.79'}, host_ip())
104+ self.unit_get.assert_called_with('private-address')

Subscribers

People subscribed via source and target branches