This repository was archived by the owner on Jan 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Allow per-deployment metrics check interval #39
Merged
krancour
merged 9 commits into
deislabs:master
from
vbehar:per-deployment-metrics-check-interval
Oct 18, 2019
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3eca5e4
Allow per-deployment metrics check interval
vbehar 4f2e891
Merge branch 'master' into per-deployment-metrics-check-interval
krancour d3dce7b
expose error from parsing annotation value
vbehar be6ef3f
Merge branch 'master' into per-deployment-metrics-check-interval
krancour 8d46b8c
add documentation
vbehar 7e1277a
Merge branch 'master' into per-deployment-metrics-check-interval
vbehar fa782a7
add a warning if metricsCheckInterval is invalid
vbehar e99cf3c
improve warning message
vbehar 1ddfe31
switch to testify for tests
vbehar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,17 +131,43 @@ func (z *zeroscaler) ensureMetricsCollection(deployment *appsv1.Deployment) { | |
| if ok { | ||
| collector.stop() | ||
| } | ||
| metricsCheckInterval, err := k8s.GetMetricsCheckInterval( | ||
| deployment.Annotations, | ||
| ) | ||
| if err != nil { | ||
| glog.Warningf( | ||
| "There was an error getting custom metrics check interval value "+ | ||
| "in deployment %s, falling back to the default value of %d "+ | ||
| "seconds; error: %s", | ||
| deployment.Name, | ||
| z.cfg.MetricsCheckInterval, | ||
| err, | ||
| ) | ||
| metricsCheckInterval = z.cfg.MetricsCheckInterval | ||
| } | ||
| if metricsCheckInterval <= 0 { | ||
| glog.Warningf( | ||
| "Invalid custom metrics check interval value %d in deployment %s,"+ | ||
| " falling back to the default value of %d seconds", | ||
| metricsCheckInterval, | ||
| deployment.Name, | ||
| z.cfg.MetricsCheckInterval, | ||
| ) | ||
| metricsCheckInterval = z.cfg.MetricsCheckInterval | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably worthy of a warning. |
||
| } | ||
| glog.Infof( | ||
| "Using new metrics collector for deployment %s in namespace %s", | ||
| "Using new metrics collector for deployment %s in namespace %s "+ | ||
| "with metrics check interval of %d seconds", | ||
| deployment.Name, | ||
| deployment.Namespace, | ||
| metricsCheckInterval, | ||
| ) | ||
| collector := newMetricsCollector( | ||
| z.kubeClient, | ||
| deployment.Name, | ||
| deployment.Namespace, | ||
| selector, | ||
| time.Duration(z.cfg.MetricsCheckInterval)*time.Second, | ||
| time.Duration(metricsCheckInterval)*time.Second, | ||
| ) | ||
| go func() { | ||
| collector.run(z.ctx) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error you return from
GetMetricsCheckInterval()already indicates it was an issue with paring the value. Since you're including the text of the error at the end of the warning message, this information basically appears twice.I would refrain from mentioning the value as "invalid" here and just note "there was an error getting.... falling back to." This way, also, if
GetMetricsCheckInterval()ever changes and produces other possible errors as well, there won't be text elsewhere in the code (e.g. right here) that needs to be adjusted to account for the different sorts of errors that function can produce.