[lxc-devel] [lxc/lxc] 3a9e94: start: don't log stop/continue for non-init proces...

GitHub noreply at github.com
Fri Jan 19 04:26:33 UTC 2018


  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: 3a9e949f6d4cad085d645b2efbc126cdbc48773a
      https://github.com/lxc/lxc/commit/3a9e949f6d4cad085d645b2efbc126cdbc48773a
  Author: Tycho Andersen <tycho at tycho.ws>
  Date:   2018-01-19 (Fri, 19 Jan 2018)

  Changed paths:
    M src/lxc/start.c

  Log Message:
  -----------
  start: don't log stop/continue for non-init processes

This non-init forwarding check should really be before all the log messages
about "init continued" or "init stopped", since they will otherwise lie
about some process that wasn't init being stopped or continued.

Signed-off-by: Tycho Andersen <tycho at tycho.ws>


  Commit: 19cfa02c4c7bd29cdf10462878d06d025fcc3d27
      https://github.com/lxc/lxc/commit/19cfa02c4c7bd29cdf10462878d06d025fcc3d27
  Author: Tycho Andersen <tycho at tycho.ws>
  Date:   2018-01-19 (Fri, 19 Jan 2018)

  Changed paths:
    M src/lxc/error.c

  Log Message:
  -----------
  fix lxc_error_set_and_log to match the docs

The documentation for this function says if the task was killed by a
signal, the return code will be 128+n, where n is the signal number. Let's
make that actually true.

(We'll use this behavior in later patches.)

Signed-off-by: Tycho Andersen <tycho at tycho.ws>


  Commit: 4f4530faa742e39fb0e0cd3d08de07f36e2b0fc8
      https://github.com/lxc/lxc/commit/4f4530faa742e39fb0e0cd3d08de07f36e2b0fc8
  Author: Tycho Andersen <tycho at tycho.ws>
  Date:   2018-01-19 (Fri, 19 Jan 2018)

  Changed paths:
    M src/lxc/lxc_init.c

  Log Message:
  -----------
  lxc.init: correctly exit with the app's error code

Based on the comments in the code (and the have_status flag), the intent
here (and IMO, the desired behavior) should be for init.lxc to propagate
the actual exit code from the real application process up through.
Otherwise, it is swallowed and nobody can access it.

The bug being fixed here is that ret held the correct exit code, but when
it went around the loop again (to wait for other children) ret is
clobbered. Let's save the desired exit status somewhere else, so it can't
get clobbered, and we propagate things correctly.

Signed-off-by: Tycho Andersen <tycho at tycho.ws>


  Commit: cd5177e9e36b36869c99ee8b850b9853a344b179
      https://github.com/lxc/lxc/commit/cd5177e9e36b36869c99ee8b850b9853a344b179
  Author: Tycho Andersen <tycho at tycho.ws>
  Date:   2018-01-19 (Fri, 19 Jan 2018)

  Changed paths:
    M src/lxc/lxccontainer.c
    M src/lxc/start.c
    M src/lxc/start.h

  Log Message:
  -----------
  remember the exit code from the init process

error_num seems to be trying to remember the exit code of the init process,
except that nothing actually keeps track of it anywhere. So, let's add a
field to the handler, so that we can keep track of the process' exit
status, and the propagate it to error_num in struct lxc_container so that
people can use it.

Note that this is a slight behavior change, essentially instead of making
error_num always == the return code from start, now it contains slightly
more useful information (the actual exit status). But, there is only one
internal user of error_num which I'll fix in later in the series, so IMO
this is ok.

Signed-off-by: Tycho Andersen <tycho at tycho.ws>


  Commit: eb8085399ce511e976678a0012fbf0e5319efe32
      https://github.com/lxc/lxc/commit/eb8085399ce511e976678a0012fbf0e5319efe32
  Author: Tycho Andersen <tycho at tycho.ws>
  Date:   2018-01-19 (Fri, 19 Jan 2018)

  Changed paths:
    M src/lxc/start.c

  Log Message:
  -----------
  start: don't return false when the container's init exits nonzero

This seems slightly counter-intuitive, but IMO it's what we want.
Basically, ->start() should succeed if the container is spawned correctly
(similar to how golang's exec.Cmd.Start() returns nil if the thing spawns
correctly), and users can check error_num (i.e. golang's exec.Cmd.Wait())
to see how it exited.

This preserves previous behavior, which basically was that start was always
successful if the thing actually launched. Since we never kept track of
exit codes, this would always succeed too. Now that we do, it doesn't, and
this change is required.

Signed-off-by: Tycho Andersen <tycho at tycho.ws>


  Commit: f9eff9505328c1ec5ef05f07c0e27c0c51cf8361
      https://github.com/lxc/lxc/commit/f9eff9505328c1ec5ef05f07c0e27c0c51cf8361
  Author: Tycho Andersen <tycho at tycho.ws>
  Date:   2018-01-19 (Fri, 19 Jan 2018)

  Changed paths:
    M src/lxc/tools/lxc_execute.c

  Log Message:
  -----------
  lxc-execute: actually exit with the status of the spawned task

Now that we have things propagated through init and liblxc correctly, at
least in non-daemon mode, we can exit with the actual exit status of the
task, instead of always succeeding, which is not so helpful.

Signed-off-by: Tycho Andersen <tycho at tycho.ws>


  Commit: 55e1311e4b8b113f1b99d6667414c58dd910aee0
      https://github.com/lxc/lxc/commit/55e1311e4b8b113f1b99d6667414c58dd910aee0
  Author: Tycho Andersen <tycho at tycho.ws>
  Date:   2018-01-19 (Fri, 19 Jan 2018)

  Changed paths:
    M src/lxc/start.c

  Log Message:
  -----------
  set exit status to 1 in the unknown si_code case

Signed-off-by: Tycho Andersen <tycho at tycho.ws>


  Commit: 2c3a005d733fcfdc7473afb48c49a25712211981
      https://github.com/lxc/lxc/commit/2c3a005d733fcfdc7473afb48c49a25712211981
  Author: Serge Hallyn <serge at hallyn.com>
  Date:   2018-01-18 (Thu, 18 Jan 2018)

  Changed paths:
    M src/lxc/error.c
    M src/lxc/lxc_init.c
    M src/lxc/lxccontainer.c
    M src/lxc/start.c
    M src/lxc/start.h
    M src/lxc/tools/lxc_execute.c

  Log Message:
  -----------
  Merge pull request #2094 from tych0/propagate-exit-code

Propagate exit code for app containers


Compare: https://github.com/lxc/lxc/compare/dc4f8fb11aa9...2c3a005d733f


More information about the lxc-devel mailing list