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

ssh package #1094

Merged
merged 1 commit into from
Aug 9, 2022
Merged

ssh package #1094

merged 1 commit into from
Aug 9, 2022

Conversation

cdoern
Copy link
Contributor

@cdoern cdoern commented Jul 19, 2022

initial implementation of the ssh package including:

  • nativeConnectionCreate() / golangConnectionCreate()
  • nativeConnectionDial() / golangConnectionDial()
  • nativeConnectionScp() / golangConnectionScp()

the way this works, is there are publicly accessible functions Create Dial and Scp. podman will have a new global flag --ssh that will allow users to choose native or golang based ssh functions. The functionality in containers/common (here) also checks if you have the necessary binaries installed

closes #1091

see https://github.com/cdoern/podman/tree/ssh for podman implementation

Signed-off-by: Charlie Doern cdoern@redhat.com

@cdoern
Copy link
Contributor Author

cdoern commented Jul 20, 2022

just realized I reintroduced pkg/errors. will remove that.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

I do not like inheriting the entities and infra structure from Podman.

I always had a hard time interpreting the meaning of the two names as they are very generic. We also have naming conflicts when importing them into the Podman code.

Do we need to separate the types and interfaces from the implementations? If so, I prefer to keep the types and interfaces in pkg/ssh and the implementations in pkg/ssh/{foo,bar,...}. It feels more idiomatic to me.

@rhatdan
Copy link
Member

rhatdan commented Jul 21, 2022

I agree, Do not use entities and infra

@cdoern
Copy link
Contributor Author

cdoern commented Jul 25, 2022

i'll try to change up the structure @vrothberg

the best I can seem to do is:

ssh/

  • /golang (containing that implementation)
  • /native (containing that implementation)
  • /types (containing a single file with structs)
  • /utils (utils.go lives here)
  • engine_container.go
  • runtime.go
  • ssh.go

otherwise we get cyclical imports and the interface does not work. I know this is bulky but this is a bulky addition to common and one that we do not want to have to re work over and over

@cdoern cdoern force-pushed the ssh branch 3 times, most recently from 0a492f5 to c36c2e9 Compare July 25, 2022 21:31
@cdoern cdoern force-pushed the ssh branch 4 times, most recently from a8bd3ae to 205142c Compare July 26, 2022 22:14
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Thanks, @cdoern. I like the package structure much more :)

I wished that more external types and APIs would have comments but it's probably not fair to ask you to do that given it's inherited from Podman.

Before merging, I suggest to open a PR in Podman and vendor this code here. That's a nice way to figure out which types and parts of the API Podman needs. At the moment, I think that we expose more than needed but I am not familiar with the ssh code at all.

go.mod Outdated Show resolved Hide resolved
pkg/config/default.go Outdated Show resolved Hide resolved
@cdoern cdoern force-pushed the ssh branch 7 times, most recently from aef9298 to 932b17f Compare July 27, 2022 18:52
@rhatdan
Copy link
Member

rhatdan commented Jul 27, 2022

@cdoern is this still a draft?

@cdoern cdoern marked this pull request as ready for review July 27, 2022 20:00
@cdoern
Copy link
Contributor Author

cdoern commented Jul 27, 2022

@cdoern is this still a draft?

not anymore :)

pkg/ssh/ssh.go Outdated Show resolved Hide resolved
pkg/ssh/ssh.go Outdated Show resolved Hide resolved
pkg/ssh/ssh.go Show resolved Hide resolved
pkg/ssh/ssh.go Outdated Show resolved Hide resolved
pkg/ssh/utils.go Outdated Show resolved Hide resolved
pkg/ssh/utils.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

I’m sorry, I probably won’t be able to review this carefully, at least this week.

I’ve only been looking at the knownhosts uses.


I continue to be a bit worried about the impact of the verification enforcement on users. To an extent I’m very fine with that impact, but I’d be happier if someone could actively check that the most important cases (is that podman machine? Some localhost use?) are not terribly user-unfriendly (e.g. that we don’t ourselves create a VM and then immediately faili accessing it, or something like that).

pkg/ssh/connection_golang.go Show resolved Hide resolved
pkg/ssh/utils.go Outdated Show resolved Hide resolved
pkg/ssh/utils.go Outdated Show resolved Hide resolved
pkg/ssh/utils.go Outdated Show resolved Hide resolved
@cdoern
Copy link
Contributor Author

cdoern commented Aug 4, 2022

@containers/podman-maintainers PTAL

@TomSweeneyRedHat
Copy link
Member

Just curious, are we aiming this for Podman v4.3 or 5.0?

@cdoern
Copy link
Contributor Author

cdoern commented Aug 4, 2022

Just curious, are we aiming this for Podman v4.3 or 5.0?

@TomSweeneyRedHat I was thinking 4.3 The overall impact on podman should be nothing, unless one wants to use --ssh=native. The changes to the golang ssh processing can be considered a bug fix

@vrothberg
Copy link
Member

I agree with @cdoern! Let's wait for a head nod from @mtrmac before merging.

@rhatdan
Copy link
Member

rhatdan commented Aug 7, 2022

This should definitely be in podman 4.3

initial implementation of the ssh package including:

- nativeConnectionCreate() / golangConnectionCreate()
- n/a / golangConnectionDial()
- nativeConnectionScp() / golangConnectionScp()
- nativeConnectionExec() / golangConnectionExeC()

the way this works, is there are publicly accessible functions Create, Exec, Dial and Scp. podman will have a new global flag --ssh` that will allow users to choose native or golang based ssh functions. The functionality in containers/common (here) also checks if you have the necessary binaries installed

closes containers#1091

Signed-off-by: Charlie Doern <cdoern@redhat.com>
@cdoern
Copy link
Contributor Author

cdoern commented Aug 8, 2022

@mtrmac @containers/podman-maintainers PTAL and merge

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 9, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cdoern, giuseppe, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

cfg.Engine.ActiveService = options.Name
}

if cfg.Engine.ServiceDestinations == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

@cdoern

AFAICS this code, and the code creating dst, is ~the same here and in connection_golang.go.

And the only parts of Podman that actually care about sshMode are scp (which I’m ignoring here), and connection.add.

So how does this work? How can the user set up a connection to use the native mode (and ideally to do it every time for that connection without having to set a flag)?

What am I missing about how this works?

Comment on lines +79 to +81
if options.Default {
cfg.Engine.ActiveService = options.Name
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This part does not exist in golangConnectionCreate. Isn’t that a bug?

(Really it seems to me that the level of abstraction of this function is incorrect — a lot of the code should not be duplicated between native/golang here, and should not be duplicated with Podman’s connection/add.)

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

Successfully merging this pull request may close these issues.

implement ssh package
7 participants