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

Fixing panic issue in Validate when properties are nil #3242

Merged
merged 1 commit into from
Jun 15, 2018

Conversation

tariq1890
Copy link
Contributor

@tariq1890 tariq1890 commented Jun 9, 2018

What this PR does / why we need it: Avoiding panics during validation

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

Special notes for your reviewer:

If applicable:

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

Release note:

@acs-bot acs-bot added the size/M label Jun 9, 2018
@@ -65,6 +65,9 @@ func (l *LinuxProfile) Validate() error {

// Validate implements APIObject
func (a *Properties) Validate() error {
if a == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Can you point to some references that suggest that this is idiomatic golang? I think we prefer to do this nil-type validation before the method is invoked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, I did think of that initially. But I decided against it as I supposed this it'd be more consistent to put it within the Validate method. I'll make the change and push it.

@tariq1890 tariq1890 force-pushed the master branch 2 times, most recently from 1f8044c to 71989e7 Compare June 11, 2018 17:27
@tariq1890
Copy link
Contributor Author

@jackfrancis I've made the changes. As for the references, I am not sure if adding multiple comments is a good idea. I thought of pointing to this as a reference for other readers , https://golang.org/doc/faq#nil_error. Thoughts?

@codecov
Copy link

codecov bot commented Jun 11, 2018

Codecov Report

Merging #3242 into master will increase coverage by <.01%.
The diff coverage is 60%.

@@            Coverage Diff             @@
##           master    #3242      +/-   ##
==========================================
+ Coverage   52.72%   52.73%   +<.01%     
==========================================
  Files         103      103              
  Lines       15461    15471      +10     
==========================================
+ Hits         8152     8158       +6     
- Misses       6569     6573       +4     
  Partials      740      740

@CecileRobertMichon
Copy link
Contributor

@shrutir25 @amanohar @weinong how does this PR align with #3197 ?

@jackfrancis
Copy link
Member

/lgtm

@acs-bot
Copy link

acs-bot commented Jun 15, 2018

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jackfrancis, tariq1890

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

@jackfrancis jackfrancis merged commit 109ab3d into Azure:master Jun 15, 2018
PaulCharlton added a commit to ElementAnalytics/acs-engine that referenced this pull request Jun 20, 2018
* 'master' of https://github.com/Azure/acs-engine: (44 commits)
  remove duplicate ebtables (Azure#3308)
  Kubernetes: Remove Windows-specific foo for control plane config (Azure#3240)
  add k8s 1.8.14 (Azure#3303)
  run /usr/lib/apt/apt.systemd.daily in background (Azure#3304)
  add annotation to secrets field (Azure#3292)
  fix(oms): pull oms directly from docker (Azure#3294)
  ensure params vals are bool, with test (Azure#3285)
  udpate to latest 16.04 LTS image (Azure#3286)
  Enable openshift e2e tests on centos (Azure#2910)
  remove docker dependency from hyperkube extract (Azure#3296)
  remove pathological test (Azure#3291)
  Refactor validateDNSPrefix function in one place (Azure#3276)
  remove unnecessary nil check (Azure#3290)
  Fixing panic issue in Validate when properties are nil (Azure#3242)
  Updating the omsagent yaml file to include new changes for node zero dependency (Azure#3277)
  revert Azure CNI to 1.0.4 (Azure#3289)
  Add e2e test for openshift vnet (Azure#3274)
  Support upgrading a Kubernetes cluster that contains Virtual Machine Scale Sets (Azure#3223)
  Set extension for custom DNS (Azure#3264)
  don't exit CSE on apt.systemd.daily error (Azure#3278)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants