David Lutterkort | 1 Feb 2007 01:02
Picon
Favicon

Re: [Puppet-dev] RFC: Internal redesign of the resource/transaction interface

On Wed, 2007-01-31 at 17:44 -0600, Luke Kanies wrote:
> On Jan 31, 2007, at 5:21 PM, David Lutterkort wrote:
>
> A resource container seems like a good idea.  Maybe we should develop  
> that to sit between the resources and the transaction.

Yep, that's where I think ti should go.

> Plenty of resources also cache information (e.g., the afore-mentioned  
> file stat object), and classes sometimes cache information too (e.g.,  
> the prefetching and flushing that the ParsedFile providers use).

Yeah, that's a bit of a sore point right now, since a lot of that
caching depends on how puppet goes about its business in somewhat dodgy
ways - I can think of two caching scopes that would be useful: per
server and per transaction; having explicit caches for those would make
the code a lot cleaner, and wouldn't rely on when classes and objects
are created.

> As to having two resource containers inside transactions, I think it  
> should be pretty straightforward to make the resource container  
> capable of storing both values.

Makes sense; using two containers is appealing because it seems like a
common theme inside puppet, but it might well be a bit overblown.

> Once concern I have is that if the  <at> should values are stored by the  
> container, then validation would have to be handled differently.  At  
> the least, the validation process would have to return the munge/ 
> validate result, rather than just storing it in  <at> should.  Other  
(Continue reading)

Luke Kanies | 1 Feb 2007 07:31
Favicon
Gravatar

[Puppet-dev] Kermit arrives tomorrow

Unless someone sends me some kind of crazy bugs, I'll be releasing  
kermit after breakfast tomorrow (probably around 10am GMT-5).

Get your fixes in now or whatever.

  --
  Don't throw away the old bucket until you know whether the new one  
holds
  water.  -- Swedish Proverb
  ---------------------------------------------------------------------
  Luke Kanies | http://reductivelabs.com | http://madstop.com
José González Gómez | 1 Feb 2007 10:58
Picon

Re: [Puppet-dev] RFC: Internal redesign of the resource/transaction interface


2007/1/31, Luke Kanies <luke <at> madstop.com>:
Hi all,

I think I've finally figured out the solution to at least a couple of
the significant internal design problems, and I'd like some feedback
on my ideas.  I'm not in a hurry to implement the solutions, and I've
got other development priorities that will likely overshadow this for
a while (in particular, replacing webrick and working on PuppetShow),
but I think solving these problems is pretty important.  I took a
crack at them in the fall, but it was too much work in the time I had
allotted.

Here are the changes I'm thinking of:

First, make 'retrieve' (on both attributes and types) return a value,
rather than setting <at> is internally.  This makes the classes much more
generically useful, and it means I can get rid of all of the code
related to caching or flushing those values.  The values would get
stored in the transaction, and each transaction would have a new
value list.

As part of this change, the [] methods would be changed to directly
modify and retrieve current state.  Right now, they set the <at> should
values and retrieve the ' <at> is' values, which is really confusing, and
probably just plain stupid.  I've actually stopped using those
methods internally because I was getting them wrong so often
(instead, I use 'is' and 'should' methods).

Second, change 'insync?' and 'sync' to accept values.  Thus, the
StateChange instances would pull the values using 'retrieve', and
then pass them back into the objects when necessary.  This makes the
transactions and StateChanges more powerful controllers, rather than
just triggering changes in internal state.

Third, create a cache in each transaction to store the current and
desired values.  The cache would also store the results of the
'insync' tests, so that the transaction could report exactly which
states weren't in sync.  This information is kind of available using
the statechange instances, but it's not very accessible.  This change
might actually make the StateChange class either unnecessary, or at
least less important.

Fourth, provide some loose hooks between the resources and this
transaction cache, so that resources know when they're running inside
of a transaction.

The most important hook would be that the resources would know how to
look up other resources from the transaction.  Right now, all of the
resource classes have [] methods, and they all place the same
restrictions in memory that the language places:  You can't have more
than one instance of an object that manages a given resource.  This
restriction makes sense in the language, but I don't think it makes
sense in the library, especially since it's actually a real pain to
manage creation and deletion of resources.  I have a lot of code that
removes resources after every operation because of this restriction,
and the only reason the restriction even exists is because I was
confused when I did the initial implemention; the restriction should
only ever have been in the language and never in the library.

Another important hook would be the ability to cache random
information in the transaction.  For instance, a file resource could
cache its 'stat' object in the transaction, so that every transaction
forced the resource to get a new stat.  This, again, would simplify a
good bit of internal code, and it would reduce the likelihood of
failures related to caching problems.

The damage:

All existing types would have to be migrated to this new system.
I've done 9/10s of the migration in a previous branch, but I had to
give up because I was on a release deadline and the 'cron' type (the
bane of my existence) was impossible to migrate.  I would need to
modify 'cron' to use providers, which would allow me to fix the
problems that stopped the work before.

I think I can get backwards compatibility for most types until the
migration is complete.  There are accessors for all of the variables
in question, so I can check the work and throw warnings when things
don't behave as they should yet still function correctly.

Also, it's going to take a while to do this.  I don't really know how
long, but I'd expect at least 3-4 days, plus 1-2 days fixing the cron
type (did I mention that it's my bane?).  The cron type needs to be
fixed anyway, though.

The results:

First and foremost, types would no longer have to maintain internal
state, which is a pretty big deal both in terms of reducing code
quantity and failures.

Second, the resources would become much more useful outside of
transactions.  Currently, if you want to figure out a file's uid, you
have to create the file, call 'retrieve' on it, then call 'file.is
(:owner)', which is just silly.  This way, you could just run 'file
[:owner]' and get the value right then.  This is an important fact
for me, because it suddenly becomes a lot easier for other ruby
applications to use the Puppet library to interact with systems,
whereas they'd currently pretty much have to follow Puppet's
transactional model to get anything useful done.

Third, it'd be much easier to create far better reports, because the
transaction would have easy access to all resources, and the current
vs. desired state of all of their attributes.

Comments?  Questions?  Recommendations?

Sorry if I'm saying anything stupid, but I don't know almost anything about puppet internals... could this redesign be seized to include some kind of hooks for "transition actions", this is, things to be done when there is a change in the state of some puppet managed resource? I asked for this some time ago, and it was clear that I had to learn about puppet internals to develop this idea, but I haven't had the time :(

Best regards
Jose
_______________________________________________
Puppet-dev mailing list
Puppet-dev <at> madstop.com
https://mail.madstop.com/mailman/listinfo/puppet-dev
José González Gómez | 1 Feb 2007 10:37
Picon

Re: [Puppet-dev] RFC: Internal redesign of the resource/transaction interface


2007/1/31, Luke Kanies <luke <at> madstop.com>:
Hi all,

I think I've finally figured out the solution to at least a couple of
the significant internal design problems, and I'd like some feedback
on my ideas.  I'm not in a hurry to implement the solutions, and I've
got other development priorities that will likely overshadow this for
a while (in particular, replacing webrick and working on PuppetShow),
but I think solving these problems is pretty important.  I took a
crack at them in the fall, but it was too much work in the time I had
allotted.

Here are the changes I'm thinking of:

First, make 'retrieve' (on both attributes and types) return a value,
rather than setting <at> is internally.  This makes the classes much more
generically useful, and it means I can get rid of all of the code
related to caching or flushing those values.  The values would get
stored in the transaction, and each transaction would have a new
value list.

As part of this change, the [] methods would be changed to directly
modify and retrieve current state.  Right now, they set the <at> should
values and retrieve the ' <at> is' values, which is really confusing, and
probably just plain stupid.  I've actually stopped using those
methods internally because I was getting them wrong so often
(instead, I use 'is' and 'should' methods).

Second, change 'insync?' and 'sync' to accept values.  Thus, the
StateChange instances would pull the values using 'retrieve', and
then pass them back into the objects when necessary.  This makes the
transactions and StateChanges more powerful controllers, rather than
just triggering changes in internal state.

Third, create a cache in each transaction to store the current and
desired values.  The cache would also store the results of the
'insync' tests, so that the transaction could report exactly which
states weren't in sync.  This information is kind of available using
the statechange instances, but it's not very accessible.  This change
might actually make the StateChange class either unnecessary, or at
least less important.

Fourth, provide some loose hooks between the resources and this
transaction cache, so that resources know when they're running inside
of a transaction.

The most important hook would be that the resources would know how to
look up other resources from the transaction.  Right now, all of the
resource classes have [] methods, and they all place the same
restrictions in memory that the language places:  You can't have more
than one instance of an object that manages a given resource.  This
restriction makes sense in the language, but I don't think it makes
sense in the library, especially since it's actually a real pain to
manage creation and deletion of resources.  I have a lot of code that
removes resources after every operation because of this restriction,
and the only reason the restriction even exists is because I was
confused when I did the initial implemention; the restriction should
only ever have been in the language and never in the library.

Another important hook would be the ability to cache random
information in the transaction.  For instance, a file resource could
cache its 'stat' object in the transaction, so that every transaction
forced the resource to get a new stat.  This, again, would simplify a
good bit of internal code, and it would reduce the likelihood of
failures related to caching problems.

The damage:

All existing types would have to be migrated to this new system.
I've done 9/10s of the migration in a previous branch, but I had to
give up because I was on a release deadline and the 'cron' type (the
bane of my existence) was impossible to migrate.  I would need to
modify 'cron' to use providers, which would allow me to fix the
problems that stopped the work before.

I think I can get backwards compatibility for most types until the
migration is complete.  There are accessors for all of the variables
in question, so I can check the work and throw warnings when things
don't behave as they should yet still function correctly.

Also, it's going to take a while to do this.  I don't really know how
long, but I'd expect at least 3-4 days, plus 1-2 days fixing the cron
type (did I mention that it's my bane?).  The cron type needs to be
fixed anyway, though.

The results:

First and foremost, types would no longer have to maintain internal
state, which is a pretty big deal both in terms of reducing code
quantity and failures.

Second, the resources would become much more useful outside of
transactions.  Currently, if you want to figure out a file's uid, you
have to create the file, call 'retrieve' on it, then call 'file.is
(:owner)', which is just silly.  This way, you could just run 'file
[:owner]' and get the value right then.  This is an important fact
for me, because it suddenly becomes a lot easier for other ruby
applications to use the Puppet library to interact with systems,
whereas they'd currently pretty much have to follow Puppet's
transactional model to get anything useful done.

Third, it'd be much easier to create far better reports, because the
transaction would have easy access to all resources, and the current
vs. desired state of all of their attributes.

Comments?  Questions?  Recommendations?

Sorry if I'm saying anything stupid, but I don't know almost anything about puppet internals... could this redesign be seized to include some kind of hooks for "transition actions", this is, things to be done when there is a change in the state of some puppet managed resource? I asked for this some time ago, and it was clear that I had to learn about puppet internals to develop this idea, but I haven't had the time :(

Best regards
Jose
_______________________________________________
Puppet-dev mailing list
Puppet-dev <at> madstop.com
https://mail.madstop.com/mailman/listinfo/puppet-dev
puppet | 1 Feb 2007 16:43

[Puppet-dev] #469: Rails support reopens the log file and database on every connection

#469: Rails support reopens the log file and database on every connection
---------------------+------------------------------------------------------
 Reporter:  luke     |       Owner:  luke  
     Type:  defect   |      Status:  new   
 Priority:  normal   |   Milestone:  grover
Component:  library  |     Version:  0.22.0
 Severity:  normal   |    Keywords:        
---------------------+------------------------------------------------------
 I got 'too many open files' because of this, and when I checked the open
 file list with lsof, there were tens or hundreds of copies of the log and
 sqlite filehandles.

 I'm going to hold this until grover since it's just a server-side error
 and the Rails support is still explicitly experimental, but it should
 clearly be solved.

--

-- 
Ticket URL: <https://reductivelabs.com/cgi-bin/puppet.cgi/ticket/469>
puppet <https://reductivelabs.com>
Puppet - Portable System Automation
puppet | 1 Feb 2007 16:53

[Puppet-dev] #470: exec type requires that specified users exist before the configuration run.

#470: exec type requires that specified users exist before the configuration run.
---------------------+------------------------------------------------------
 Reporter:  cstorey  |       Owner:  luke
     Type:  defect   |      Status:  new 
 Priority:  normal   |   Milestone:      
Component:  parser   |     Version:      
 Severity:  normal   |    Keywords:      
---------------------+------------------------------------------------------
 If I have an example configuration like so:

 {{{
 exec { "/bin/id": user => fish, require => Package[fish] }
 # Installation of fish creates the user 'fish'.
 package { fish: ensure => present }
 }}}

 The puppet will warn that it can't create the type:

 {{{
 puppetd[3301]: Could not create X: No such user Y at
 /etc/puppet/manifests/classes/Z.pp:42
 }}}

 It seems to be the case that it's looking up the uid for 'fish' before the
 run executes, and so it'll fail to create the exec.

--

-- 
Ticket URL: <http://reductivelabs.com/trac/puppet/ticket/470>
puppet <https://reductivelabs.com>
Puppet - Portable System Automation
puppet | 1 Feb 2007 17:17

Re: [Puppet-dev] #470: exec type requires that specified users exist before the configuration run.

#470: exec type requires that specified users exist before the configuration run.
---------------------+------------------------------------------------------
 Reporter:  cstorey  |        Owner:  luke  
     Type:  defect   |       Status:  closed
 Priority:  normal   |    Milestone:        
Component:  parser   |      Version:        
 Severity:  normal   |   Resolution:  fixed 
 Keywords:           |  
---------------------+------------------------------------------------------
Changes (by luke):

  * status:  new => closed
  * resolution:  => fixed

Comment:

 Fixed in [2150].

--

-- 
Ticket URL: <https://reductivelabs.com/cgi-bin/puppet.cgi/ticket/470#comment:1>
puppet <https://reductivelabs.com>
Puppet - Portable System Automation
puppet | 1 Feb 2007 17:30

[Puppet-dev] #471: RPM creation is broken by the existence of pi

#471: RPM creation is broken by the existence of pi
--------------------+-------------------------------------------------------
 Reporter:  luke    |       Owner:  luke  
     Type:  defect  |      Status:  new   
 Priority:  normal  |   Milestone:        
Component:  puppet  |     Version:  0.22.1
 Severity:  normal  |    Keywords:        
--------------------+-------------------------------------------------------
 RPM's currently cannot be created because of 'pi'; the spec needs to be
 updated.

--

-- 
Ticket URL: <https://reductivelabs.com/cgi-bin/puppet.cgi/ticket/471>
puppet <https://reductivelabs.com>
Puppet - Portable System Automation
puppet | 1 Feb 2007 21:13

Re: [Puppet-dev] #142: The CA's public key is not being stored

#142: The CA's public key is not being stored
---------------------+------------------------------------------------------
 Reporter:  luke     |        Owner:  ajax  
     Type:  defect   |       Status:  new   
 Priority:  normal   |    Milestone:        
Component:  library  |      Version:  0.17.2
 Severity:  normal   |   Resolution:        
 Keywords:           |  
---------------------+------------------------------------------------------
Changes (by ajax):

  * owner:  luke => ajax

--

-- 
Ticket URL: <http://reductivelabs.com/trac/puppet/ticket/142#comment:5>
puppet <https://reductivelabs.com>
Puppet - Portable System Automation
puppet | 1 Feb 2007 22:27

[Puppet-dev] #472: Subclasses are not inheriting defaults

#472: Subclasses are not inheriting defaults
----------------------+-----------------------------------------------------
 Reporter:  luke      |       Owner:  luke                
     Type:  defect    |      Status:  new                 
 Priority:  high      |   Milestone:  grover              
Component:  language  |     Version:  0.22.1              
 Severity:  major     |    Keywords:  defaults inheritance
----------------------+-----------------------------------------------------
 The following code doesn't work as expected:

 {{{
 class base {
     Exec { logoutput => true }
 }

 class sub inherits base {
     exec { "/bin/echo yayness": }
 }

 include sub
 }}}

 The exec in the subclass should get the default from the parent class, but
 it does not.

 Currently, the only workaround is to move the default to the top-level of
 the site.pp file.

--

-- 
Ticket URL: <https://reductivelabs.com/trac/puppet/ticket/472>
puppet <https://reductivelabs.com>
Puppet - Portable System Automation

Gmane