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 issue with ssh flags used with scp. #505

Closed

Conversation

jraygauthier
Copy link
Member

As the '-p' flag attempt to preserve file attributes
with scp, it was making the scp command fail in
contexts where preserving attributes is not possible
(this is without mentionning the '22' argument that
followed and which seems to be accepted silently).

Here's the error it fixes:

afrontend> uploading key ‘my_secret.key’...
afrontend> scp: /run/keys/my_secret.key: No such file or directory
afrontend> error: command ‘['scp', '-P', '22', '-i', '/run/user/1000/nixops-tmp4MXxgW/id_nixops-afrontend', '-p', '22', '-oControlPath=/run/user/1000/nixops-ssh-tmpakFvsQ/master-socket', '/run/user/1000/nixops-tmp4MXxgW/key-afrontend', u'root@10.233.1.2:/run/my_secret.key']’ failed on machine ‘afrontend’ (exit code 1)
error: activation of 1 of 1 machines failed (namely on ‘afrontend’)

See the ['-P', '22'] part followed not long after by wrong ['-p', '22'].

Note that this is a prerequisite for #300

@domenkozar
Copy link
Member

This doesn't call get_ssh_flags anymore, which is needed sometimes to pass the private ssh key

As the '-p' flag attempt to preserve file attributes
with scp, it was making the scp command fail in
contexts where preserving attributes is not possible
(this is without mentionning the '22' argument that
followed and which seems to be accepted silently).
@jraygauthier
Copy link
Member Author

Good point. It seems that default options were working fine for the localhost case. Bringing back
get_ssh_flags uncovered supplementary arguments propagation errors in the container backend.
This one should do the trick.

@@ -63,9 +63,9 @@ def get_ssh_flags(self, *args, **kwargs):
flags = super(ContainerState, self).get_ssh_flags(*args, **kwargs)
flags += ["-i", self.get_ssh_private_key_file()]
if self.host == "localhost":
flags.extend(MachineState.get_ssh_flags(self))
flags.extend(MachineState.get_ssh_flags(self, *args, **kwargs))
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

so that MachineState.get_ssh_flags gets its expected scp flag as specified by the caller. Otherwise it will default to False.

I honestly find these var args parameters confusing, I'm not sure why there was a need for it in the first place but I tried to make do with it.

@domenkozar
Copy link
Member

@jraygauthier could you rebase? I think we can merge this.

@jraygauthier
Copy link
Member Author

@domenkozar This PR is no longer relevant now that #804 fixes the problem.

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