fix: avoid possible panic in govc metric commands #2859
Merged
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.
Description
Newer versions of vCenter may return a CounterId via QueryAvailablePerfMetric()
which does not have a corresponding PerfCounterInfo entry in PerformanceManager's
perfCounter property. This results in a panic by a few of the govc metric commands
and any application using performance.Manager.AvailableMetric with Sort enabled.
While this may be a bug in vCenter, it is included in some recent release versions.
This workaround avoids the panic by ignoring any CounterId w/o a PerfCounterInfo.
Also updated vcsim's PerformanceManager.QueryCounter to match real vCenter's behavior.
Where null is returned for an unknown CounterId.
Closes #2835
Type of change
Please mark options that are relevant:
not work as expected)
How Has This Been Tested?
Tested against vCenter build 55745184 (unreleased 8.0).
Updated vcsim to add this behavior, which triggered the same panics in govc metric commands without this fix.
Checklist:
this project