Skip to content

Run cmds in write_files test as sudo#676

Closed
lucasmoura wants to merge 1 commit into
canonical:masterfrom
lucasmoura:update_write_files_integration_tests
Closed

Run cmds in write_files test as sudo#676
lucasmoura wants to merge 1 commit into
canonical:masterfrom
lucasmoura:update_write_files_integration_tests

Conversation

@lucasmoura
Copy link
Copy Markdown
Contributor

We are updating how pycloudlib run the exec cmds. By default, LXD is running all of the commands as root. We are changing that behavior. However, this will impact the test_write_files test, which is being updated in this PR.

@smoser
Copy link
Copy Markdown
Collaborator

smoser commented Nov 18, 2020

imo the test harness 'exec' should be done as root.
That is the most sane default. if the caller wants to change to non-root, they can do so using sudo.

but i'm not sure what the motivation for "We are changing that behavior" is.

@OddBloke
Copy link
Copy Markdown
Collaborator

imo the test harness 'exec' should be done as root.

In non-LXD cases (where we SSH into instances as non-root), that would mean that running commands as non-root would be going through sudo twice: once to do the exec as root, and once to get back to the default user. It would also mean that tests have to know what the default username is (e.g. ubuntu vs. ec2-user) for the currently running instance; currently that can be contained in the framework code which handles the SSH connection (or lxc exec call).

That is the most sane default. if the caller wants to change to non-root, they can do so using sudo.

James has proposed #664 for framework changes around this: we use sudo to gain root, and that's the default behaviour when you call execute() (so the 'exec' is done as root, in that sense). execute() has a use_sudo parameter which allows you to not use sudo (and therefore run as the default SSH user without knowing its username).

(Writing this out, I realise there's a gap here if root is the default SSH user: https://github.com/canonical/cloud-init/pull/664/files#r526453646)

@smoser
Copy link
Copy Markdown
Collaborator

smoser commented Nov 19, 2020

I moved this conversation to #664

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.

3 participants