SSH remoting cmdlet parameter set changes based on RFC 0010#2710
SSH remoting cmdlet parameter set changes based on RFC 0010#2710mirichmo merged 11 commits intoPowerShell:masterPowerShell/PowerShell:masterfrom PaulHigin:RFCRemoteCmdletsCopy head branch name to clipboard
Conversation
… RFCRemoteCmdlets
… RFCRemoteCmdlets
… for CoreCLR entry point when hosted in SSH as a subsystem.
|
|
||
| It "New-PSSession SSHTransport parameter cannot have false value" { | ||
|
|
||
| [System.Management.Automation.ErrorRecord] $paramError = $null |
There was a problem hiding this comment.
It is a good candidate for BeforeEach.
There was a problem hiding this comment.
Thanks, will change.
|
|
||
| Describe "SSHConnection parameter hashtable error conditions" -Tags 'CI' { | ||
|
|
||
| It "SSHConnection parameter hashtable cannot contain empty parameter names" { |
There was a problem hiding this comment.
Perhaps it would be better to use -Testcase in the Describe block.
There was a problem hiding this comment.
Thanks, will change.
| // For NanoServer: | ||
| // 1. There is no GetCurrentConsoleFontEx / SetCurrentConsoleFontEx on NanoServer; | ||
| // 2. We don't handle CJK locales on NanoServer due to lack of win32 API supports on NanoServer. | ||
| #if !CORECLR |
There was a problem hiding this comment.
The comment doesn't match the specified environment. Nano Server (and IoT) are (Platform.IsInbox && Platform.IsCoreCLR) aka Platform.IsNanoServer() and Platform.IsIoT(). However, line 285 indicates that the code is for Windows PowerShell on full SKUs
There was a problem hiding this comment.
I don't understand your comment. This code was simply moved from one place to another. Please feel free to update the comment as needed.
There was a problem hiding this comment.
My request is for you to improve the existing comment since you are touching that bit of code
| #endregion | ||
| } | ||
|
|
||
| internal struct SSHConnection |
| /// Parse the Connection parameter HashTable array. | ||
| /// </summary> | ||
| /// <returns>Array of SSHConnection objects</returns> | ||
| private const string ComputerNameParameter = "ComputerName"; |
There was a problem hiding this comment.
These should have their own region
| { | ||
| connectionInfo.UserName = paramValue; | ||
| } | ||
| else if (paramName.Equals(KeyFilePathParameter, StringComparison.OrdinalIgnoreCase) || paramName.Equals(IdentityFilePathAlias, StringComparison.OrdinalIgnoreCase)) |
There was a problem hiding this comment.
There are a lot of string comparisons here. I'm wondering about techniques to optimize the matching and if they are worth the perf gain.
There was a problem hiding this comment.
What do you have in mind? Computer names, User names, and file paths cannot be made into enums since they are not known before hand. I am open to any suggestions.
There was a problem hiding this comment.
After talking offline I think this is Ok as is. This parameter set is intended to support fan-out remoting where it is possible that 100s of target machines are specified in the hashtable. But I feel the parsing of these connection info objects is insignificant compared to setting up the remote runspaces needed for each connection. But this is something we can revisit if it turns out to be a perf problem.
| } | ||
| } | ||
|
|
||
| if (string.IsNullOrEmpty(connectionInfo.ComputerName)) |
There was a problem hiding this comment.
Based on the checks of lines 829 and 835, the only way this can be true is if it is not provided via ComputerName or HostName. What about just checking for that condition as a separate IF check after the checks on 815 and 820?
There was a problem hiding this comment.
It is possible for ComputerName or HostName to exist but contain only space characters. So the check would have to be a contains coupled with a not-empty check. It is easier to do the single check here.
| #region Supress PSRemotingBaseCmdlet SSH hash parameter set | ||
|
|
||
| /// <summary> | ||
| /// Connection |
There was a problem hiding this comment.
Yes. Enter-PSSession cmdlet derives from a base cmdlet that defined SSHConnection parameter, which is not applicable here and must be suppressed. This is done throughout our code base.
There was a problem hiding this comment.
My comment was specific to the content of the comment on line 180. It is not clear. In other places you state, "Suppress Connection"
| <value>The SSH client session has ended with no error message.</value> | ||
| </data> | ||
| <data name="MissingRequiredSSHParameter" xml:space="preserve"> | ||
| <value>The provided SSHConnection hash table is missing the required ComputerName or HostName parameter.</value> |
There was a problem hiding this comment.
Hashtable is a single word since it is referring to System.Collections.Hashtable
| ## SSH Remoting cmdlet tests | ||
| ## | ||
|
|
||
| Describe "SSHTransport switch parameter value" -Tags 'CI' { |
There was a problem hiding this comment.
These should be "Feature" tests because they are all negative.
| } | ||
| catch { $paramError = $_ } | ||
|
|
||
| $paramError.FullyQualifiedErrorId | Should Match "ParameterArgumentValidationError" |
There was a problem hiding this comment.
Do this check within the catch block and make it explicit:
$_.FullyQualifiedErrorId | Should Be "ParameterArgumentValidationError,<...>" <--Needs additional stuff to match the FQEID
There was a problem hiding this comment.
Fixed catch block. We need "Should Match" because FQEIDs can and are augmented over time, which breaks tests.
| } | ||
| } | ||
|
|
||
| Describe "SSHConnection parameter hashtable error conditions" -Tags 'CI' { |
There was a problem hiding this comment.
Same comments for the previous Describe apply here too.
Are you going to add any positive test cases for this feature? If so, those should be added as "CI."
There was a problem hiding this comment.
Fixed. Functional tests will be added when SSH remoting can be enabled via Enable-SSHRemoting. Currently it is a manual process. See RFC.
| throw new PSArgumentException(RemotingErrorIdStrings.InvalidSSHConnectionParameter); | ||
| } | ||
|
|
||
| if (paramName.Equals("ComputerName", StringComparison.OrdinalIgnoreCase) || paramName.Equals("HostName", StringComparison.OrdinalIgnoreCase)) |
There was a problem hiding this comment.
We should return error if we encounter both ComputerName and HostName (should be mutually exclusive) as it's ambiguous of the intent and probably a mistake.
| { | ||
| connectionInfo.UserName = paramValue; | ||
| } | ||
| else if (paramName.Equals("KeyFilePath", StringComparison.OrdinalIgnoreCase) || paramName.Equals("IdentityFilePath", StringComparison.OrdinalIgnoreCase)) |
There was a problem hiding this comment.
KeyFilePath and IdentityFilePath should also be mutually exclusive
| ParameterSetName = EnterPSSessionCommand.VMNameParameterSet)] | ||
| public String ConfigurationName { get; set; } | ||
|
|
||
| #region Supress PSRemotingBaseCmdlet SSH hash parameter set |
There was a problem hiding this comment.
'supress' is spelled wrong, but not sure why this word is even here?
There was a problem hiding this comment.
Fixed. This cmdlet derives from a base cmdlet that includes the SSHConnection parameter. But this cmdlet cannot support SSHConnection hashtable (since Enter-PSSession works only on single session) and we have to remove it from the parameter set. This is common in our code base and the word "suppress" is used for this and I continued using the term here.
There was a problem hiding this comment.
This has not been addressed yet
There was a problem hiding this comment.
Thanks. Not sure how I missed that. Fixed now.
…ting Invoke-Command parameter set
…ers to no longer work. This fix separates the SSH parameter sets from the existing WinRM parameter sets.
|
@SteveL-MSFT Do you have any other comments or concerns? If not, I'd like to merge this PR. |
These changes implement the SSH remoting cmdlet parameter set changes as discussed in RFC 0010 and comments (https://github.com/PowerShell/PowerShell-RFC/blob/master/1-Draft/RFC0010-SSH-Remoting-Cmdlets.md).
These changes also include a fix that prevented built-in Windows PowerShell (FullCLR) from hosting a SSH remoting endpoint. The issue was with the managed code entry point attempting to update the console font before knowing if PowerShell is being run in console or server mode. SSH hosts PowerShell in server mode without a console handle and this was preventing PowerShell from starting as an endpoint. Fix is to move the font update code to console start where it knows what mode is running.