Partial Convergence Support

Hello,

Is anyone aware of a handler, or a technique in use, for indicating that
Chef has not successfully converged the node?

Iโ€™m considering writing a custom handler that will check an "unfinished"
flag and either kill chef with a custom exit code( :expressionless: ) or write something
to stdout that I can look for.

Cheers,
-Greg

It should exit with a non zero code if there is an error, what are you trying to accomplish!

On June 23, 2014 3:59:17 PM PDT, Greg Zapp greg.zapp@gmail.com wrote:

Hello,

Is anyone aware of a handler, or a technique in use, for indicating
that
Chef has not successfully converged the node?

I'm considering writing a custom handler that will check an
"unfinished"
flag and either kill chef with a custom exit code( :expressionless: ) or write
something
to stdout that I can look for.

Cheers,
-Greg

Non-zero exit codes do not necessarily, or do not have to, indicate an
error.

I'm trying to accomplish Chef finishing and indicating it has not fully
converged the node. I apologize if that wasn't clear in my original post.

-Greg

On Tue, Jun 24, 2014 at 11:08 AM, Noah Kantrowitz noah@coderanger.net
wrote:

It should exit with a non zero code if there is an error, what are you
trying to accomplish!

On June 23, 2014 3:59:17 PM PDT, Greg Zapp greg.zapp@gmail.com wrote:

Hello,

Is anyone aware of a handler, or a technique in use, for indicating that
Chef has not successfully converged the node?

I'm considering writing a custom handler that will check an "unfinished"
flag and either kill chef with a custom exit code( :expressionless: ) or write something
to stdout that I can look for.

Cheers,
-Greg

A non zero exit code does exactly that in Chef. If it is completed, we
return 0.
On Jun 23, 2014 4:18 PM, "Greg Zapp" greg.zapp@gmail.com wrote:

Non-zero exit codes do not necessarily, or do not have to, indicate an
error.

I'm trying to accomplish Chef finishing and indicating it has not fully
converged the node. I apologize if that wasn't clear in my original post.

-Greg

On Tue, Jun 24, 2014 at 11:08 AM, Noah Kantrowitz noah@coderanger.net
wrote:

It should exit with a non zero code if there is an error, what are you
trying to accomplish!

On June 23, 2014 3:59:17 PM PDT, Greg Zapp greg.zapp@gmail.com wrote:

Hello,

Is anyone aware of a handler, or a technique in use, for indicating that
Chef has not successfully converged the node?

I'm considering writing a custom handler that will check an "unfinished"
flag and either kill chef with a custom exit code( :expressionless: ) or write something
to stdout that I can look for.

Cheers,
-Greg

Hi Adam,

Are you aware of any built-in way to indicate it has not completed without
throwing an exception or otherwise stopping the run?

Thanks,
-Greg

On Tue, Jun 24, 2014 at 12:41 PM, Adam Jacob adam@opscode.com wrote:

A non zero exit code does exactly that in Chef. If it is completed, we
return 0.
On Jun 23, 2014 4:18 PM, "Greg Zapp" greg.zapp@gmail.com wrote:

Non-zero exit codes do not necessarily, or do not have to, indicate an
error.

I'm trying to accomplish Chef finishing and indicating it has not fully
converged the node. I apologize if that wasn't clear in my original post.

-Greg

On Tue, Jun 24, 2014 at 11:08 AM, Noah Kantrowitz noah@coderanger.net
wrote:

It should exit with a non zero code if there is an error, what are you
trying to accomplish!

On June 23, 2014 3:59:17 PM PDT, Greg Zapp greg.zapp@gmail.com wrote:

Hello,

Is anyone aware of a handler, or a technique in use, for indicating
that Chef has not successfully converged the node?

I'm considering writing a custom handler that will check an
"unfinished" flag and either kill chef with a custom exit code( :expressionless: ) or
write something to stdout that I can look for.

Cheers,
-Greg

I don't understand what you're trying to accomplish. :slight_smile: Can you give us
more of a use case?

On Mon, Jun 23, 2014 at 5:46 PM, Greg Zapp greg.zapp@gmail.com wrote:

Hi Adam,

Are you aware of any built-in way to indicate it has not completed without
throwing an exception or otherwise stopping the run?

Thanks,
-Greg

On Tue, Jun 24, 2014 at 12:41 PM, Adam Jacob adam@opscode.com wrote:

A non zero exit code does exactly that in Chef. If it is completed, we
return 0.
On Jun 23, 2014 4:18 PM, "Greg Zapp" greg.zapp@gmail.com wrote:

Non-zero exit codes do not necessarily, or do not have to, indicate an
error.

I'm trying to accomplish Chef finishing and indicating it has not fully
converged the node. I apologize if that wasn't clear in my original post.

-Greg

On Tue, Jun 24, 2014 at 11:08 AM, Noah Kantrowitz noah@coderanger.net
wrote:

It should exit with a non zero code if there is an error, what are you
trying to accomplish!

On June 23, 2014 3:59:17 PM PDT, Greg Zapp greg.zapp@gmail.com wrote:

Hello,

Is anyone aware of a handler, or a technique in use, for indicating
that Chef has not successfully converged the node?

I'm considering writing a custom handler that will check an
"unfinished" flag and either kill chef with a custom exit code( :expressionless: ) or
write something to stdout that I can look for.

Cheers,
-Greg

--
Opscode, Inc.
Adam Jacob, Chief Dev Officer
T: (206) 619-7151 E: adam@opscode.com

I think you are talking about doing explicit two-run converges where something takes two full executions of chef-client? The only case where that generally comes up is windows requiring a reboot to install certain features, and even that seems fortunately minimal these days. Beyond that, Chef is very much designed to avoid doing this, so as Adam said a concrete case might help.

--Noah

On Jun 23, 2014, at 5:55 PM, Adam Jacob adam@opscode.com wrote:

I don't understand what you're trying to accomplish. :slight_smile: Can you give us more of a use case?

On Mon, Jun 23, 2014 at 5:46 PM, Greg Zapp greg.zapp@gmail.com wrote:
Hi Adam,

Are you aware of any built-in way to indicate it has not completed without throwing an exception or otherwise stopping the run?

Thanks,
-Greg

On Tue, Jun 24, 2014 at 12:41 PM, Adam Jacob adam@opscode.com wrote:
A non zero exit code does exactly that in Chef. If it is completed, we return 0.

On Jun 23, 2014 4:18 PM, "Greg Zapp" greg.zapp@gmail.com wrote:
Non-zero exit codes do not necessarily, or do not have to, indicate an error.

I'm trying to accomplish Chef finishing and indicating it has not fully converged the node. I apologize if that wasn't clear in my original post.

-Greg

On Tue, Jun 24, 2014 at 11:08 AM, Noah Kantrowitz noah@coderanger.net wrote:
It should exit with a non zero code if there is an error, what are you trying to accomplish!

On June 23, 2014 3:59:17 PM PDT, Greg Zapp greg.zapp@gmail.com wrote:
Hello,

Is anyone aware of a handler, or a technique in use, for indicating that Chef has not successfully converged the node?

I'm considering writing a custom handler that will check an "unfinished" flag and either kill chef with a custom exit code( :expressionless: ) or write something to stdout that I can look for.

Cheers,
-Greg

--
Opscode, Inc.
Adam Jacob, Chief Dev Officer
T: (206) 619-7151 E: adam@opscode.com

I'll try to expand on it a bit more :slight_smile:

I have a lot of websites that need to be installed or upgraded,
potentially. They use a custom installer and this phase requires the
database having already been setup or upgraded. These database
configurations are handled outside the web cluster. The site information
comes from a rest API. A custom service runs Chef when a cluster change is
reflect in the API. This service also records the timestamp of the most
recent resource from the remote API when Chef has fully converged the node.
It will run Chef again if the remote API indicates the cluster has changed.

This all works well however I'm looking to improve one aspect: Sites whose
databases are not ready currently end the run. This blocks other site's
resources from being processed and is not very efficient. So, I want to
skip those sites and indicate that the node is "partially converged" to my
service that runs Chef so that it knows the node is not fully converged and
can run it again until it is.

The two most direct methods I can think of involve a custom report handler
that can tell if something was postponed/skipped/etc. If so it could:
A.) Exit Chef with a custom exit code
B.) Print something to stdout that will be parsed

I'm curious if anyone knows of such a handler, or has any experience in
implementing an N-run converge setup.

Cheers,
-Greg

On Tue, Jun 24, 2014 at 12:55 PM, Adam Jacob adam@opscode.com wrote:

I don't understand what you're trying to accomplish. :slight_smile: Can you give us
more of a use case?

On Mon, Jun 23, 2014 at 5:46 PM, Greg Zapp greg.zapp@gmail.com wrote:

Hi Adam,

Are you aware of any built-in way to indicate it has not completed
without throwing an exception or otherwise stopping the run?

Thanks,
-Greg

On Tue, Jun 24, 2014 at 12:41 PM, Adam Jacob adam@opscode.com wrote:

A non zero exit code does exactly that in Chef. If it is completed, we
return 0.
On Jun 23, 2014 4:18 PM, "Greg Zapp" greg.zapp@gmail.com wrote:

Non-zero exit codes do not necessarily, or do not have to, indicate an
error.

I'm trying to accomplish Chef finishing and indicating it has not fully
converged the node. I apologize if that wasn't clear in my original post.

-Greg

On Tue, Jun 24, 2014 at 11:08 AM, Noah Kantrowitz noah@coderanger.net
wrote:

It should exit with a non zero code if there is an error, what are you
trying to accomplish!

On June 23, 2014 3:59:17 PM PDT, Greg Zapp greg.zapp@gmail.com
wrote:

Hello,

Is anyone aware of a handler, or a technique in use, for indicating
that Chef has not successfully converged the node?

I'm considering writing a custom handler that will check an
"unfinished" flag and either kill chef with a custom exit code( :expressionless: ) or
write something to stdout that I can look for.

Cheers,
-Greg

--
Opscode, Inc.
Adam Jacob, Chief Dev Officer
T: (206) 619-7151 E: adam@opscode.com

Gotcha. You can do this on a resource-by-resource basis by setting
"ignore_failure true" on a resource. Probably the easiest thing would be to
encapsulate your setup in an LWRP, set ignore_failure on that call, and
move the group of resources inside the LWRP resource.

Adam

On Mon, Jun 23, 2014 at 8:02 PM, Greg Zapp greg.zapp@gmail.com wrote:

I'll try to expand on it a bit more :slight_smile:

I have a lot of websites that need to be installed or upgraded,
potentially. They use a custom installer and this phase requires the
database having already been setup or upgraded. These database
configurations are handled outside the web cluster. The site information
comes from a rest API. A custom service runs Chef when a cluster change is
reflect in the API. This service also records the timestamp of the most
recent resource from the remote API when Chef has fully converged the node.
It will run Chef again if the remote API indicates the cluster has changed.

This all works well however I'm looking to improve one aspect: Sites whose
databases are not ready currently end the run. This blocks other site's
resources from being processed and is not very efficient. So, I want to
skip those sites and indicate that the node is "partially converged" to my
service that runs Chef so that it knows the node is not fully converged and
can run it again until it is.

The two most direct methods I can think of involve a custom report handler
that can tell if something was postponed/skipped/etc. If so it could:
A.) Exit Chef with a custom exit code
B.) Print something to stdout that will be parsed

I'm curious if anyone knows of such a handler, or has any experience in
implementing an N-run converge setup.

Cheers,
-Greg

On Tue, Jun 24, 2014 at 12:55 PM, Adam Jacob adam@opscode.com wrote:

I don't understand what you're trying to accomplish. :slight_smile: Can you give us
more of a use case?

On Mon, Jun 23, 2014 at 5:46 PM, Greg Zapp greg.zapp@gmail.com wrote:

Hi Adam,

Are you aware of any built-in way to indicate it has not completed
without throwing an exception or otherwise stopping the run?

Thanks,
-Greg

On Tue, Jun 24, 2014 at 12:41 PM, Adam Jacob adam@opscode.com wrote:

A non zero exit code does exactly that in Chef. If it is completed, we
return 0.
On Jun 23, 2014 4:18 PM, "Greg Zapp" greg.zapp@gmail.com wrote:

Non-zero exit codes do not necessarily, or do not have to, indicate an
error.

I'm trying to accomplish Chef finishing and indicating it has not
fully converged the node. I apologize if that wasn't clear in my original
post.

-Greg

On Tue, Jun 24, 2014 at 11:08 AM, Noah Kantrowitz <noah@coderanger.net

wrote:

It should exit with a non zero code if there is an error, what are
you trying to accomplish!

On June 23, 2014 3:59:17 PM PDT, Greg Zapp greg.zapp@gmail.com
wrote:

Hello,

Is anyone aware of a handler, or a technique in use, for indicating
that Chef has not successfully converged the node?

I'm considering writing a custom handler that will check an
"unfinished" flag and either kill chef with a custom exit code( :expressionless: ) or
write something to stdout that I can look for.

Cheers,
-Greg

--
Opscode, Inc.
Adam Jacob, Chief Dev Officer
T: (206) 619-7151 E: adam@opscode.com

--
Opscode, Inc.
Adam Jacob, Chief Dev Officer
T: (206) 619-7151 E: adam@opscode.com

here's some similar stuff i wrote for my own use. in this case i'm
searching for rails apps in order to setup nginx config. i just used
pure-ruby libraries and did a retry/sleep loop. mostly i'm just
worried about the delay between writing the node data and it showing up
in search, so i loop waiting for it to show up.

chef providers also support retries and retry_delay settings. if you
go that route with ruby_blocks to search though you will probably have
an interesting time with compile/converge mode problems later, using a
pure ruby library which does all its work in compile mode means you can
use that information to dynamically generate resources a bit more
straightforwards.

On Mon Jun 23 20:10:03 2014, Adam Jacob wrote:

Gotcha. You can do this on a resource-by-resource basis by setting
"ignore_failure true" on a resource. Probably the easiest thing would
be to encapsulate your setup in an LWRP, set ignore_failure on that
call, and move the group of resources inside the LWRP resource.

Adam

On Mon, Jun 23, 2014 at 8:02 PM, Greg Zapp <greg.zapp@gmail.com
mailto:greg.zapp@gmail.com> wrote:

I'll try to expand on it a bit more :)

I have a lot of websites that need to be installed or upgraded,
potentially.  They use a custom installer and this phase requires
the database having already been setup or upgraded.  These
database configurations are handled outside the web cluster.  The
site information comes from a rest API.  A custom service runs
Chef when a cluster change is reflect in the API. This service
also records the timestamp of the most recent resource from the
remote API when Chef has fully converged the node.  It will run
Chef again if the remote API indicates the cluster has changed.

This all works well however I'm looking to improve one aspect:
Sites whose databases are not ready currently end the run.  This
blocks other site's resources from being processed and is not very
efficient.  So, I want to skip those sites and indicate that the
node is "partially converged" to my service that runs Chef so that
it knows the node is not fully converged and can run it again
until it is.

The two most direct methods I can think of involve a custom report
handler that can tell if something was postponed/skipped/etc.  If
so it could:
A.) Exit Chef with a custom exit code
B.) Print something to stdout that will be parsed

I'm curious if anyone knows of such a handler, or has any
experience in implementing an N-run converge setup.

Cheers,
   -Greg


On Tue, Jun 24, 2014 at 12:55 PM, Adam Jacob <adam@opscode.com
<mailto:adam@opscode.com>> wrote:

    I don't understand what you're trying to accomplish. :) Can
    you give us more of a use case?


    On Mon, Jun 23, 2014 at 5:46 PM, Greg Zapp
    <greg.zapp@gmail.com <mailto:greg.zapp@gmail.com>> wrote:

        Hi Adam,

        Are you aware of any built-in way to indicate it has not
        completed without throwing an exception or otherwise
        stopping the run?

        Thanks,
           -Greg


        On Tue, Jun 24, 2014 at 12:41 PM, Adam Jacob
        <adam@opscode.com <mailto:adam@opscode.com>> wrote:

            A non zero exit code does exactly that in Chef. If it
            is completed, we return 0.

            On Jun 23, 2014 4:18 PM, "Greg Zapp"
            <greg.zapp@gmail.com <mailto:greg.zapp@gmail.com>> wrote:

                Non-zero exit codes do not necessarily, or do not
                have to, indicate an error.

                I'm trying to accomplish Chef finishing and
                indicating it has not fully converged the node.  I
                apologize if that wasn't clear in my original post.

                -Greg


                On Tue, Jun 24, 2014 at 11:08 AM, Noah Kantrowitz
                <noah@coderanger.net <mailto:noah@coderanger.net>>
                wrote:

                    It should exit with a non zero code if there
                    is an error, what are you trying to accomplish!


                    On June 23, 2014 3:59:17 PM PDT, Greg Zapp
                    <greg.zapp@gmail.com
                    <mailto:greg.zapp@gmail.com>> wrote:

                        Hello,

                        Is anyone aware of a handler, or a
                        technique in use, for indicating that Chef
                        has not successfully converged the node?

                        I'm considering writing a custom handler
                        that will check an "unfinished" flag and
                        either kill chef with a custom exit code(
                        :| ) or write something to stdout that I
                        can look for.


                        Cheers,
                           -Greg






    --
    Opscode, Inc.
    Adam Jacob, Chief Dev Officer
    T: (206) 619-7151 <tel:%28206%29%20619-7151> E:
    adam@opscode.com <mailto:adam@opscode.com>

--
Opscode, Inc.
Adam Jacob, Chief Dev Officer
T: (206) 619-7151 E: adam@opscode.com mailto:adam@opscode.com

Hi Guys,

Thanks for the responses.
@Lamont: Thanks for that, I'll have a look. After considering the gotchas
around search and the complexities around last-writer-wins I opted to fetch
my stuff down from our provisioning system. So my "sites" recipe fetches
down the list of sites for the the cluster right from our system via the
REST client. I just saw the retry stuff the other day(not sure why I never
noticed it?) and I I'm sure I'll find a place for it somewhere. In this
case though I just want to skip all the resources for a given "site" if
it's database isn't ready. When I upgrade all the sites they are more or
less down until the database AND the IIS sites have gone through their
upgrade process, so I'm going to completely remove hold ups related to
ordering(as well as having to even think about the ordering).

@Adam : I think that may do the trick for me :slight_smile: As long as the nested
resources exceptions get caught by the wrapping resource and can be logged?
It looks like it would (
https://github.com/opscode/chef/blob/master/lib/chef/resource.rb#L661). I
could actually go with a skip or a failure, but I also need to make sure I
can get a hold of the failure information in a report handler and find a
way to signal my Chef running service that a site was skipped during the
run. It looks like there is no resource attribute for failures and skips?
So I could create a custom handler that subscribes to either event and
then takes action in the report method?

-Greg

On Wed, Jun 25, 2014 at 10:37 AM, Lamont Granquist lamont@opscode.com
wrote:

here's some similar stuff i wrote for my own use. in this case i'm
searching for rails apps in order to setup nginx config. i just used
pure-ruby libraries and did a retry/sleep loop. mostly i'm just worried
about the delay between writing the node data and it showing up in search,
so i loop waiting for it to show up.

sk_services.md ยท GitHub

chef providers also support retries and retry_delay settings. if you go
that route with ruby_blocks to search though you will probably have an
interesting time with compile/converge mode problems later, using a pure
ruby library which does all its work in compile mode means you can use that
information to dynamically generate resources a bit more straightforwards.

On Mon Jun 23 20:10:03 2014, Adam Jacob wrote:

Gotcha. You can do this on a resource-by-resource basis by setting
"ignore_failure true" on a resource. Probably the easiest thing would
be to encapsulate your setup in an LWRP, set ignore_failure on that
call, and move the group of resources inside the LWRP resource.

Adam

On Mon, Jun 23, 2014 at 8:02 PM, Greg Zapp <greg.zapp@gmail.com
mailto:greg.zapp@gmail.com> wrote:

I'll try to expand on it a bit more :)

I have a lot of websites that need to be installed or upgraded,
potentially.  They use a custom installer and this phase requires
the database having already been setup or upgraded.  These
database configurations are handled outside the web cluster.  The
site information comes from a rest API.  A custom service runs
Chef when a cluster change is reflect in the API. This service
also records the timestamp of the most recent resource from the
remote API when Chef has fully converged the node.  It will run
Chef again if the remote API indicates the cluster has changed.

This all works well however I'm looking to improve one aspect:
Sites whose databases are not ready currently end the run.  This
blocks other site's resources from being processed and is not very
efficient.  So, I want to skip those sites and indicate that the
node is "partially converged" to my service that runs Chef so that
it knows the node is not fully converged and can run it again
until it is.

The two most direct methods I can think of involve a custom report
handler that can tell if something was postponed/skipped/etc.  If
so it could:
A.) Exit Chef with a custom exit code
B.) Print something to stdout that will be parsed

I'm curious if anyone knows of such a handler, or has any
experience in implementing an N-run converge setup.

Cheers,
   -Greg


On Tue, Jun 24, 2014 at 12:55 PM, Adam Jacob <adam@opscode.com
<mailto:adam@opscode.com>> wrote:

    I don't understand what you're trying to accomplish. :) Can
    you give us more of a use case?


    On Mon, Jun 23, 2014 at 5:46 PM, Greg Zapp
    <greg.zapp@gmail.com <mailto:greg.zapp@gmail.com>> wrote:

        Hi Adam,

        Are you aware of any built-in way to indicate it has not
        completed without throwing an exception or otherwise
        stopping the run?

        Thanks,
           -Greg


        On Tue, Jun 24, 2014 at 12:41 PM, Adam Jacob
        <adam@opscode.com <mailto:adam@opscode.com>> wrote:

            A non zero exit code does exactly that in Chef. If it
            is completed, we return 0.

            On Jun 23, 2014 4:18 PM, "Greg Zapp"
            <greg.zapp@gmail.com <mailto:greg.zapp@gmail.com>> wrote:

                Non-zero exit codes do not necessarily, or do not
                have to, indicate an error.

                I'm trying to accomplish Chef finishing and
                indicating it has not fully converged the node.  I
                apologize if that wasn't clear in my original post.

                -Greg


                On Tue, Jun 24, 2014 at 11:08 AM, Noah Kantrowitz
                <noah@coderanger.net <mailto:noah@coderanger.net>>

                wrote:

                    It should exit with a non zero code if there
                    is an error, what are you trying to accomplish!


                    On June 23, 2014 3:59:17 PM PDT, Greg Zapp
                    <greg.zapp@gmail.com
                    <mailto:greg.zapp@gmail.com>> wrote:

                        Hello,

                        Is anyone aware of a handler, or a
                        technique in use, for indicating that Chef
                        has not successfully converged the node?

                        I'm considering writing a custom handler
                        that will check an "unfinished" flag and
                        either kill chef with a custom exit code(
                        :| ) or write something to stdout that I
                        can look for.


                        Cheers,
                           -Greg






    --
    Opscode, Inc.
    Adam Jacob, Chief Dev Officer
    T: (206) 619-7151 <tel:%28206%29%20619-7151> E:
    adam@opscode.com <mailto:adam@opscode.com>

--
Opscode, Inc.
Adam Jacob, Chief Dev Officer
T: (206) 619-7151 E: adam@opscode.com mailto:adam@opscode.com