# Is there a timeout attr for the service resource?

**URL:** https://discourse.chef.io/t/is-there-a-timeout-attr-for-the-service-resource/4452
**Category:** Chef Infra (archive)
**Created:** [September 13, 2013, 9:58pm UTC](https://discourse.chef.io/t/is-there-a-timeout-attr-for-the-service-resource/4452 "2013-09-13T21:58:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Kallen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallen/32/1049_2.png) [@Kallen](https://discourse.chef.io/u/Kallen)
#### Post date: [September 13, 2013, 9:58pm UTC](https://discourse.chef.io/t/is-there-a-timeout-attr-for-the-service-resource/4452/1 "2013-09-13T21:58:46Z")

</div>

hai.

In a recipe, the service resource to start mysql threw an exception because it  
took too long for it to start mysql. The node that runs this recipe should be  
expected to possibly take several minutes to start mysql, since innodb is doing  
a recovery.

[2013-09-13T21:37:46+00:00] DEBUG: service[mysql] supports status, running  
[2013-09-13T21:47:56+00:00] DEBUG: Re-raising exception: Mixlib::ShellOut::CommandTimeout - service[mysql] (dbci::drone line 61) had an error: Mixlib::ShellOut::CommandTimeout: command timed out:  
---- Begin output of /sbin/service mysql start ----  
STDOUT: Starting MySQL (Percona Server)…

After this exception was thrown, mysql actually did finish successfully starting  
up.

I looked for a way to set a timeout for the service resource, but didn’t see  
a way to do it. Can anyone advise?

thanks,  
kallen

---

<div class="post-metadata">

### Author: ![Charles\_Johnson1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/charles_johnson1/32/210_2.png) [@Charles\_Johnson1](https://discourse.chef.io/u/Charles_Johnson1)
#### Post date: [September 13, 2013, 11:14pm UTC](https://discourse.chef.io/t/is-there-a-timeout-attr-for-the-service-resource/4452/2 "2013-09-13T23:14:18Z")

</div>

While it’s not a timeout change, what you can do instead is set a retry.

All resources support a retries attribute, which takes an int as number of retries to attempt before marking the resource failed. There’s also a retry\_delay attribute, to set a timer between retries.

More info here: [http://docs.opscode.com/chef/resources.html#attributes](http://docs.opscode.com/chef/resources.html#attributes)

On September 13, 2013 at 2:58:58 PM, [kallen@groknaut.net](mailto:kallen@groknaut.net) ([kallen@groknaut.net](mailto:kallen@groknaut.net)) wrote:

hai.

In a recipe, the service resource to start mysql threw an exception because it  
took too long for it to start mysql. The node that runs this recipe should be  
expected to possibly take several minutes to start mysql, since innodb is doing  
a recovery.

[2013-09-13T21:37:46+00:00] DEBUG: service[mysql] supports status, running  
[2013-09-13T21:47:56+00:00] DEBUG: Re-raising exception: Mixlib::ShellOut::CommandTimeout - service[mysql] (dbci::drone line 61) had an error: Mixlib::ShellOut::CommandTimeout: command timed out:  
---- Begin output of /sbin/service mysql start ----  
STDOUT: Starting MySQL (Percona Server)…

After this exception was thrown, mysql actually did finish successfully starting  
up.

I looked for a way to set a timeout for the service resource, but didn’t see  
a way to do it. Can anyone advise?

thanks,  
kallen

---

<div class="post-metadata">

### Author: ![Kallen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallen/32/1049_2.png) [@Kallen](https://discourse.chef.io/u/Kallen)
#### Post date: [September 13, 2013, 11:19pm UTC](https://discourse.chef.io/t/is-there-a-timeout-attr-for-the-service-resource/4452/3 "2013-09-13T23:19:00Z")

</div>

On Fri, 13 Sep 2013, Charles Johnson wrote:

> While it's not a timeout change, what you can do instead is set a retry.
> 
> All resources support a retries attribute, which takes an int as number of retries to attempt before marking the resource failed. There's also a retry\_delay attribute, to set a timer between retries.
> 
> More info here: [All Infra Resources](http://docs.opscode.com/chef/resources.html#attributes)

I thought about that, but thought that might not work because the "start" is  
already still in flight, waiting for innodb recovery to finish. I assumed  
a retry of "start" wouldn't work, might exit non-zero. But I haven't tried it  
yet. I'll give it a try. Thanks.

Still, I would think a timeout on service resource would be useful.

And I guess I could also try starting mysql without the service resource, but  
within a ruby\_block that creates the timeout..

> On September 13, 2013 at 2:58:58 PM, [kallen@groknaut.net](mailto:kallen@groknaut.net) ([kallen@groknaut.net](mailto:kallen@groknaut.net)) wrote:
> 
> hai.
> 
> In a recipe, the service resource to start mysql threw an exception because it  
> took too long for it to start mysql. The node that runs this recipe should be  
> expected to possibly take several minutes to start mysql, since innodb is doing  
> a recovery.
> 
> [2013-09-13T21:37:46+00:00] DEBUG: service[mysql] supports status, running  
> [2013-09-13T21:47:56+00:00] DEBUG: Re-raising exception: Mixlib::ShellOut::CommandTimeout - service[mysql] (dbci::drone line 61) had an error: Mixlib::ShellOut::CommandTimeout: command timed out:  
> ---- Begin output of /sbin/service mysql start ----  
> STDOUT: Starting MySQL (Percona Server)............
> 
> After this exception was thrown, mysql actually did finish successfully starting  
> up.
> 
> I looked for a way to set a timeout for the service resource, but didn't see  
> a way to do it. Can anyone advise?
> 
> thanks,  
> kallen

---

<div class="post-metadata">

### Author: ![Kallen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallen/32/1049_2.png) [@Kallen](https://discourse.chef.io/u/Kallen)
#### Post date: [September 14, 2013, 1:21am UTC](https://discourse.chef.io/t/is-there-a-timeout-attr-for-the-service-resource/4452/4 "2013-09-14T01:21:42Z")

</div>

On Fri, 13 Sep 2013, [kallen@groknaut.net](mailto:kallen@groknaut.net) wrote:

> On Fri, 13 Sep 2013, Charles Johnson wrote:
> 
> > While it's not a timeout change, what you can do instead is set a retry.
> > 
> > All resources support a retries attribute, which takes an int as number of retries to attempt before marking the resource failed. There's also a retry\_delay attribute, to set a timer between retries.
> > 
> > More info here: [All Infra Resources](http://docs.opscode.com/chef/resources.html#attributes)
> 
> I thought about that, but thought that might not work because the "start" is  
> already still in flight, waiting for innodb recovery to finish. I assumed  
> a retry of "start" wouldn't work, might exit non-zero. But I haven't tried it  
> yet. I'll give it a try. Thanks.

When I issue another "start", the init script (from percona pkg) isn't smart  
enough to see that mysql is already trying to start, and the result of the second  
start is the following errors spewed over and over again into the log:

InnoDB: Unable to lock ./ibdata1, error: 11  
InnoDB: Check that you do not already have another mysqld process  
InnoDB: using the same InnoDB data or log files.

Next I guess I'll try a timeout inside a ruby\_block without using the service  
resource, unless someone has other suggestions.

thanks,  
kallen

> Still, I would think a timeout on service resource would be useful.
> 
> And I guess I could also try starting mysql without the service resource, but  
> within a ruby\_block that creates the timeout..
> 
> > On September 13, 2013 at 2:58:58 PM, [kallen@groknaut.net](mailto:kallen@groknaut.net) ([kallen@groknaut.net](mailto:kallen@groknaut.net)) wrote:
> > 
> > hai.
> > 
> > In a recipe, the service resource to start mysql threw an exception because it  
> > took too long for it to start mysql. The node that runs this recipe should be  
> > expected to possibly take several minutes to start mysql, since innodb is doing  
> > a recovery.
> > 
> > [2013-09-13T21:37:46+00:00] DEBUG: service[mysql] supports status, running  
> > [2013-09-13T21:47:56+00:00] DEBUG: Re-raising exception: Mixlib::ShellOut::CommandTimeout - service[mysql] (dbci::drone line 61) had an error: Mixlib::ShellOut::CommandTimeout: command timed out:  
> > ---- Begin output of /sbin/service mysql start ----  
> > STDOUT: Starting MySQL (Percona Server)............
> > 
> > After this exception was thrown, mysql actually did finish successfully starting  
> > up.
> > 
> > I looked for a way to set a timeout for the service resource, but didn't see  
> > a way to do it. Can anyone advise?
> > 
> > thanks,  
> > kallen

---

<div class="post-metadata">

### Author: ![Dan\_Razzell](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@Dan\_Razzell](https://discourse.chef.io/u/Dan_Razzell)
#### Post date: [September 14, 2013, 1:42am UTC](https://discourse.chef.io/t/is-there-a-timeout-attr-for-the-service-resource/4452/5 "2013-09-14T01:42:22Z")

</div>

You could try subclassing the service resource. (I haven't looked at it  
but if it uses Chef::Mixin::ShellOut you just have to find a way to add  
a :timeout value to the options hash passed to shell\_out.)

On 13-09-13 06:21 PM, [kallen@groknaut.net](mailto:kallen@groknaut.net) wrote:

> On Fri, 13 Sep 2013, [kallen@groknaut.net](mailto:kallen@groknaut.net) wrote:
> 
> > On Fri, 13 Sep 2013, Charles Johnson wrote:
> > 
> > > While it's not a timeout change, what you can do instead is set a retry.
> > > 
> > > All resources support a retries attribute, which takes an int as number of retries to attempt before marking the resource failed. There's also a retry\_delay attribute, to set a timer between retries.
> > > 
> > > More info here: [http://docs.opscode.com/chef/resources.html#attributes](http://docs.opscode.com/chef/resources.html#attributes)  
> > > I thought about that, but thought that might not work because the "start" is  
> > > already still in flight, waiting for innodb recovery to finish. I assumed  
> > > a retry of "start" wouldn't work, might exit non-zero. But I haven't tried it  
> > > yet. I'll give it a try. Thanks.  
> > > When I issue another "start", the init script (from percona pkg) isn't smart  
> > > enough to see that mysql is already trying to start, and the result of the second  
> > > start is the following errors spewed over and over again into the log:
> 
> InnoDB: Unable to lock ./ibdata1, error: 11  
> InnoDB: Check that you do not already have another mysqld process  
> InnoDB: using the same InnoDB data or log files.
> 
> Next I guess I'll try a timeout inside a ruby\_block without using the service  
> resource, unless someone has other suggestions.
> 
> thanks,  
> kallen
> 
> > Still, I would think a timeout on service resource would be useful.
> > 
> > And I guess I could also try starting mysql without the service resource, but  
> > within a ruby\_block that creates the timeout..
> > 
> > > On September 13, 2013 at 2:58:58 PM, [kallen@groknaut.net](mailto:kallen@groknaut.net) ([kallen@groknaut.net](mailto:kallen@groknaut.net)) wrote:
> > > 
> > > hai.
> > > 
> > > In a recipe, the service resource to start mysql threw an exception because it  
> > > took too long for it to start mysql. The node that runs this recipe should be  
> > > expected to possibly take several minutes to start mysql, since innodb is doing  
> > > a recovery.
> > > 
> > > [2013-09-13T21:37:46+00:00] DEBUG: service[mysql] supports status, running  
> > > [2013-09-13T21:47:56+00:00] DEBUG: Re-raising exception: Mixlib::ShellOut::CommandTimeout - service[mysql] (dbci::drone line 61) had an error: Mixlib::ShellOut::CommandTimeout: command timed out:  
> > > ---- Begin output of /sbin/service mysql start ----  
> > > STDOUT: Starting MySQL (Percona Server)............
> > > 
> > > After this exception was thrown, mysql actually did finish successfully starting  
> > > up.
> > > 
> > > I looked for a way to set a timeout for the service resource, but didn't see  
> > > a way to do it. Can anyone advise?
> > > 
> > > thanks,  
> > > kallen
