Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

feat: Enabling SSH on windows nodes by default #2759

Merged
merged 7 commits into from Apr 22, 2020

Conversation

marosset
Copy link
Contributor

@marosset marosset commented Feb 20, 2020

Reason for Change:

SSH has been supported on Windows since 1809/WS2019.
Since Windows 1803 is no longer being supported by MS this PR installs/configures SSH for windows agent pools unless WindowsProfile.SSHEnables is explicitly set to false.

Issue Fixed:

Requirements:

Notes:

@acs-bot
Copy link

acs-bot commented Feb 20, 2020

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marosset

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

@codecov
Copy link

codecov bot commented Feb 20, 2020

Codecov Report

Merging #2759 into master will increase coverage by 0.00%.
The diff coverage is 53.84%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #2759    +/-   ##
========================================
  Coverage   71.03%   71.04%            
========================================
  Files         147      147            
  Lines       25553    25679   +126     
========================================
+ Hits        18152    18244    +92     
- Misses       6271     6297    +26     
- Partials     1130     1138     +8     
Impacted Files Coverage Δ
cmd/get_logs.go 18.09% <0.00%> (ø)
pkg/api/converterfromapi.go 93.60% <0.00%> (-0.29%) ⬇️
pkg/api/convertertoapi.go 93.12% <0.00%> (-0.58%) ⬇️
pkg/api/vlabs/types.go 73.30% <ø> (ø)
pkg/api/types.go 94.37% <75.00%> (-0.09%) ⬇️
pkg/api/defaults.go 92.47% <100.00%> (+0.04%) ⬆️
pkg/engine/template_generator.go 81.70% <100.00%> (-0.81%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22c5fb6...70556cf. Read the comment docs.

@stale
Copy link

stale bot commented Mar 22, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 22, 2020
@stale stale bot closed this Mar 29, 2020
@marosset marosset reopened this Apr 13, 2020
@stale stale bot removed the stale label Apr 13, 2020
@marosset
Copy link
Contributor Author

@jackfrancis @jadarsie @ksubrmnn PTAL
I reactivated this old PR which enables SSH by default for Windows agent pools

pkg/api/defaults.go Outdated Show resolved Hide resolved
pkg/api/const.go Outdated Show resolved Hide resolved
if w.SSHEnabled != nil {
return *w.SSHEnabled
}
return DefaultWindowsSSHEnabled
Copy link
Member

Choose a reason for hiding this comment

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

This is probably not what we want. Are we assuming that this method is only invoked in execution flows after default enforcement flows have been traversed? (And if so, I still don’t think we want this method on this pointer object in this way.)

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 following the same behavior as GetEnabledWindowsUpdate directly below.

This was done this way in order to not perform updates to the stored apimodel.json in upgrade/scale scenarios but still be able to enforce a default value.

What do you have in mind for this logic?

Copy link
Member

Choose a reason for hiding this comment

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

So these methods are just for the E2E test runner?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And to protection when operating on older templates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I think - I initially wrote this ~2 months ago)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so I took a look and if there is an apimodel.json that does not have sshEnabled set is passed in to aks-engine generate the resulting apimodel.json in _output does persist the default value in code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic in defaults.go will set a value for w.SSHEnabled for generate operations but will not set a value for aks-engine upgrade or aks-engine scale operations - which looks like the behavior we want.
I see a unit test that verifies apimodel.json is not modified during those commands.
@jackfrancis i'm not following why you are against having a function first do a nil-check before returning a value - can you help me understand your concerns here?

Copy link
Member

Choose a reason for hiding this comment

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

I think my main concern is that GetSSHEnabled is a accessor method that wraps the SSHEnabled bool pointer property. So I would expect a nil value of that to be falsy.

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 PR changed SSHEnabled property from a bool to a bool pointer so we could get an extra state - set to false, set to true, or unset by the user).
In the case where it is unset by the user wouldn't it make sense to set it to a default value instead of false?

Copy link
Member

Choose a reason for hiding this comment

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

Right, perhaps I'm being too pedantic about that. It just seems that an accessor should return the truth, and if we want nil values to be semantically meaningful we should do that semantic enforcment so that it's sticky. I.e., so that by the time we use the accessors we can just have them be accessors, rather than being overloaded with that default value hijacking.

I think concretely what feels right to me is to set the default values during the defaults enforcement flow, and then confirm that the accessor is always being used only after that flow has been traversed and the data state representations have been rationalized (nil values converted to defaults, etc)

@@ -298,7 +298,7 @@ var _ = Describe("Azure Container Cluster using the Kubernetes Orchestrator", fu
dockerVersionCmd := fmt.Sprintf("\"docker version\"")
for _, n := range nodes {
if n.IsWindows() {
if eng.ExpandedDefinition.Properties.WindowsProfile != nil && !eng.ExpandedDefinition.Properties.WindowsProfile.SSHEnabled {
if eng.ExpandedDefinition.Properties.WindowsProfile != nil && !eng.ExpandedDefinition.Properties.WindowsProfile.GetSSHEnabled() {
Copy link
Member

Choose a reason for hiding this comment

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

for example, the method invocation here will operate against a ContainerService object post-template generation (i.e., we can rely upon the actual data in the object and not have to worry about highjacking the underlying value w/ the default const value)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about the case where we are working with an template generated with an older version of aks-engine which may not have a value for sshEnabled stored?
If we call GetSSHEnabled() we are guaranteed to never have a nil value.

Copy link
Member

Choose a reason for hiding this comment

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

Good point. I think we have the runner call a func/method in its own area that wraps nil values underneath appropriate defaults (true/false)

Copy link
Member

@jackfrancis jackfrancis left a comment

Choose a reason for hiding this comment

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

/lgtm

@jackfrancis jackfrancis merged commit b74f691 into Azure:master Apr 22, 2020
AbelHu pushed a commit to AbelHu/aks-engine that referenced this pull request May 26, 2020
andyliuliming pushed a commit that referenced this pull request May 26, 2020
* Add LicenseType in WindowsProfile

* feat: Enabling SSH on windows nodes by default (#2759)

Co-authored-by: Mark Rossetti <marosset@microsoft.com>
AbelHu pushed a commit to AbelHu/aks-engine that referenced this pull request May 27, 2020
AbelHu pushed a commit to AbelHu/aks-engine that referenced this pull request May 27, 2020
xuto2 pushed a commit that referenced this pull request May 28, 2020
Co-authored-by: Mark Rossetti <marosset@microsoft.com>
xuto2 added a commit that referenced this pull request May 30, 2020
xuto2 added a commit that referenced this pull request Jun 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants