url_flush updates wrong url type

Bug #1713814 reported by Nikita Koshikov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
puppet-keystone
New
Undecided
Unassigned

Bug Description

This commit https://review.openstack.org/#/c/331623 introduced feature of updating/creating missing urls for service, however, there is problem inside self.make_id(endpoint) function. If the url is missing it won't produce ',' and then the wrong id will be used to update url.
Here is example, if we have only admin and public, function will yield:
"6b9d1a3eeea4435abd23c3fe279b76d3,6b9d1a3eeea4435abd23c3fe279b76d3"

The correct result should be
"6b9d1a3eeea4435abd23c3fe279b76d3,,6b9d1a3eeea4435abd23c3fe279b76d3"

mysql> select * from endpoint where service_id='7de1fc440d0a4270b7e013e15ec2a150';
+----------------------------------+--------------------+-----------+----------------------------------+---------------------------------------+-------+---------+-----------+
| id | legacy_endpoint_id | interface | service_id | url | extra | enabled | region_id |
+----------------------------------+--------------------+-----------+----------------------------------+---------------------------------------+-------+---------+-----------+
| 6b9d1a3eeea4435abd23c3fe279b76d3 | NULL | admin | 7de1fc440d0a4270b7e013e15ec2a150 | http://nova.fuel.local:8774/v3 | {} | 1 | RegionOne |
| 8a8f8d13b0d8439aa52d380708f7dd1e | NULL | public | 7de1fc440d0a4270b7e013e15ec2a150 | http://nova.public.fuel.local:8774/v3 | {} | 1 | RegionOne |
+----------------------------------+--------------------+-----------+----------------------------------+---------------------------------------+-------+---------+---------

And if we run puppet that will produce:
Notice: /Stage[main]/Nova::Keystone::Auth/Keystone::Resource::Service_identity[nova v3 service, user novav3]/Keystone_endpoint[RegionOne/novav3]/internal_url: internal_url changed '' to 'http://nova.fuel.local:8774/v3'
Debug: Executing '/usr/bin/openstack endpoint set 8a8f8d13b0d8439aa52d380708f7dd1e --url=http://nova.fuel.local:8774/v3'

The Notice is right - internal_url should be changed, but the command grabs public_id and changes it, instead of using internal_url. This is result in db:
mysql> select * from endpoint where service_id='7de1fc440d0a4270b7e013e15ec2a150';
+----------------------------------+--------------------+-----------+----------------------------------+--------------------------------+-------+---------+-----------+
| id | legacy_endpoint_id | interface | service_id | url | extra | enabled | region_id |
+----------------------------------+--------------------+-----------+----------------------------------+--------------------------------+-------+---------+-----------+
| 6b9d1a3eeea4435abd23c3fe279b76d3 | NULL | admin | 7de1fc440d0a4270b7e013e15ec2a150 | http://nova.fuel.local:8774/v3 | {} | 1 | RegionOne |
| 8a8f8d13b0d8439aa52d380708f7dd1e | NULL | public | 7de1fc440d0a4270b7e013e15ec2a150 | http://nova.fuel.local:8774/v3 | {} | 1 | RegionOne |
+----------------------------------+--------------------+-----------+----------------------------------+--------------------------------+-------+---------+-----------+
2 rows in set (0.00 sec)

The fix is simple:

--- lib/puppet/provider/keystone_endpoint/openstack.rb.orig 2017-08-29 20:14:49.480370509 +0000
+++ lib/puppet/provider/keystone_endpoint/openstack.rb 2017-08-29 20:13:54.248370550 +0000
@@ -164,7 +164,8 @@
     id_str = ''
     id_sep = ''
     [:admin, :internal, :public].each do |type|
- id_str += "#{id_sep}#{endpoint[type][:id]}" if endpoint[type]
+ id_str += "#{id_sep}"
+ id_str += "#{endpoint[type][:id]}" if endpoint[type]
       id_sep = ','
     end
     Puppet.debug "Make_id: #{id_str}"

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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