Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid possible panic in govc metric commands #2859

Merged
merged 1 commit into from Jun 15, 2022

Conversation

dougm
Copy link
Member

@dougm dougm commented May 27, 2022

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:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update
  • Build related change

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:

  • My code follows the CONTRIBUTION guidelines of
    this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Copy link
Contributor

@embano1 embano1 left a comment

Choose a reason for hiding this comment

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

LGTM, just not sure if this one broke the govc test?

@dougm
Copy link
Member Author

dougm commented May 31, 2022

LGTM, just not sure if this one broke the govc test?

#2850 broke the vm.migrate test, I will look into that and we can fix in a separate PR. Hadn't seen vcsim examples tests fail that way before, seems related to the Go install on the action workers.

@embano1
Copy link
Contributor

embano1 commented Jun 1, 2022

Ah, I have seen those before. It's due to some variables we use in the Makefile which shadow certain Go installation variables/GOROOT in the action runner. Need to look into that.

@dougm
Copy link
Member Author

dougm commented Jun 1, 2022

@embano1 PR #2867 fixes the govc vm.migrate test

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 vmware#2835
Copy link
Contributor

@embano1 embano1 left a comment

Choose a reason for hiding this comment

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

LGTM

@dougm dougm merged commit e42c94b into vmware:master Jun 15, 2022
@dougm dougm deleted the issue-2835 branch June 15, 2022 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] govc metric.ls panic
3 participants