[lxc-devel] [PATCH 1/2] change lxc-autostart shutdown to behave like lxc-stop

Dwight Engen dwight.engen at oracle.com
Thu Jan 2 17:57:06 UTC 2014


On Thu, 2 Jan 2014 10:59:56 -0600
Serge Hallyn <serge.hallyn at ubuntu.com> wrote:

> Quoting Dwight Engen (dwight.engen at oracle.com):
> > It is desirable to have a mode where a soft shutdown is requested,
> > but then do a hard shutdown if after some time period the container
> > has not shut down. This the default behaviour of lxc-stop, but is
> > not currently possible with lxc-autostart. This change makes this
> > the default behaviour when shutdown is specified to lxc-autostart.
> > This will be very useful for init scripts.
> > 
> > An indefinte wait for soft shutdown (though I'm not sure how that
> > would be useful) is still possible by passing a timeout of 0.
> > 
> > Change default timeout value to 60 seconds to match lxc-stop
> > 
> > Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
> 
> Yeah since lxc-autostart batches by nature, having a default
> of failing instead of hard-killing makes less sense there
> than in lxc-shutdown.  The inconsistency is too bad, but
> maybe the thing to do is consider changing lxc-shutdown too.

Agree, I didn't like that this makes the meaning of shutdown
inconsistent in lxc-stop vs lxc-autostart. Maybe we should just rename
the option in lxc-stop to something like --no-hard-kill ?

> Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
> 
> > ---
> >  doc/lxc-autostart.sgml.in | 7 +++++--
> >  src/lxc/lxc_autostart.c   | 3 +--
> >  2 files changed, 6 insertions(+), 4 deletions(-)
> > 
> > diff --git a/doc/lxc-autostart.sgml.in b/doc/lxc-autostart.sgml.in
> > index 2f132ad..99ee7fa 100644
> > --- a/doc/lxc-autostart.sgml.in
> > +++ b/doc/lxc-autostart.sgml.in
> > @@ -103,8 +103,11 @@ Foundation, Inc., 51 Franklin Street, Fifth
> > Floor, Boston, MA 02110-1301 USA </term>
> >                  <listitem>
> >                      <para>
> > -                        Only request a clean shutdown, do not kill
> > the
> > -                        container tasks if the clean shutdown
> > fails.
> > +                        Request a clean shutdown. If a
> > +                        <optional>-t timeout</optional> greater
> > than 0 is
> > +                        given and the container has not shut down
> > within
> > +                        this period, it will be killed as with the
> > +                        <optional>-k kill</optional> option.
> >                      </para>
> >                  </listitem>
> >              </varlistentry>
> > diff --git a/src/lxc/lxc_autostart.c b/src/lxc/lxc_autostart.c
> > index 1407a41..62e101b 100644
> > --- a/src/lxc/lxc_autostart.c
> > +++ b/src/lxc/lxc_autostart.c
> > @@ -71,7 +71,7 @@ Options:\n\
> >  	.options  = my_longopts,
> >  	.parser   = my_parser,
> >  	.checker  = NULL,
> > -	.timeout = 30,
> > +	.timeout = 60,
> >  };
> >  
> >  int lists_contain_common_entry(struct lxc_list *p1, struct
> > lxc_list *p2) { @@ -273,7 +273,6 @@ int main(int argc, char *argv[])
> >  				if (my_args.list)
> >  					printf("%s\n", c->name);
> >  				else {
> > -					my_args.timeout = 0;
> >  					if (!c->shutdown(c,
> > my_args.timeout)) fprintf(stderr, "Error shutting down container:
> > %s\n", c->name); }
> > -- 
> > 1.8.3.1
> > 
> > _______________________________________________
> > lxc-devel mailing list
> > lxc-devel at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-devel
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel



More information about the lxc-devel mailing list