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: 284 lines (+203/-28)
3 files modified
config.yaml (+11/-0)
hooks/nova_cc_hooks.py (+68/-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
Billy Olsen Needs Fixing
Edward Hope-Morley Pending
Jorge Niedbalski Pending
Review via email: mp+252138@code.launchpad.net

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

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

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 :

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

review: Approve
Revision history for this message
Billy Olsen (billy-olsen) wrote :

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 :

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 :

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 :

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 :

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

152. By Felipe Reyes

pcmkr: Delete resources when single-nova-consoleauth turned off

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

> 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,

153. By Felipe Reyes

Remove pcmkr rules when single-nova-consoleauth is set to True

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-18 03:44:48 +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-18 03:44:48 +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,60 @@
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 if len(relids) != 1:
179 log('Related to {} ha services'.format(len(relids)), level='DEBUG')
180 ha_relid = None
181 data = {}
182 else:
183 ha_relid = relids[0]
184 data = relation_get(rid=ha_relid) or {}
185
186 if config('single-nova-consoleauth') and console_attributes('protocol'):
187 data.setdefault('delete_resources', [])
188 for item in ['vip_consoleauth', 'res_nova_consoleauth']:
189 if item in data['delete_resources']:
190 data['delete_resources'].remove(item)
191
192 # the new pcmkr resources have to be added to the existing ones
193 data.setdefault('colocations', {})
194 data['colocations']['vip_consoleauth'] = COLO_CONSOLEAUTH
195
196 data.setdefault('init_services', {})
197 data['init_services']['res_nova_consoleauth'] = 'nova-consoleauth'
198
199 data.setdefault('resources', {})
200 data['resources']['res_nova_consoleauth'] = AGENT_CONSOLEAUTH
201
202 data.setdefault('resource_params', {})
203 data['resource_params']['res_nova_consoleauth'] = AGENT_CA_PARAMS
204
205 for rid in relation_ids('ha'):
206 relation_set(rid,
207 **data)
208 elif (not config('single-nova-consoleauth')
209 and console_attributes('protocol')):
210 data.setdefault('delete_resources', [])
211 for item in ['vip_consoleauth', 'res_nova_consoleauth']:
212 if item not in data['delete_resources']:
213 data['delete_resources'].append(item)
214
215 # remove them from the rel, so they aren't recreated
216 data.setdefault('colocations', {})
217 data['colocations'].pop('vip_consoleauth', None)
218
219 data.setdefault('init_services', {})
220 data['init_services'].pop('res_nova_consoleauth', None)
221
222 data.setdefault('resources', {})
223 data['resources'].pop('res_nova_consoleauth', None)
224
225 data.setdefault('resource_params', {})
226 data['resource_params'].pop('res_nova_consoleauth', None)
227
228 for rid in relation_ids('ha'):
229 relation_set(rid, **data)
230
174231
175@hooks.hook('amqp-relation-joined')232@hooks.hook('amqp-relation-joined')
176def amqp_joined(relation_id=None):233def amqp_joined(relation_id=None):
@@ -636,7 +693,7 @@
636 'res_nova_haproxy': 'lsb:haproxy',693 'res_nova_haproxy': 'lsb:haproxy',
637 }694 }
638 resource_params = {695 resource_params = {
639 'res_nova_haproxy': 'op monitor interval="5s"'696 'res_nova_haproxy': 'op monitor interval="5s"',
640 }697 }
641698
642 vip_group = []699 vip_group = []
@@ -674,12 +731,21 @@
674 clones = {731 clones = {
675 'cl_nova_haproxy': 'res_nova_haproxy'732 'cl_nova_haproxy': 'res_nova_haproxy'
676 }733 }
734 colocations = {}
735
736 if config('single-nova-consoleauth') and console_attributes('protocol'):
737 colocations['vip_consoleauth'] = COLO_CONSOLEAUTH
738 init_services['res_nova_consoleauth'] = 'nova-consoleauth'
739 resources['res_nova_consoleauth'] = AGENT_CONSOLEAUTH
740 resource_params['res_nova_consoleauth'] = AGENT_CA_PARAMS
741
677 relation_set(init_services=init_services,742 relation_set(init_services=init_services,
678 corosync_bindiface=cluster_config['ha-bindiface'],743 corosync_bindiface=cluster_config['ha-bindiface'],
679 corosync_mcastport=cluster_config['ha-mcastport'],744 corosync_mcastport=cluster_config['ha-mcastport'],
680 resources=resources,745 resources=resources,
681 resource_params=resource_params,746 resource_params=resource_params,
682 clones=clones)747 clones=clones,
748 colocations=colocations)
683749
684750
685@hooks.hook('ha-relation-changed')751@hooks.hook('ha-relation-changed')
686752
=== 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-18 03:44:48 +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