[openstack-dev] [puppet] Re: Puppet-OpenStack API providers - Follow up

Colleen Murphy colleen at gazlene.net
Tue May 5 18:20:15 UTC 2015


I'm cross-posting to the dev list since this conversation should be
happening there and is related to another thread there. I'm going to
top-post a summary and then respond inline.

The summary so far is that puppet-openstacklib provides a way to pass in
credentials to an API-driven puppet type via an auth parameter[1] included
in the types like so[2]. The benefit of this is that a user could create
additional API resources, such as keystone_user, by passing in credentials
directly to the type (presumably via hiera) without having to read
credentials out of keystone.conf. The desire for something like this was
outlined in the initial aviator blueprint[3] (the openstackclient
blueprint[4] changed some of the design parameters, but not that one).

self.instances and self.prefetch are class methods provided by puppet that
types and providers typically override. These methods are unable to read
type parameters, as far as I can tell, because they do not have a specific
instance from which to look up those parameters. In our implementation,
self.instances exists so that the command `puppet resource keystone_user`
works and returns a list of keystone_users, and we don't use self.prefetch.
So, the way the providers are intended to work right now is: when creating
a single resource, to run a custom 'instances' object method to list
resources and check for existence, which can use username/password
credentials passed in to the resource OR use username/password credentials
set as environment variables OR fall back to reading admin_token
credentials from keystone.conf, as it always did; when run in `puppet
resource` mode, it runs self.instances which can only use credentials set
as environment variables or read credentials from keystone.conf since it
has no way to accept an auth parameter.

There are a couple of problems with this approach, one outlined by Gilles
below and another that I'm just noticing.

On Mon, May 4, 2015 at 8:34 PM, Gilles Dubreuil <gil.dubreuil at gmail.com>
wrote:

> Hi Colleen,
>
> The issue is about having to deal with 2 different code paths because
> authentication could be optionally passed to a resource instance where it
> can't when dealing with self.instances.
> Its creates many complications down the road.
> I initially expressed that from a technical OO point of view, although as
> you said it doesn't really matter.
> So, let's look at those examples:
> https://review.openstack.org/#/c/178385/3/lib/puppet/provider/keystone.rb
>
> https://review.openstack.org/#/c/178456/6/lib/puppet/provider/keystone_endpoint/openstack.rb
>
> Providers should not have to go through that.
>
That is indeed pretty awful, I had no idea this would get so complicated
when I initially wrote this.

I'm also noticing what looks like a major flaw in that the object instances
method seems almost entirely useless. A resource looks up the full list of
resources but only ever stores one[5]. So the goal of replacing
self.prefetch with an object method that had access to the auth params is
just not accomplished at all.

>
> This is why I think avoiding passing authentication details in some case
> (instance) should be avoided.
> The authentication is provided by another layer, basically the
> environment, whether that comes from.
>
Given the added complexity that you pointed out and the fact that the
motivation behind some of that complexity is moot, I'm inclined to agree.
We could avoid this complexity and be be able to take advantage of
self.prefetch (which should speed up performance) if we did away with the
auth parameter and the methods needed to accommodate that parameter.

The modules do not use that auth parameter themselves, it's intended as an
add-on if users wanted to include extra keystone_user, etc, resources in
their profiles and didn't want to worry about running it on the keystone
node. I rather doubt anyone is actually using that yet, and I'm curious if
anyone has a desire to keep it around.

So if the providers could both read a config file (keystone.conf,
glance-api.conf, etc) and read environment variables for authentication,
would that be desireable?

The auth param can accept a path to an openrc file, but if we just assumed
a certain path we could have the provider check that for credentials as
well. puppet-openstack_extras happens to place it in /root/openrc[6].

>
> Don't get me wrong the new openstacklib is great but the authentication
> being different between class and instances.
> Again, the authentication should be the same for the a whole provider,
> unconditionally.
> Otherwise, sure it works, I don't know how to put it, honestly, it breaks
> the spirit of the providers.
>
> Richm, imcsk8, and I have discussed around that issue (keystone v2/v3
> support) and decided to talk to you before pushing anything, but we do
> think this boulder to be removed.
> By doing so we'll be able to move faster.
>
Thanks for doing so. I'm glad we could have this discussion.

>
> I'm in time zone UTC+10 - Will try tomorrow morning for me, arvo for you.
>
> Gilles
>
> --
>
>  To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-openstack+unsubscribe at puppetlabs.com.
>

Colleen

[1]
http://git.openstack.org/cgit/stackforge/puppet-openstacklib/tree/lib/puppet/util/openstack.rb
[2]
http://git.openstack.org/cgit/stackforge/puppet-keystone/tree/lib/puppet/type/keystone_user.rb#n85
[3]
https://blueprints.launchpad.net/puppet-openstacklib/+spec/use-aviator-in-module-resources
[4]
https://blueprints.launchpad.net/puppet-openstacklib/+spec/use-openstackclient-in-module-resources
[5]
http://git.openstack.org/cgit/stackforge/puppet-keystone/tree/lib/puppet/provider/keystone_user/openstack.rb#n212
[6]
http://git.openstack.org/cgit/stackforge/puppet-openstack_extras/tree/manifests/auth_file.pp#n86
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150505/642dff3f/attachment.html>


More information about the OpenStack-dev mailing list