Skip to content

Add changes for custom remote connections - #16923

Closed
Paul Higinbotham (PaulHigin) wants to merge 50 commits into
PowerShell:masterfrom
PaulHigin:custom_remote_connections2
Closed

Add changes for custom remote connections#16923
Paul Higinbotham (PaulHigin) wants to merge 50 commits into
PowerShell:masterfrom
PaulHigin:custom_remote_connections2

Conversation

@PaulHigin

@PaulHigin Paul Higinbotham (PaulHigin) commented Feb 25, 2022

Copy link
Copy Markdown
Contributor

PR Summary

This PR implements the Custom Remote Connections RFC:
https://github.com/PowerShell/PowerShell-RFC/blob/master/Archive/Draft/RFC0063-Custom-Remote-Connections.md

PR Context

These changes open up the internal PowerShell remoting API so that custom connections can be created as PowerShell modules. This PR does not introduce any new functions, and instead selectively makes some previously internal APIs public so that third parties can create custom remote connections without modifying PowerShell core engine code. See the above RFC for more details.

A new module repo has been created to serve as an example custom connection, by using the newly public API to create a named pipe custom remote connection. The module is also built in PowerShell CI to allow for testing.

This module will be transferred to the PowerShell repo at some point.
https://github.com/PaulHigin/NamedPipeConnection

PR Checklist

@ghost

Copy link
Copy Markdown

Open PRs should not be assigned to milestone, so they are not assigned to the wrong milestone after they are merged. For backport consideration, use a backport label.

Comment thread src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs Outdated
Comment thread src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs Outdated
Comment thread src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs Outdated
@iSazonov

Copy link
Copy Markdown
Collaborator

I still have doubts that this is needed or that this is the right direction, as I don't see the analytics.

  • Do we really have persistent requests for this?
  • Who are these people?
  • What do they really want to implement and when?

Is it worth taking any steps without understanding this? Perhaps they all want the same thing and we could join forces?

I may be wrong, but I feel and what first comes to mind is that (1) gRPC is starting to dominate on both Unix and Windows, (2) it's time for some PSRP extensions.
Sorry to repeat myself but this is happening because I don't see an analysis and arguments.

@ghost ghost removed the Review - Needed The PR is being reviewed label Feb 26, 2022

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is there any additional validation we should be doing for these changes?

@PaulHigin

Paul Higinbotham (PaulHigin) commented Feb 28, 2022

Copy link
Copy Markdown
Contributor Author

James Truher (@JamesWTruher) No new functionality was added so there is no need for new functional tests. Currently the only way I validate the new public APIs is via the example module I created (https://github.com/PaulHigin/SSHRemotingConnection). We could create new tests that takes a dependency on this module, but I feel it would not be that valuable for CI. I feel the best way to validate the new APIs is to have community members create their own custom connections and provide feedback.

GitHub
Custom PowerShell custom remoting connection . Contribute to PaulHigin/SSHRemotingConnection development by creating an account on GitHub.

@PaulHigin

Copy link
Copy Markdown
Contributor Author

Ilya (@iSazonov) I agree that it is time to take a critical look at PowerShell's current remoting system. But this change is a very narrow scope to allow third parties to create custom connections with the current remoting system. Granted, not very many customers will take advantage of this, but it is still important for some scenarios. Specifically, this will allow third parties to create a custom Linux/Mac -> Windows (WinRM) solution, without having to modify internal PowerShell engine code. And this is something that many customers have asked for, and which we don't currently support.

@JamesWTruher

James Truher (JamesWTruher) commented Mar 1, 2022

Copy link
Copy Markdown
Collaborator

James Truher (@JamesWTruher) No new functionality was added so there is no need for new functional tests. Currently the only way I validate the new public APIs is via the example module I created (https://github.com/PaulHigin/SSHRemotingConnection). We could create new tests that takes a dependency on this module, but I feel it would not be that valuable for CI. I feel the best way to validate the new APIs is to have community members create their own custom connections and provide feedback.

GitHub**GitHub - PaulHigin/SSHRemotingConnection: Custom PowerShell custom remoting connection**Custom PowerShell custom remoting connection . Contribute to PaulHigin/SSHRemotingConnection development by creating an account on GitHub.

one of the things that i've done are tests like:

it "the type 'new.public.newexcitingtype' should be public" {
("new.public.newexcitingtype" -as [type]).Name | Should -Be newexcitingtype
}
GitHub
Custom PowerShell custom remoting connection . Contribute to PaulHigin/SSHRemotingConnection development by creating an account on GitHub.

@iSazonov

Copy link
Copy Markdown
Collaborator

I agree that it is time to take a critical look at PowerShell's current remoting system.

Paul Higinbotham (@PaulHigin) Thanks for clarify! I hope we open new discussion to collect ideas and prepare experiments.

* Add fix for process objects for processes that have exited.

* Fix code factor

* Fix typo

* Add try/catch for possible race condition on exiting process.
@PaulHigin

Copy link
Copy Markdown
Contributor Author

James Truher (@JamesWTruher) That is an interesting idea but I don't see a lot of value in it. But I am thinking of creating a simpler named pipe custom module for testing. We already have support in our build for building test (module) binaries.

@jborean93

Copy link
Copy Markdown
Collaborator

I'm hoping to test this out at some point in the next few days, excited to see it's here.

For testing it sounds like just replicating the NamedPipeConnectionInfo with your own custom pipe to ensure both the client and server can correctly transfer the data as expected would be a good test case.

Comment thread .vsts-ci/templates/windows-test.yml

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Paul Higinbotham (@PaulHigin) it looks like you pulled in commits unrelated to this feature, can you fix this?

Comment thread build.psm1
@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Mar 16, 2022
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Mar 16, 2022
@pull-request-quantifier-deprecated

Copy link
Copy Markdown

This PR has 1429 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Large
Size       : +1103 -326
Percentile : 100%

Total files changed: 45

Change summary by file extension:
.yml : +2 -2
.psm1 : +33 -0
.cs : +640 -286
.resx : +4 -1
.ps1 : +343 -37
.config : +10 -0
.psd1 : +51 -0
.csproj : +20 -0

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detetcted.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@PaulHigin

Copy link
Copy Markdown
Contributor Author

Closing this PR after adding new one with clean changes.

#17011

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

Labels

Extra Large WG-Remoting PSRP issues with any transport layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.