2146-unified.diff is a unified diff of all changes.
--
bda
cyberpunk is dead. long live cyberpunk.
Please send your patches with git send-email after they've been git
formatted, because my MUA sees them attached and I can't reply to you
with the patch included as Luke did (hey what MUA are you using?).
See:
http://reductivelabs.com/trac/puppet/wiki/DevelopmentLifecycle#id12
I caught a few things, though:
> diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb
> index e8d116a..e45e0b7 100644
> --- a/lib/puppet/provider/service/daemontools.rb
> +++ b/lib/puppet/provider/service/daemontools.rb
> @@ -26,11 +26,16 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
>
> This provider supports out of the box:
>
> - * start/stop (mapped to enable/disable)
> + * start/stop
> * enable/disable
> * restart
> * status
>
> + If a service has ensure => \"running\", it will link /path/to/daemon to
> + /path/to/service, which will automatically enable the service.
> +
> + If a service has ensure => \"stopped\", it will only down the service, not
> + remove the /path/to/service link.
>
> """
>
> @@ -113,12 +118,9 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
> [ command(:svc), "-t", self.service]
> end
>
> - # The start command does nothing, service are automatically started
> - # when enabled by svscan. But, forces an enable if necessary
> - def start
> - # to start make sure the sevice is enabled
> - self.enable
> - # start is then automatic
> + def startcmd
> + self.enable if ! FileTest.symlink?(self.service)
> + [command(:svc), "-u", self.service ]
> end
Is it necessary to svc -u the service?
Also I don't think it is possible to put something like self.enable in
startcmd , because you don't have the guarantee startcmd will be called
at the moment puppet wants to start the service (hence you might enable
the service at the wrong moment).
And prefer unless to if not, it's easier to read.
Make it:
texecute("stop", [command(:svc), '-d', self.service] )
> File.unlink(self.service) if FileTest.symlink?(self.service)
> end
>
> def enabled?
> - FileTest.symlink?(self.service)
> + case self.status
> + when :running:
> + return :true
> + else
> + return :false
> + end
> end
This looks suspicious: enabled should not check if the service is
running, it should check if the service is enabled, or did I get your
logic wrong?
> def enable
> + Puppet.notice "Enabling %s: linking %s -> %s" % [ self.service, self.daemon, self.service ]
> File.symlink(self.daemon, self.service) if ! FileTest.symlink?(self.service)
> end
> end
--
Brice Figureau
Days of Wonder
http://www.daysofwonder.com
+------------------------------------------------------------------------------
| On 2009-04-11 08:57:05, Luke Kanies wrote:
|
| I'd appreciate it if you'd squash all of these commits into one
| commit, using rebase -i.
Will do, after below.
| Also, this patch is missing any tests; could you add some?
I have no idea how to write tests for Ruby/Puppet. I assume the rspec thread
from last week/weekend will be useful?
| > def enabled?
| > - FileTest.symlink?(self.service)
| > + case self.status
| > + when :running:
| > + return :true
| > + else
| > + return :false
| > + end
| > end
|
| Aren't you differentiating between enable/disable and start/stop in
| this patch? In that case, shouldn't this be testing for the symlink
| if it's enabled, and whether it's running to see, um, if it's running?
So, then:
http://github.com/bda/puppet/commit/d74e20d63b5da4edeb69251568037c7ed03b733e
If the service has been manually downed, and your policy says the service
should be running, I assume startcmd is the proper place to up the serivce.
| Also I don't think it is possible to put something like self.enable in
| startcmd , because you don't have the guarantee startcmd will be called
| at the moment puppet wants to start the service (hence you might enable
| the service at the wrong moment).
| And prefer unless to if not, it's easier to read.
| > + [ command(:svc), "-d", self.service ]
|
| Make it:
| texecute("stop", [command(:svc), '-d', self.service] )
Done. I assume start and restart should also use texecute?
| This looks suspicious: enabled should not check if the service is
| running, it should check if the service is enabled, or did I get your
| logic wrong?
You (and Luke) are correct. Fixed in my branch, will post patches after I
figure out rspec.
>
> Sorry for the lag. Easter weekend, Catholic girlfriend.
>
> +
> ------------------------------------------------------------------------------
> | On 2009-04-11 08:57:05, Luke Kanies wrote:
> |
> | I'd appreciate it if you'd squash all of these commits into one
> | commit, using rebase -i.
>
> Will do, after below.
>
> | Also, this patch is missing any tests; could you add some?
>
> I have no idea how to write tests for Ruby/Puppet. I assume the
> rspec thread
> from last week/weekend will be useful?
It was mostly about the tools (how to run the tests, etc.).
Rspec is actually pretty damn easy; just look at other tests for
similar classes, and ask if you have problems.
>
> | > def enabled?
> | > - FileTest.symlink?(self.service)
> | > + case self.status
> | > + when :running:
> | > + return :true
> | > + else
> | > + return :false
> | > + end
> | > end
> |
> | Aren't you differentiating between enable/disable and start/stop in
> | this patch? In that case, shouldn't this be testing for the symlink
> | if it's enabled, and whether it's running to see, um, if it's
> running?
>
> So, then:
>
> http://github.com/bda/puppet/commit/d74e20d63b5da4edeb69251568037c7ed03b733e
Because Puppet is stupidly converting true/false into symbols, you're
probably-correctly returning the symbols rather than the booleans.
However, you're enabled? method is returning :true/:false, so it will
always evaluate to true (because :false is true).
--
The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw