Merge lp:~freyes/charms/trusty/nova-cloud-controller/single-nova-consoleauth into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next

Proposed by Felipe Reyes
Status: Superseded
Proposed branch: lp:~freyes/charms/trusty/nova-cloud-controller/single-nova-consoleauth
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 276 lines (+195/-28)
3 files modified
config.yaml (+11/-0)
hooks/nova_cc_hooks.py (+60/-2)
unit_tests/test_nova_cc_hooks.py (+124/-26)
To merge this branch: bzr merge lp:~freyes/charms/trusty/nova-cloud-controller/single-nova-consoleauth
Reviewer Review Type Date Requested Status
Edward Hope-Morley Needs Fixing
OpenStack Charmers Pending
Jorge Niedbalski Pending
Billy Olsen Pending
Review via email: mp+253309@code.launchpad.net

This proposal supersedes a proposal from 2015-03-06.

This proposal has been superseded by a proposal from 2015-03-25.

Description of the change

Dear OpenStack Charmers,

This patch configures a new pacemaker resource that will allow to run a single instance of nova-consoleauth service when console-access-protocol is defined.

Specifically, nova-consoleauth is configured to run where the vip is allocated, with this patch this will be default behaviour. This is needed for environments where the memcached cannot (or doesn't want to) be related to nova-cloud-controller to share the authorization tokens across all the running instances.

Example output of 'sudo crm_mon -1' with this patch applied:

Last updated: Mon Mar 2 14:46:43 2015
Last change: Mon Mar 2 14:44:53 2015 via crm_resource on juju-freyes-machine-18
Stack: corosync
Current DC: juju-freyes-machine-18 (168103083) - partition with quorum
Version: 1.1.10-42f2063
3 Nodes configured
5 Resources configured

Online: [ juju-freyes-machine-16 juju-freyes-machine-17 juju-freyes-machine-18 ]

 Resource Group: grp_nova_vips
     res_nova_eth0_vip (ocf::heartbeat:IPaddr2): Started juju-freyes-machine-16
 Clone Set: cl_nova_haproxy [res_nova_haproxy]
     Started: [ juju-freyes-machine-16 juju-freyes-machine-17 juju-freyes-machine-18 ]
 res_nova_consoleauth (upstart:nova-consoleauth): Started juju-freyes-machine-16

$ python juju_rrun.py --service nova-cloud-controller 'sudo ps aux|grep nova-consoleauth'
---------- 16 nova-cloud-controller/0
---------- stdout ----------
nova 20773 1.2 7.0 312604 71312 ? Ss 14:44 0:02 /usr/bin/python /usr/bin/nova-consoleauth --config-file=/etc/nova/nova.conf
ubuntu 21188 0.0 0.6 134316 6836 ? Sl 14:47 0:00 juju-run nova-cloud-controller/0 sudo ps aux|grep nova-consoleauth
root 21195 0.0 0.0 8860 648 ? S 14:47 0:00 grep nova-consoleauth

---------- 17 nova-cloud-controller/1
---------- stdout ----------
ubuntu 20997 0.0 0.6 134316 6840 ? Sl 14:47 0:00 juju-run nova-cloud-controller/1 sudo ps aux|grep nova-consoleauth
root 21004 0.0 0.0 8860 648 ? S 14:47 0:00 grep nova-consoleauth

---------- 18 nova-cloud-controller/2
---------- stdout ----------
ubuntu 21325 0.0 0.8 134316 8888 ? Sl 14:47 0:00 juju-run nova-cloud-controller/2 sudo ps aux|grep nova-consoleauth
root 21332 0.0 0.0 8860 644 ? S 14:47 0:00 grep nova-consoleauth

Thanks,

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

charm_lint_check #2119 nova-cloud-controller-next for freyes mp250339
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/2119/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #1909 nova-cloud-controller-next for freyes mp250339
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/1909/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #2028 nova-cloud-controller-next for freyes mp250339
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/2028/

Revision history for this message
Billy Olsen (billy-olsen) wrote : Posted in a previous version of this proposal

Felipe,

Thanks for the submission. I haven't deployed this yet to try it out, but my concerns are around the upstart resources. Since we'll have a difference between systemd and upstart between vivid and previous releases I think we should be using an ocf file instead. There's already one that exists in https://github.com/madkiss/openstack-resource-agents/tree/master/ocf. Looks like its been awhile since its been touched so its either stable or not supported anymore. I think the openstack-resource-agents package also includes this, but I'm not sure as to its status (I believe its in universe).

An amulet test is always nice :-) We don't have anything in the way of the hacluster relation in our amulet tests at this point so I don't think its strictly a requirement (e.g. I wouldn't hold up the mp for it), but improvements are always welcomed.

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #2392 nova-cloud-controller-next for freyes mp251456
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
  unit_tests/test_nova_cc_hooks.py:727:51: E502 the backslash is redundant between brackets
  make: *** [lint] Error 1

Full lint test output: http://paste.ubuntu.com/10520210/
Build: http://10.245.162.77:8080/job/charm_lint_check/2392/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #2182 nova-cloud-controller-next for freyes mp251456
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/2182/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #2312 nova-cloud-controller-next for freyes mp251456
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/2312/

Revision history for this message
Billy Olsen (billy-olsen) wrote : Posted in a previous version of this proposal

Felipe, thanks for the submission! Things look good. Approved.

review: Approve
Revision history for this message
Billy Olsen (billy-olsen) wrote : Posted in a previous version of this proposal

Okay I spoke too soon. Everything looks good for enabling the single-nova-consoleauth and it works as expected while its running. However, if a user wishes to change from single-nova-consoleauth back to multi consoleauth then this patch doesn't actually:

1. remove the res_nova_consoleauth from the corosync/pacemaker configuration.
2. restart the services on nodes which the service is not running restoring the multi-consoleauth scenario.

Apologies for not chasing this scenario down sooner.

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #2493 nova-cloud-controller-next for freyes mp252138
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/2493/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #2283 nova-cloud-controller-next for freyes mp252138
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/2283/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #2365 nova-cloud-controller-next for freyes mp252138
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
  ERROR subprocess encountered error code 1
  make: *** [test] Error 1

Full amulet test output: http://paste.ubuntu.com/10553839/
Build: http://10.245.162.77:8080/job/charm_amulet_test/2365/

Revision history for this message
Felipe Reyes (freyes) wrote : Posted in a previous version of this proposal

The amulet failure is:

  juju-test.conductor.14-basic-precise-icehouse DEBUG : Running 14-basic-precise-icehouse (tests/14-basic-precise-icehouse)
  2015-03-07 01:22:16 Starting deployment of osci-sv00
  2015-03-07 01:22:49 Deploying services...
[...]
  2015-03-07 01:23:13 Deploying service rabbitmq-server using local:precise/rabbitmq-server
  2015-03-07 01:34:08 The following units had errors:
  unit: rabbitmq-server/0: machine: 7 agent-state: error details: hook failed: "config-changed"

This isn't related to my change

Revision history for this message
Felipe Reyes (freyes) wrote : Posted in a previous version of this proposal

> 1. remove the res_nova_consoleauth from the corosync/pacemaker configuration.
> 2. restart the services on nodes which the service is not running restoring
> the multi-consoleauth scenario.

Makes sense, I'll update the patch.

Thanks,

Revision history for this message
Felipe Reyes (freyes) wrote :

@Billy, I pushed a new version of the patch to address your feedback, this can't be merged until bug 1433377 is fixed, but I'll appreciate if you could take a quick review to know if things look good.

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

charm_lint_check #2747 nova-cloud-controller-next for freyes mp253309
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/2747/

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

charm_unit_test #2538 nova-cloud-controller-next for freyes mp253309
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/2538/

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

charm_amulet_test #2586 nova-cloud-controller-next for freyes mp253309
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
  ERROR subprocess encountered error code 1
  make: *** [test] Error 1

Full amulet test output: http://paste.ubuntu.com/10630161/
Build: http://10.245.162.77:8080/job/charm_amulet_test/2586/

Revision history for this message
Felipe Reyes (freyes) wrote :

A couple of deployer configurations for testing this change were pushed to lp:~openstack-charm-testers/+junk/percona-mysql-agent

One of them is a complete openstack cloud (based in next.yaml from openstack-charm-testing repo) and the other one is a simple 3 node percona cluster + keystone.

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

Felipe, i'm deploying this as we speak. The code looks fine although I have a few comments about how it could be slightly neater, see inline. One approach might be so pull the relation_settings, travers the settings dict and apply any default/missing entries then process the results.

review: Needs Fixing
Revision history for this message
Felipe Reyes (freyes) wrote :

Ed, the bundle to test this MP is located at https://code.launchpad.net/~openstack-charm-testers/+junk/single-nova-consoleauth , sorry for the confusion.

Revision history for this message
Felipe Reyes (freyes) wrote :

Ed, I'll push another MP that addresses your feedback, except one of them, please see my reply.

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

So i should have noticed before but, your code is living in config_changed() but relies on the ha relation to exist so it will never get called unless the ha relation exists prior to config_changed() being run...which will not be the case unless you modify charm config after the hacluster has completed installation and relations have been added. So, i suggest you move that code into the ha_joined() or ha_changed() hooks and call it from config_changed() assuming that is safe to do.

review: Needs Fixing
154. By Felipe Reyes

Commit after merge

155. By Felipe Reyes

Move code into its own function and it's called from config-changed, ha-relation-changed and upgrade-charm

156. By Felipe Reyes

fix lint warning

157. By Felipe Reyes

Commit after merge

158. By Felipe Reyes

nova-consoleauth set to manual only if there is a ha relation

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2015-02-19 04:30:13 +0000
+++ config.yaml 2015-03-25 23:24:02 +0000
@@ -326,3 +326,14 @@
326 description: |326 description: |
327 A comma-separated list of nagios servicegroups.327 A comma-separated list of nagios servicegroups.
328 If left empty, the nagios_context will be used as the servicegroup328 If left empty, the nagios_context will be used as the servicegroup
329 single-nova-consoleauth:
330 type: boolean
331 default: true
332 description: |
333 When this configuration is set to True, a single instance of
334 nova-consoleauth service will be running, this allows users to always
335 authenticate against the same instance and avoid authentications issues
336 when the token used was stored in a different instance.
337
338 If memcached is being used to store the tokens, then it's recommended to
339 change this configuration to False.
329340
=== modified file 'hooks/nova_cc_hooks.py'
--- hooks/nova_cc_hooks.py 2015-02-19 04:29:22 +0000
+++ hooks/nova_cc_hooks.py 2015-03-25 23:24:02 +0000
@@ -120,6 +120,9 @@
120120
121hooks = Hooks()121hooks = Hooks()
122CONFIGS = register_configs()122CONFIGS = register_configs()
123COLO_CONSOLEAUTH = 'inf: res_nova_consoleauth grp_nova_vips'
124AGENT_CONSOLEAUTH = 'ocf:openstack:nova-consoleauth'
125AGENT_CA_PARAMS = 'op monitor interval="5s"'
123126
124127
125@hooks.hook()128@hooks.hook()
@@ -171,6 +174,52 @@
171 [cluster_joined(rid) for rid in relation_ids('cluster')]174 [cluster_joined(rid) for rid in relation_ids('cluster')]
172 update_nrpe_config()175 update_nrpe_config()
173176
177 relids = relation_ids('ha')
178 data = {}
179 if len(relids) != 1:
180 log('Related to {} ha services'.format(len(relids)), level='DEBUG')
181 ha_relid = None
182 else:
183 ha_relid = relids[0]
184 data = relation_get(rid=ha_relid) or {}
185
186 for key in ['delete_resources', 'colocations', 'init_services',
187 'resources', 'resource_params']:
188 if key not in data:
189 if key != 'delete_resources':
190 data[key] = {}
191 else:
192 data[key] = []
193
194 if config('single-nova-consoleauth') and console_attributes('protocol'):
195 for item in ['vip_consoleauth', 'res_nova_consoleauth']:
196 if item in data['delete_resources']:
197 data['delete_resources'].remove(item)
198
199 # the new pcmkr resources have to be added to the existing ones
200 data['colocations']['vip_consoleauth'] = COLO_CONSOLEAUTH
201 data['init_services']['res_nova_consoleauth'] = 'nova-consoleauth'
202 data['resources']['res_nova_consoleauth'] = AGENT_CONSOLEAUTH
203 data['resource_params']['res_nova_consoleauth'] = AGENT_CA_PARAMS
204
205 for rid in relation_ids('ha'):
206 relation_set(rid, **data)
207
208 elif (not config('single-nova-consoleauth')
209 and console_attributes('protocol')):
210 for item in ['vip_consoleauth', 'res_nova_consoleauth']:
211 if item not in data['delete_resources']:
212 data['delete_resources'].append(item)
213
214 # remove them from the rel, so they aren't recreated
215 data['colocations'].pop('vip_consoleauth', None)
216 data['init_services'].pop('res_nova_consoleauth', None)
217 data['resources'].pop('res_nova_consoleauth', None)
218 data['resource_params'].pop('res_nova_consoleauth', None)
219
220 for rid in relation_ids('ha'):
221 relation_set(rid, **data)
222
174223
175@hooks.hook('amqp-relation-joined')224@hooks.hook('amqp-relation-joined')
176def amqp_joined(relation_id=None):225def amqp_joined(relation_id=None):
@@ -636,7 +685,7 @@
636 'res_nova_haproxy': 'lsb:haproxy',685 'res_nova_haproxy': 'lsb:haproxy',
637 }686 }
638 resource_params = {687 resource_params = {
639 'res_nova_haproxy': 'op monitor interval="5s"'688 'res_nova_haproxy': 'op monitor interval="5s"',
640 }689 }
641690
642 vip_group = []691 vip_group = []
@@ -674,12 +723,21 @@
674 clones = {723 clones = {
675 'cl_nova_haproxy': 'res_nova_haproxy'724 'cl_nova_haproxy': 'res_nova_haproxy'
676 }725 }
726 colocations = {}
727
728 if config('single-nova-consoleauth') and console_attributes('protocol'):
729 colocations['vip_consoleauth'] = COLO_CONSOLEAUTH
730 init_services['res_nova_consoleauth'] = 'nova-consoleauth'
731 resources['res_nova_consoleauth'] = AGENT_CONSOLEAUTH
732 resource_params['res_nova_consoleauth'] = AGENT_CA_PARAMS
733
677 relation_set(init_services=init_services,734 relation_set(init_services=init_services,
678 corosync_bindiface=cluster_config['ha-bindiface'],735 corosync_bindiface=cluster_config['ha-bindiface'],
679 corosync_mcastport=cluster_config['ha-mcastport'],736 corosync_mcastport=cluster_config['ha-mcastport'],
680 resources=resources,737 resources=resources,
681 resource_params=resource_params,738 resource_params=resource_params,
682 clones=clones)739 clones=clones,
740 colocations=colocations)
683741
684742
685@hooks.hook('ha-relation-changed')743@hooks.hook('ha-relation-changed')
686744
=== modified file 'unit_tests/test_nova_cc_hooks.py'
--- unit_tests/test_nova_cc_hooks.py 2015-01-13 14:44:54 +0000
+++ unit_tests/test_nova_cc_hooks.py 2015-03-25 23:24:02 +0000
@@ -611,30 +611,128 @@
611 'by the neutron-server process.'611 'by the neutron-server process.'
612 )612 )
613613
614 def test_ha_relation_joined_no_bound_ip(self):614 @patch('nova_cc_utils.config')
615 self.get_hacluster_config.return_value = {615 def test_ha_relation_joined_no_bound_ip(self, config):
616 'ha-bindiface': 'em0',616 self.get_hacluster_config.return_value = {
617 'ha-mcastport': '8080',617 'ha-bindiface': 'em0',
618 'vip': '10.10.10.10',618 'ha-mcastport': '8080',
619 }619 'vip': '10.10.10.10',
620 self.test_config.set('vip_iface', 'eth120')620 }
621 self.test_config.set('vip_cidr', '21')621 self.test_config.set('vip_iface', 'eth120')
622 self.get_iface_for_address.return_value = None622 self.test_config.set('vip_cidr', '21')
623 self.get_netmask_for_address.return_value = None623 config.return_value = None
624 hooks.ha_joined()624 self.get_iface_for_address.return_value = None
625 args = {625 self.get_netmask_for_address.return_value = None
626 'corosync_bindiface': 'em0',626 hooks.ha_joined()
627 'corosync_mcastport': '8080',627 args = {
628 'init_services': {'res_nova_haproxy': 'haproxy'},628 'corosync_bindiface': 'em0',
629 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',629 'corosync_mcastport': '8080',
630 'res_nova_haproxy': 'lsb:haproxy'},630 'init_services': {'res_nova_haproxy': 'haproxy'},
631 'resource_params': {631 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',
632 'res_nova_eth120_vip': 'params ip="10.10.10.10"'632 'res_nova_haproxy': 'lsb:haproxy'},
633 ' cidr_netmask="21" nic="eth120"',633 'resource_params': {
634 'res_nova_haproxy': 'op monitor interval="5s"'},634 'res_nova_eth120_vip': 'params ip="10.10.10.10"'
635 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}635 ' cidr_netmask="21" nic="eth120"',
636 }636 'res_nova_haproxy': 'op monitor interval="5s"'},
637 self.relation_set.assert_has_calls([637 'colocations': {},
638 call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),638 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}
639 call(**args),639 }
640 self.relation_set.assert_has_calls([
641 call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),
642 call(**args),
643 ])
644
645 @patch('nova_cc_utils.config')
646 def test_ha_relation_multi_consoleauth(self, config):
647 self.get_hacluster_config.return_value = {
648 'ha-bindiface': 'em0',
649 'ha-mcastport': '8080',
650 'vip': '10.10.10.10',
651 }
652 self.test_config.set('vip_iface', 'eth120')
653 self.test_config.set('vip_cidr', '21')
654 self.test_config.set('single-nova-consoleauth', False)
655 config.return_value = 'novnc'
656 self.get_iface_for_address.return_value = None
657 self.get_netmask_for_address.return_value = None
658 hooks.ha_joined()
659 args = {
660 'corosync_bindiface': 'em0',
661 'corosync_mcastport': '8080',
662 'init_services': {'res_nova_haproxy': 'haproxy'},
663 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',
664 'res_nova_haproxy': 'lsb:haproxy'},
665 'resource_params': {
666 'res_nova_eth120_vip': 'params ip="10.10.10.10"'
667 ' cidr_netmask="21" nic="eth120"',
668 'res_nova_haproxy': 'op monitor interval="5s"'},
669 'colocations': {},
670 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}
671 }
672 self.relation_set.assert_has_calls([
673 call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),
674 call(**args),
675 ])
676
677 @patch('nova_cc_utils.config')
678 def test_ha_relation_single_consoleauth(self, config):
679 self.get_hacluster_config.return_value = {
680 'ha-bindiface': 'em0',
681 'ha-mcastport': '8080',
682 'vip': '10.10.10.10',
683 }
684 self.test_config.set('vip_iface', 'eth120')
685 self.test_config.set('vip_cidr', '21')
686 config.return_value = 'novnc'
687 self.get_iface_for_address.return_value = None
688 self.get_netmask_for_address.return_value = None
689 hooks.ha_joined()
690 args = {
691 'corosync_bindiface': 'em0',
692 'corosync_mcastport': '8080',
693 'init_services': {'res_nova_haproxy': 'haproxy',
694 'res_nova_consoleauth': 'nova-consoleauth'},
695 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',
696 'res_nova_haproxy': 'lsb:haproxy',
697 'res_nova_consoleauth':
698 'ocf:openstack:nova-consoleauth'},
699 'resource_params': {
700 'res_nova_eth120_vip': 'params ip="10.10.10.10"'
701 ' cidr_netmask="21" nic="eth120"',
702 'res_nova_haproxy': 'op monitor interval="5s"',
703 'res_nova_consoleauth': 'op monitor interval="5s"'},
704 'colocations': {
705 'vip_consoleauth': 'inf: res_nova_consoleauth grp_nova_vips'
706 },
707 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}
708 }
709 self.relation_set.assert_has_calls([
710 call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),
711 call(**args),
712 ])
713
714 @patch('nova_cc_hooks.configure_https')
715 @patch('nova_cc_utils.config')
716 def test_config_changed_single_consoleauth(self, config, *args):
717 config.return_value = 'novnc'
718 rids = {'ha': ['ha:1']}
719
720 def f(r):
721 return rids.get(r, [])
722
723 self.relation_ids.side_effect = f
724 hooks.config_changed()
725 args = {
726 'delete_resources': [],
727 'init_services': {'res_nova_consoleauth': 'nova-consoleauth'},
728 'resources': {'res_nova_consoleauth':
729 'ocf:openstack:nova-consoleauth'},
730 'resource_params': {
731 'res_nova_consoleauth': 'op monitor interval="5s"'},
732 'colocations': {
733 'vip_consoleauth': 'inf: res_nova_consoleauth grp_nova_vips'
734 }
735 }
736 self.relation_set.assert_has_calls([
737 call(v, **args) for v in rids['ha']
640 ])738 ])

Subscribers

People subscribed via source and target branches