Skip to content

Fix unsafe access in multiscaler. - #2775

Merged
knative-prow-robot merged 2 commits into
knative:masterfrom
markusthoemmes:fix-multiscaler
Dec 21, 2018
Merged

knative-prow-robot merged 2 commits into
knative:masterfrom
markusthoemmes:fix-multiscaler

Conversation

@markusthoemmes

@markusthoemmes markusthoemmes commented Dec 21, 2018 •

Copy link
Copy Markdown
Contributor

Fixes #2774

Access to the watcher function needs to be guarded in a nil check, since it's not guaranteed to be set. I also added goroutine safety for good measure.

Release Note

NONE

@knative-prow-robot knative-prow-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 21, 2018

@knative-prow-robot knative-prow-robot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@markusthoemmes: 0 warnings.

Details

In response to this:

Fixes #2774

Access to the watcher function needs to be guarded in a nil check, since it's not guaranteed to be set.

Release Note

NONE

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-metrics-robot

Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/autoscaler/multiscaler.go 89.6% 89.4% -0.2

@vvraskin vvraskin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good, just a small nit

m.watcher(event)
return true
}
return false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe better to return an error and log it for posterity? it should never happen but just in case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not necessarily an error scenario, since one can choose not to set a watcher at all. After all, this is a publish/subscribe kind of pattern hence I opted to not return an error.

@knative-prow-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: markusthoemmes, vvraskin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@vvraskin

Copy link
Copy Markdown
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 21, 2018
@knative-prow-robot
knative-prow-robot merged commit 1668282 into knative:master Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants