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

Juju 7464/reuse dial logic #1529

Merged
merged 5 commits into from
Jan 21, 2025

Conversation

SimoneDutto
Copy link
Contributor

Description

In this PR we reuse some logic from the rpc dial pkg to get addresses from Controller.

First commit is just extracting the GetAddressesAndTLSConfig from the Dial method and add some tests for it.

I have decided to use a single SSHManager interface, because we don't even need two different interfaces for it. it's overengineering for 2 methods.

Engineering checklist

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

Test instructions

@SimoneDutto SimoneDutto requested a review from a team as a code owner January 20, 2025 14:54
Copy link
Contributor

@kian99 kian99 left a comment

Choose a reason for hiding this comment

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

lgtm with 2 comments

internal/ssh/utils.go Outdated Show resolved Hide resolved
internal/ssh/ssh.go Outdated Show resolved Hide resolved
internal/jimm/ssh/ssh.go Outdated Show resolved Hide resolved
internal/ssh/dial.go Show resolved Hide resolved
internal/ssh/dial.go Show resolved Hide resolved
}
}
if client == nil {
return nil, fmt.Errorf("failed to dial controller ssh server: %v", errors)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this PR seems to change how we return errors.. is this an agreed direction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is just the way to return errors in ssh dial, no change to the controller's dial

Copy link
Collaborator

Choose a reason for hiding this comment

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

well, no, it's about how we return and log errors.. i would suggest returning always returning a sensible error.. now, how the ssh server's handler treats, logs and returns these errors to its client is a different matter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah ok, i've changed it to use the errorrs pkg with the msg decoupled from the error.

Copy link
Collaborator

@alesstimec alesstimec left a comment

Choose a reason for hiding this comment

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

LGTM.. BUT.. in the underlying layers i would suggest keeping error handling (and returning) as we do in other code.. the ssh server can then log and map these error as it likes..

internal/jimm/ssh/ssh.go Outdated Show resolved Hide resolved
internal/jimm/ssh/ssh.go Outdated Show resolved Hide resolved
}
}
if client == nil {
return nil, fmt.Errorf("failed to dial controller ssh server: %v", errors)
Copy link
Collaborator

Choose a reason for hiding this comment

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

well, no, it's about how we return and log errors.. i would suggest returning always returning a sensible error.. now, how the ssh server's handler treats, logs and returns these errors to its client is a different matter

@SimoneDutto SimoneDutto force-pushed the JUJU-7464/reuse-dial-logic branch from 36d2ee1 to 3018233 Compare January 21, 2025 14:12
@SimoneDutto SimoneDutto merged commit c0b0b11 into canonical:v3 Jan 21, 2025
4 checks passed
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