Bug #3113

When importing a manifest puppet needs to chill

Added by Martin Englund about 2 years ago. Updated almost 2 years ago.

Status:Closed Start date:01/26/2010
Priority:Normal Due date:
Assignee:- % Done:

100%

Category:Solaris
Target version:2.6.0
Affected Puppet version:0.25.3 Branch:markus:ticket/master/3113
Keywords:service
Votes: 4

Description

When puppet imports a manifest to create a service it needs to wait a while before proceeding, as it will often see the state as “offline*” due to the service is being started when it checks.

This generates an unnecessary error message:

err: //ssh::ops/Service[sshd-pubkey]: Failed to call refresh on Service[sshd-pubkey]: Unmanageable state 'offline*' on service svc:/ops/ssh:default

dummy.xml (1 kB) Martin Englund, 01/27/2010 08:23 am

History

Updated by Markus Roberts about 2 years ago

A few questions:

  • Is this a change from 0.24.x?
  • Rather than time based (“wait awhile”) should it be “wait for completion”?
  • Can you give context / a simple case to demonstrate the problem?
  • Is the real issue that svcs is returning “offline*” (with a trailing star) and the smf provider isn’t recognizing this as it would “offline”?

— Markus

Updated by Markus Roberts about 2 years ago

  • Status changed from Unreviewed to Needs More Information

Updated by Martin Englund about 2 years ago

A few answers :) * It has always been this way, I’ve just not gotten around to file the bug until now * Waiting for completion could be dangerous, as the import + enable could cause a very long wait (defined in the timeout in the service manifest) * I’ve attached a service manifest which will take 30 seconds to start * Yes it returns “offline*” with a trailing star when the state is in transition.

If you run the query as

svcs -o state,nstate fmri

you get the desired end state too, so if it (the end state) is the desired state (online in most cases), it should assume it is going to be successful and continue.

E.g.

root@uk-lp-1 # svccfg import dummy.xml
root@uk-lp-1 # svcs dummy
STATE          STIME    FMRI
offline*        8:23:18 svc:/dummy:default
root@uk-lp-1 # svcs -o state,nstate dummy
STATE          NSTATE
offline        online

Updated by Markus Roberts about 2 years ago

  • Status changed from Needs More Information to Investigating

Updated by Martin Englund about 2 years ago

Try this fix: http://github.com/pmenglund/puppet/commit/5f25a5cd4bb742cc626f995b158fb1e2cf193750:

diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb
index 0071a8c..e7510d3 100755
--- a/lib/puppet/provider/service/smf.rb
+++ b/lib/puppet/provider/service/smf.rb
@@ -70,7 +70,10 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
         end
 
         begin
-            state = svcs("-H", "-o", "state", @resource[:name]).chomp
+            # get the current state and the next state, and if the next
+            # state is set (i.e. not "-") use it for state comparison
+            states = svcs("-H", "-o", "state,nstate", @resource[:name]).chomp
+            state = states[1] == "-" ? states[0] : states[1]
         rescue Puppet::ExecutionFailure
             info "Could not get status on service %s" % self.name
             return :stopped

Updated by Nobuchika Tanaka about 2 years ago

Hi, Markus and Martin.

I also have same trouble on this topic. I checked a patch made by Martin, but this didn’t work well.

messages file shows:

Jan 29 11:48:26 kousagi puppetd[2837]: [ID 702911 daemon.notice] triggered run
Jan 29 11:48:28 kousagi puppetd[2837]: [ID 702911 daemon.error] (//Service[autofs]) Failed to retrieve current state of resource: Unmanageable state '110' on service autofs
Jan 29 11:48:28 kousagi puppetd[2837]: [ID 702911 daemon.warning] Value of 'preferred_serialization_format' (pson) is invalid for report, using default (b64_zlib_yaml)
Jan 29 11:48:28 kousagi puppetd[2837]: [ID 702911 daemon.notice] Finished catalog run in 0.59 seconds

Do you have any idea?

Updated by Martin Englund about 2 years ago

That is strange! I’ll take a look and will produce another patch today.

Can you paste the output of the command: svcs -H -o state,nstate autofs

Updated by Martin Englund about 2 years ago

Ah, it helps if I commit the changes from the right system. It was missing a “split” a the end.

Try this diff, it should work better…

diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb
index e7510d3..f7f3a31 100755
--- a/lib/puppet/provider/service/smf.rb
+++ b/lib/puppet/provider/service/smf.rb
@@ -72,7 +72,7 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
         begin
             # get the current state and the next state, and if the next
             # state is set (i.e. not "-") use it for state comparison
-            states = svcs("-H", "-o", "state,nstate", @resource[:name]).chomp
+            states = svcs("-H", "-o", "state,nstate", @resource[:name]).chomp.split
             state = states[1] == "-" ? states[0] : states[1]
         rescue Puppet::ExecutionFailure
             info "Could not get status on service %s" % self.name

Updated by Nobuchika Tanaka about 2 years ago

I checked a new patch you made, it works well!

messages file shows:

Feb  1 09:52:58 kousagi puppetd[2015]: [ID 702911 daemon.notice] triggered run
Feb  1 09:53:03 kousagi puppetd[2015]: [ID 702911 daemon.notice] (//Service[autofs]/ensure) ensure changed 'running' to 'stopped'
Feb  1 09:53:03 kousagi puppetd[2015]: [ID 702911 daemon.notice] Finished catalog run in 3.11 seconds

Updated by James Turnbull about 2 years ago

  • Status changed from Investigating to Accepted
  • Target version set to 0.25.5

Updated by James Turnbull almost 2 years ago

  • Status changed from Accepted to In Topic Branch Pending Review

Updated by James Turnbull almost 2 years ago

Pushed in commit:74cd55fbda7edf64b6bbd77143ea3f1fbdf39e30 in branch 0.25.x

Updated by James Turnbull almost 2 years ago

  • Status changed from In Topic Branch Pending Review to Closed
  • % Done changed from 0 to 100

Applied in changeset commit:74cd55fbda7edf64b6bbd77143ea3f1fbdf39e30.

Updated by James Turnbull almost 2 years ago

  • Status changed from Closed to In Topic Branch Pending Review

Updated by Markus Roberts almost 2 years ago

  • Branch set to markus:ticket/master/3113

Updated by Markus Roberts almost 2 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release

Updated by James Turnbull almost 2 years ago

  • Target version changed from 0.25.5 to 2.6.0

Updated by Markus Roberts almost 2 years ago

  • Status changed from Merged - Pending Release to Closed

Pushed as commit:1c5b3d7d4457a7c2e643a3ac160a95f14b347397 in master.

Also available in: Atom PDF