salt icon indicating copy to clipboard operation
salt copied to clipboard

salt-cloud lxc driver does not respect --no-deploy options

Open samodid opened this issue 9 years ago • 6 comments

Description of Issue/Question

salt-cloud lxc driver does not respect --no-deploy options, it must skip host bootstrap step.

Setup

# cat /etc/salt/cloud.providers.d/lxc.conf 

lab-deb9-cloud01:
  target: lab-deb9-cloud01
  driver: lxc

lab-deb9-cloud02:
  target: lab-deb9-cloud02
  driver: lxc

# salt lab-deb9-cloud01 config.get lxc.container_profile
lab-deb9-cloud01:
    ----------
    centos7:
        ----------
        options:
            ----------
            arch:
                amd64
            dist:
                centos
            release:
                7
        template:
            download
    ubuntu-xenial:
        ----------
        options:
            ----------
            arch:
                amd64
            dist:
                ubuntu
            release:
                xenial
        template:
            download

# salt lab-deb9-cloud01 config.get lxc.network_profile
lab-deb9-cloud01:
    ----------
    centos7:
        ----------
        eth0:
            ----------
            flags:
                up
            link:
                br0
            type:
                veth

Steps to Reproduce Issue

# salt-cloud --no-deploy -p lab-deb9-cloud01-centos7 test1
test1:
    ----------
    Error:
        Error while creating test1,
    changes:
        ----------
    comment:
    name:
        test1
    result:
        False
    runner_return:
        ----------
        comment:
        done:
        errors:
            ----------
            lab-deb9-cloud01:
                ----------
                test1:
                    |_
                      ----------
                      changes:
                          ----------
                          init:
                              |_
                                ----------
                                create:
                                    Container created
                              |_
                                ----------
                                config:
                                    Container configuration updated
                              |_
                                ----------
                                password:
                                    Password(s) updated
                              |_
                                ----------
                                dns:
                                    DNS updated
                              |_
                                ----------
                                state:
                                    ----------
                                    new:
                                        running
                                    old:
                                        None
                      comment:
                          Bootstrap failed, see minion log for more information
                      name:
                          test1
                      result:
                          False
        lab-deb9-cloud01:
        ping_status:
            False
        result:
            False

Versions Report

# salt-cloud --versions-report                                          
Salt Version:
            Salt: 2017.7.2
 
Dependency Versions:
 Apache Libcloud: 1.5.0
            cffi: Not Installed
        cherrypy: Not Installed
        dateutil: 2.5.3
       docker-py: Not Installed
           gitdb: 2.0.0
       gitpython: 2.1.1
           ioflo: Not Installed
          Jinja2: 2.9.4
         libgit2: Not Installed
         libnacl: Not Installed
        M2Crypto: Not Installed
            Mako: Not Installed
    msgpack-pure: Not Installed
  msgpack-python: 0.4.8
    mysql-python: Not Installed
       pycparser: Not Installed
        pycrypto: 2.6.1
    pycryptodome: Not Installed
          pygit2: Not Installed
          Python: 2.7.13 (default, Jan 19 2017, 14:48:08)
    python-gnupg: Not Installed
          PyYAML: 3.12
           PyZMQ: 16.0.2
            RAET: Not Installed
           smmap: 2.0.1
         timelib: Not Installed
         Tornado: 4.4.3
             ZMQ: 4.2.1
 
System Versions:
            dist: debian 9.1 
          locale: UTF-8
         machine: x86_64
         release: 4.9.0-4-amd64
          system: Linux
         version: debian 9.1 
 

samodid avatar Nov 22 '17 19:11 samodid

Hmmm can you add these log.error's and paste sanitized output here:

diff --git a/salt/cloud/__init__.py b/salt/cloud/__init__.py
index 73327724ef..8901afcaef 100644
--- a/salt/cloud/__init__.py
+++ b/salt/cloud/__init__.py
@@ -1191,6 +1191,7 @@ class Cloud(object):
             return
 
         deploy = salt.config.get_cloud_config_value('deploy', vm_, self.opts)
+        log.error('deploy is: {0}'.format(deploy))
         make_master = salt.config.get_cloud_config_value(
             'make_master',
             vm_,
@@ -1198,6 +1199,7 @@ class Cloud(object):
         )
 
         if deploy:
+            log.error('we are going to install salt')
             if not make_master and 'master' not in minion_dict:
                 log.warning(
                     'There\'s no master defined on the \'{0}\' VM settings.'.format(

also maybe @saltstack/team-cloud has more insight here as well.

Ch3LL avatar Nov 22 '17 22:11 Ch3LL

# salt-cloud -l error --no-deploy -p lab-deb9-cloud01-centos7 test1
[ERROR   ] deploy is: False
test1:
    ----------
    Error:
        Error while creating test1,
    changes:
        ----------
    comment:
    name:
        test1
    result:
        False
    runner_return:
        ----------
        comment:
        done:
        errors:
            ----------
            lab-deb9-cloud01:
                ----------
                test1:
                    |_
                      ----------
                      changes:
                          ----------
                          init:
                              |_
                                ----------
                                create:
                                    Container created
                              |_
                                ----------
                                config:
                                    Container configuration updated
                              |_
                                ----------
                                password:
                                    Password(s) updated
                              |_
                                ----------
                                dns:
                                    DNS updated
                              |_
                                ----------
                                state:
                                    ----------
                                    new:
                                        running
                                    old:
                                        None
                      comment:
                          Bootstrap failed, see minion log for more information
                      name:
                          test1
                      result:
                          False
        lab-deb9-cloud01:
        ping_status:
            False
        result:
            False

samodid avatar Nov 23 '17 05:11 samodid

As lxc driver uses lxc runner and modules.

https://github.com/saltstack/salt/blob/2017.7.2/salt/cloud/clouds/lxc.py#L471

https://github.com/saltstack/salt/blob/2017.7.2/salt/runners/lxc.py#L428

And lxc.init combine container deployment and bootstrap process

I think to fix that we need to define seed from deploy variable.

https://github.com/saltstack/salt/blob/2017.7.2/salt/modules/lxc.py#L1236 https://github.com/saltstack/salt/blob/2017.7.2/salt/modules/lxc.py#L1579

samodid avatar Nov 23 '17 06:11 samodid

I spent some time on lxc driver code. And looks like it works own way. #31294 is good example of another issue caused by such behavior.

I propose to separate container creation and bootstrap to different function.

samodid avatar Nov 23 '17 08:11 samodid

I would not be opposed to stripping out all the lxc specific stuff, and just using the bootstrap function directly on it.

That is the way it used to be, but when we moved everything over to a unified bootstrap script, I don't think that the lxc was included.

But I don't see a problem with moving all the lxc stuff into salt.utils and using it in salt.modules.lxc and salt.cloud.clouds.lxc.

gtmanfred avatar Nov 27 '17 16:11 gtmanfred

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.

stale[bot] avatar Mar 22 '19 17:03 stale[bot]