Service startup and error handling


#1

Ohai Chefs,

when provisioning an EC2 micro instance to be used as a very basic
LAMP server, I get an error during the chef run when the database dump
should be loaded on the database (connection refused - port 3306
unreachable).

However, the subsequent run go fine, without any additional tricks
done manually.

I think that there is no assurance that between a service declared as
’started’ (with the community mysql cookbook recipe) is really ready
to handle client requests (and I know, using a low resource instance
like the micro doesn’t helps at all).

I am wondering if someone else got this problem, and if there is a way
to avoid to fix things on the next run (we are hot-deploying
web-applications, and it should be as fast as possible since an user
is waiting for it).

Can I trap the error raised by the execute resource (used to restore
the database dump), and retry it a few times before finally exit with
error?

Thanks!


Giovanni Toraldo
http://gionn.net


#2

Hi

All resources support ‘retries’ - maybe that helps you?
http://docs.opscode.com/resource_common.html#attributes

You could the do
execute ‘foo’ do
retries 3
retry_delay 3

Cheers
Sölvi

On Mon, Dec 30, 2013 at 9:51 AM, Giovanni Toraldo me@gionn.net wrote:

Ohai Chefs,

when provisioning an EC2 micro instance to be used as a very basic
LAMP server, I get an error during the chef run when the database dump
should be loaded on the database (connection refused - port 3306
unreachable).

However, the subsequent run go fine, without any additional tricks
done manually.

I think that there is no assurance that between a service declared as
’started’ (with the community mysql cookbook recipe) is really ready
to handle client requests (and I know, using a low resource instance
like the micro doesn’t helps at all).

I am wondering if someone else got this problem, and if there is a way
to avoid to fix things on the next run (we are hot-deploying
web-applications, and it should be as fast as possible since an user
is waiting for it).

Can I trap the error raised by the execute resource (used to restore
the database dump), and retry it a few times before finally exit with
error?

Thanks!


Giovanni Toraldo
http://gionn.net


#3

On Mon, Dec 30, 2013 at 11:41 AM, Sölvi Páll Ásgeirsson
solvip@gmail.com wrote:

All resources support ‘retries’ - maybe that helps you?

retries and retry_delay should do the trick, thanks!


Giovanni Toraldo
http://gionn.net


#4

It’s also common to write “block until operational” logic for daemons
that take a while to start up and become functional. Example:

https://github.com/opscode-cookbooks/jenkins/blob/master/recipes/server.rb#L100

  • Julian

On Mon, Dec 30, 2013 at 4:51 AM, Giovanni Toraldo me@gionn.net wrote:

Ohai Chefs,

when provisioning an EC2 micro instance to be used as a very basic
LAMP server, I get an error during the chef run when the database dump
should be loaded on the database (connection refused - port 3306
unreachable).

However, the subsequent run go fine, without any additional tricks
done manually.

I think that there is no assurance that between a service declared as
’started’ (with the community mysql cookbook recipe) is really ready
to handle client requests (and I know, using a low resource instance
like the micro doesn’t helps at all).

I am wondering if someone else got this problem, and if there is a way
to avoid to fix things on the next run (we are hot-deploying
web-applications, and it should be as fast as possible since an user
is waiting for it).

Can I trap the error raised by the execute resource (used to restore
the database dump), and retry it a few times before finally exit with
error?

Thanks!


Giovanni Toraldo
http://gionn.net


[ Julian C. Dunn jdunn@aquezada.com * Sorry, I’m ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]