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

Fix nil linuxprofile #2621

Merged
merged 9 commits into from
Apr 10, 2018
Merged

Fix nil linuxprofile #2621

merged 9 commits into from
Apr 10, 2018

Conversation

zqingqing1
Copy link
Member

What this PR does / why we need it: Need to check if LinuxProfile is nil, otherwise raised nil pointer panic.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

If applicable:

  • documentation
  • unit tests
  • tested backward compatibility (ie. deploy with previous version, upgrade with this branch)

Release note:

@weinong
Copy link
Contributor

weinong commented Apr 6, 2018

UT?

jackfrancis
jackfrancis previously approved these changes Apr 6, 2018
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

weinong
weinong previously approved these changes Apr 6, 2018
@jackfrancis
Copy link
Member

@zqingqing1 @weinong the new testdata file suggests nil pointer execution flow is still possible (see latest test run)

@zqingqing1
Copy link
Member Author

yeh, working on this

weinong
weinong previously approved these changes Apr 9, 2018
SSHKeySize = 4096
)

func (a *Apiloader) createSSH(rg io.Reader) (publicKeyString string, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this function a duplicate of

func (s *SSHCreator) CreateSSH(rg io.Reader) (privateKey *rsa.PrivateKey, publicKeyString string, err error) {
? If so, is it possible to move it out in helpers/ and use the same function in both places to avoid duplicated code?

Copy link
Member Author

Choose a reason for hiding this comment

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

I discussed with Weinong. I tried to move the code to Helpers folder, however, some structs in the ssh.go are in acsengine folder. If I import acsengine in this file, it will have the import cycle. moving has much work than we thought.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not seeing why we shouldn't do, as Cecile suggests:

  1. move the SSHCreator type struct + methods in acs-engine/pkg/acsengine/ssh.go to pkg/acgengine/helpers/helpers.go
  2. convert existing usage patterns of github.com/Azure/acs-engine.SSHCreator to github.com/Azure/acs-engine/helpers.SSHCreator
  3. follow the above, new usage pattern in pkg/api

Copy link
Member Author

Choose a reason for hiding this comment

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

In the function createSaveSSH(although I don't use this function) in the ssh.go file, there is a struct called FileSaver and 2 functions privateKeyToPem(pki.go) SaveFile() are at acsengine folder. should we move the pki.go and other related file to helpers folder? Actually, we can leave that function there, and just move the CreateSSH() to helpers.go, But ssh_test.go actually called CreateSSH and privateKeyToPem functions, where should the ssh_test.go be?

Copy link
Member

Choose a reason for hiding this comment

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

I would move any tests of moved code to the new package namespace. I want to keep things as simple as possible, we just don't want to have duplicate code.

amanohar
amanohar previously approved these changes Apr 9, 2018
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.

We don't want to accept this change w/ the code duplication

@zqingqing1 zqingqing1 dismissed stale reviews from amanohar and weinong via 09502b4 April 10, 2018 00:42
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 7272611 into Azure:master Apr 10, 2018
jackfrancis added a commit that referenced this pull request Apr 10, 2018
jackfrancis pushed a commit that referenced this pull request Apr 11, 2018
* check if linuxprofile is nil
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants