Skip to content

LXD connections are attempted via SSH iff a non-default key_pair is specified #112

@OddBloke

Description

@OddBloke

Due to this code:

def _run_command(self, command, stdin):
"""Run command in the instance."""
if self.key_pair:
return super()._run_command(command, stdin)
base_cmd = [
'lxc', 'exec', self.name, '--', 'sudo', '-u', self.username, '--'
]
return subp(base_cmd + list(command), rcs=None)

This also interacts badly with LXD's SSH key defaults. For most clouds, the key_pair used by default is

self.key_pair = KeyPair(
'/home/%s/.ssh/id_rsa.pub' % _username, name=_username
)
LXD, however, has a different default:
# User must manually specify the key pair to be used
self.key_pair = None
This means that in the default case, LXD will exec. In itself, this is not a problem.

However, it also means that if a consumer chooses to specify a non-default key (via .use_key), LXD's behaviour changes. self.key_pair is no longer None, and so LXD will start using SSH to access instances.

This is biting us in the cloud-init integration testing: we have a configuration option to specify an SSH key (and we call use_key if provided). If it isn't set, then we want to use pycloudlib's default (i.e. we don't call use_key at all). This means that users who do specify the configuration option see test failures on LXD: we rely on the fact that LXD does not require functioning networking to access the instance for some tests, and so using SSH (as pycloudlib does for such users) is guaranteed to fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions