[lxc-users] Container startup hook arguments
Serge E. Hallyn
serge at hallyn.com
Thu Oct 5 06:03:54 UTC 2017
On Wed, Oct 04, 2017 at 05:02:27PM +0200, Kees Bos wrote:
> On wo, 2017-10-04 at 09:35 -0500, Serge E. Hallyn wrote:
> > Quoting Kees Bos (cornelis.bos at gmail.com):
> > >
> > > I'm not using it, but do expect the extra args:
> > >
> > > while [ {{ '${#@}' }} -gt 3 ] ; do
> > > ...
> > > shift
> > > done
> > >
> > > It might be that some users will need the last extra argument
> > > (stage:
> > > pre-start|start|post-stop). This is currently not available in the
> > > environment.
> > >
> > > I can live without these extra arguments, but will have to update
> > > my
> > > scripts.
> > Ok, but this will hurt then. I certainly was going to keep the
> > extra args, but they would be shifted now. We can pass along an
> > environment variable saying something like LXC_SIMPLE_ARGS=1 or
> > something, but your unmodified script won't know to look for
> > that so will do the wrong thing. Any ideas?
> >
> > This unfortunately basically means that you are in fact a "user",
> > and that makes this seem like at best 3.0 material then, unless
> > we can find a good solution.
> >
> > Maybe a configuration key 'lxc.hooks.version=2' ?
>
> Yep. Or 'lxc.hook.version=2'. However, that would mean you've got to
> support is for quite some time. I don't know if that's worth the
> effort. It would also mean that you've got to update (lots?) of
> container configs. I'm not sure what would be the most painful way to
> go.
It might be a long time before we can be sure noone gets hit by this,
so supporting it a long time is fine.
Or, I suppose since renaming our config keys is all the rage we could
also just use 'lxc.hook2.*' as an indicator.
> It would be nice if you define e.g. LXC_HOOK_STAGE=pre-start in the
> environment (which is currently not available). Then it's possible to
Oh, ouch. I was thinking we had all the information in env, including
the section.
Indeed adding that will have to happen before we do this switch.
> use a single script to handle multiple stages (which I don't do, but is
> currently possible based on the last argument).
>
> This new environment variable can also be used to prepare scripts for
> changing behaviour. Without that, my scripts can be prepared for this
> with e.g.:
> for lastarg; do true; done
> if $lastarg = 'pre-start' ; then old-style ; etc; fi
-serge
More information about the lxc-users
mailing list