Skip to content

lxc.init fails to bootstrap container #23772

Closed

Description

@cheuschober

Happy to be proven wrong here, but from my best understanding, calls to lxc.init will always fail as long as it attempts to remove the seed marker prior to starting the container.

remove_seed_marker is set to True at:
https://github.com/saltstack/salt/blob/develop/salt/modules/lxc.py#L1197

The bit that looks like it could use some reordering is:
https://github.com/saltstack/salt/blob/develop/salt/modules/lxc.py#L1230-L1259

Steps to reproduce:

$ salt-call lxc.init testbuntu template=ubuntu options="{'release':'trusty', 'arch': 'amd64'}"

First failure is in attachable()

[ERROR   ] Command 'lxc-attach --clear-env -n testbuntu -- /usr/bin/env' failed with return code: 1

Versions report:

$ salt --versions-report
                  Salt: 2015.5.0
                Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
                Jinja2: 2.7.2
              M2Crypto: 0.21.1
        msgpack-python: 0.3.0
          msgpack-pure: Not Installed
              pycrypto: 2.6.1
               libnacl: Not Installed
                PyYAML: 3.10
                 ioflo: Not Installed
                 PyZMQ: 14.0.1
                  RAET: Not Installed
                   ZMQ: 4.0.4
                  Mako: 0.9.1
 Debian source package: 2015.5.0+ds-1trusty1

Activity

  1. kiorky commented on May 15, 2015

    @kiorky
    Contributor

    You are totally wrong:

    • if the container exists and is attached, it wont it that code.
    • if it does not exists, when cloning, it removes the seed marker that could have been present in the container, coming from a template which would have not been cleaned out from those static markers.
    • If if comes from an lxc template, it also check
    • Indeed, rm -f run inconditonnaly, without falling whenever ever.
    • If the container is not started, there is a fallback to exec via chroot, which is used upon first creation.
    • If you dont want to seed automaticly your lxc containers as minion, use seed=False.
  2. kiorky commented on May 15, 2015

    @kiorky
    Contributor

    (The seeding is meant to be used from the lxc runner) ...

  3. cheuschober commented on May 15, 2015

    @cheuschober
    ContributorAuthor

    @kiorky, Ok. I get that -- what about the steps to reproduce? If the error is misidentified, that makes sense -- still can't init a container.

  4. kiorky commented on May 15, 2015

    @kiorky
    Contributor

    I think you may also have been misleaded from false positive debug output.

    For exemple, the one you are giving is coming from here :
    https://github.com/saltstack/salt/blob/develop/salt/modules/lxc.py#L2853

    This tests if the container is attacheable yet but is not a failure, even if it outputs something to your logs.

  5. cheuschober commented on May 15, 2015

    @cheuschober
    ContributorAuthor

    @kiorky Still failed...

    lxc.sls

    lxc.container_profile:
      ubuntu:
        template: ubuntu
        options:
          release: trusty
          arch: amd64
    
  6. cheuschober commented on May 15, 2015

    @cheuschober
    ContributorAuthor

    Minnion error log as below:

    2015-05-15 17:57:59,315 [salt.loaded.int.module.cmdmod][ERROR   ][28404] Command 'lxc-attach --clear-env -n testbuntu-01 -- /usr/bin/env' failed with return code: 1
    2015-05-15 17:57:59,316 [salt.loaded.int.module.cmdmod][ERROR   ][28404] output: lxc-attach: attach.c: lxc_attach: 635 failed to get the init pid
    2015-05-15 17:58:00,148 [salt.loaded.int.module.cmdmod][ERROR   ][28404] Command 'lxc-attach --clear-env  --set-var PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin -n testbuntu-01 -- command -v salt-minion' failed with return code: 255
    2015-05-15 17:58:00,149 [salt.loaded.int.module.cmdmod][ERROR   ][28404] stderr: lxc_container: attach.c: lxc_attach_run_command: 1094 No such file or directory - failed to exec 'command'
    2015-05-15 17:58:00,149 [salt.loaded.int.module.cmdmod][ERROR   ][28404] retcode: 255
    2015-05-15 17:58:00,170 [salt.loaded.int.module.cmdmod][ERROR   ][28404] Command "lxc-attach --clear-env  --set-var PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin -n testbuntu-01 -- test -e '/lxc.initial_seed'" failed with return code: 1
    2015-05-15 17:58:00,170 [salt.loaded.int.module.cmdmod][ERROR   ][28404] retcode: 1
    
  7. cheuschober commented on May 15, 2015

    @cheuschober
    ContributorAuthor

    @kiorky If the attachable() issue is easily ignored, then should I assume the command -v call is really the problem here?

    I did a manual attach and ran that command and it executed flawlessly but it won't run as above.

  8. changed the title [-]lxc.init fails: lxc module attempts to run commands before starting container[/-] [+]lxc.init fails to bootstrap image[/+] on May 15, 2015
  9. changed the title [-]lxc.init fails to bootstrap image[/-] [+]lxc.init fails to bootstrap container[/+] on May 15, 2015
  10. kiorky commented on May 15, 2015

    @kiorky
    Contributor

    just paste somewhere a full execution log if you are not able to interpret it.

    I doubt there is a bug, i use it daily (salt/develop branch) but we also made sure with @terminalmage to have something stabilized in stable/2015.*.

  11. kiorky commented on May 15, 2015

    @kiorky
    Contributor

    run with -lall (loglevel: all)

  12. kiorky commented on May 15, 2015

    @kiorky
    Contributor

    i personally call the exec mod lxc.init from the runner lxc.cloud_init function.
    let me check (that's no how i use it personally, i have another internal interface to setup settings, that i feed the function with).

  13. kiorky commented on May 15, 2015

    @kiorky
    Contributor

    removed comment: useless

  14. 99 remaining items

  15. cheuschober commented on May 31, 2015

    @cheuschober
    ContributorAuthor

    @kiorky I do but let me do just a little more testing to confirm it's not me -- the issue I had was partly with bootstrap. I had minions pre-seeded in my lxc templates and the bootstrap script wasn't taking the "-C" argument to just set master and other configuration options. I hadn't formally reported it if only because this could be an edge-case with the bootstrap script's autodetection or with the lxc runner's seeding options and I wanted to be sure.

  16. kiorky commented on Jun 1, 2015

    @kiorky
    Contributor

    @cheuschober did you saw #24126 , that may be of interrest.

  17. added
    RIoT
    and removed
    RIoT
    on Jun 9, 2015
  18. cheuschober commented on Jun 27, 2015

    @cheuschober
    ContributorAuthor

    @kiorky Apologies for taking so long to get back to this but I finally found some time to start debugging and will be doing so all weekend. The first bug I encountered was using lxc init with a default bridge on lxc v1.0.7

    In this case the config does not have lxc.network.ipv4 and it is illegal to have lxc.network.ipv4.gateway when lxc.network.ipv4 is not set (container will not start).

    A (potential) suggested fix is:

    843c843,844
    <         True not in ['ipv4.gateway' in a for a in ret]
    ---
    >         True not in ['ipv4.gateway' in a for a in ret] and
    >         True in ['ipv4' in a for a in ret]
  19. cheuschober commented on Jun 30, 2015

    @cheuschober
    ContributorAuthor

    I think that's the last major bug I encountered on the 2015.5.X branch.

  20. jpic commented on Aug 5, 2015

    @jpic
    Contributor

    That patch does indeed let salt-cloud start lxc instances, but then it fails as such:

    [ERROR   ] Command 'lxc-attach --clear-env  --set-var PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin -n test26 -- if [ -f "/sbin/67cee62104466d2448ab8543428ec4c0_dns.sh" ];then rm -f "/sbin/67cee62104466d2448ab8543428ec4c0_dns.sh";fi' failed with return code: 1
    [ERROR   ] stderr: /bin/bash: -c: line 0: syntax error near unexpected token `then'
    /bin/bash: -c: line 0: `lxc-attach --clear-env  --set-var PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin -n test26 -- if [ -f "/sbin/67cee62104466d2448ab8543428ec4c0_dns.sh" ];then rm -f "/sbin/67cee62104466d2448ab8543428ec4c0_dns.sh";fi'
    

    Apparently the "then" statement is outside the command because of ;....

  21. added
    Platform
    and removed
    RIoT
    on Aug 14, 2015
  22. aleufroy commented on May 11, 2016

    @aleufroy
    Contributor

    Hi,

    I'm not really sure it's related but I have troubles with lxc-cloud also:

    /etc/salt/cloud.providers.d/localhost.provider.conf:

    localhost-lxc:
      target: padian
      driver: lxc

    /srv/salt/containers.sls:

    nginx_container:
      cloud.present:
        - cloud_provider: localhost-lxc
        - template: archlinux
        - running: true
        - type: veth
        - flags: up
        - link: lxcbr0
        - gateway: 10.0.3.1
        - ip: 10.0.3.2
        - master: 10.0.3.1

    Then I performed a salt padian state.apply containers which results in a "Invalid return for nginx_container: ERROR: nginx_container is not attachable. {'padian': {'ret': 'ERROR: nginx_container is not attachable.', 'out': 'nested'}}".

    Looking in the log of the minion I found an python traceback ending with:

    File "/usr/lib/python2.7/site-packages/salt/modules/lxc.py", line 3678, in _run
      '{0} is not attachable.'.format(name)
    

    After some code inspection, I found that the minion fails to execute the following command (return code -11):

    $ lxc-attach --clear-env --set-var PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin  -n nginx_container -- df /

    This command succeed when I Iaunch it manually, returning:

    Filesystem               1K-blocks     Used Available Use% Mounted on
    /dev/mapper/storage-root 482316904 29053184 428740356   7% /
    

    But It fails when I try:

    $ salt padian cmd.run 'lxc-attach --clear-env --set-var PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin  -n nginx_container -- df /'
    padian:

    I've to specify use_vt=true:

    salt padian cmd.run 'lxc-attach --clear-env --set-var PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin  -n nginx_container -- df /' use_vt=true
    padian:
        Filesystem                      1K-blocks     Used Available Use% Mounted on
        /var/lib/lxc/jessie-base/rootfs 482316904 29611404 428182136   7% /
  23. stale commented on May 6, 2018

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

    If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Platformbugseverity-mediumstale

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions