Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new container initialization in LXC runner #23311

Merged
merged 1 commit into from
May 4, 2015

Conversation

cellscape
Copy link
Contributor

When creating new LXC container with help of salt-cloud lxc.init crashes
with similar message:

[INFO    ] Creating container(s) '['test-host']' on host 'lxc-host'
[ERROR   ] Failed to create VM test-host. Configuration value 'test-host' needs to be set
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1193, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/lxc.py", line 424, in create
    cret = _runner().cmd('lxc.cloud_init', [vm_['name']], kwarg=kwarg)
  File "/usr/lib/python2.7/dist-packages/salt/runner.py", line 123, in cmd
    return self.functions[fun](*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/runners/lxc.py", line 355, in cloud_init
    saltcloud_mode=True, quiet=quiet, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/runners/lxc.py", line 257, in init
    kw['seed'] = seeds[name]
KeyError: 'test-host'

The reason is that salt-cloud always passes generated keys to lxc.init,
it skips seeds dictionary population and errors out trying to lookup
non-existent key.

Fix this by using fallback value of True because we always want to seed
minion in such case.

When creating new LXC container with help of salt-cloud lxc.init crashes
with similar message:

[INFO    ] Creating container(s) '['test-host']' on host 'lxc-host'
[ERROR   ] Failed to create VM test-host. Configuration value 'test-host' needs to be set
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1193, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/lxc.py", line 424, in create
    cret = _runner().cmd('lxc.cloud_init', [vm_['name']], kwarg=kwarg)
  File "/usr/lib/python2.7/dist-packages/salt/runner.py", line 123, in cmd
    return self.functions[fun](*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/runners/lxc.py", line 355, in cloud_init
    saltcloud_mode=True, quiet=quiet, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/runners/lxc.py", line 257, in init
    kw['seed'] = seeds[name]
KeyError: 'test-host'

The reason is that salt-cloud always passes generated keys to lxc.init,
it skips seeds dictionary population and errors out trying to lookup
non-existent key.

Fix this by using fallback value of True because we always want to seed
minion in such case.
jfindlay added a commit that referenced this pull request May 4, 2015
Fix new container initialization in LXC runner
@jfindlay jfindlay merged commit ea20176 into saltstack:2014.7 May 4, 2015
@kiorky
Copy link
Contributor

kiorky commented May 4, 2015

@jfindlay this is not the right fix i think. (should maybe be reverted)

@kiorky
Copy link
Contributor

kiorky commented May 4, 2015

cc @terminalmage

@kiorky
Copy link
Contributor

kiorky commented May 4, 2015

@cellscape what the full VM cloud profile options ? (minus the psswd)

@@ -251,7 +251,7 @@ def init(names, host=None, saltcloud_mode=False, quiet=False, **kwargs):
expr_form='list', timeout=600).get(host, {})
name = kw.pop('name', name)
# be sure not to seed an alrady seeded host
kw['seed'] = seeds[name]
kw['seed'] = seeds.get(name, True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/True/seed/
And the commit will be valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, missed that. kwargs.get('seed', True) then. I'll prepare new pull request.

@cellscape
Copy link
Contributor Author

@kiorky

wheezy:
   provider: jessie-salt-master
   image: debian
   release: wheezy
   bridge: br0
   autostart: True
   start: True
   gateway:

@jfindlay
Copy link
Contributor

jfindlay commented May 4, 2015

@kiorky, thanks for checking this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants