Change:
<!-- Please only use this template for submitting enhancement requests --What would you like to be : We need reporting of version to be shown in the metrics. Why is this needed: The goal behind this is to add some info about the underlying infrastructure for the kubernetes cluster. Some customers were experiencing issues during the cluster upgrades, but nothing in the upgrades themselves or kubernetes code for provider seemingly could cause those. The issue is storage related, and happening on a variety of releases with a significant delay from any other underlying infrastructure change, to which the kubernetes cluster has no relation and a way to know about. So knowing used hostnames, and versions associated with it over time would be extremely beneficial for debugging in similar circumstances. Some of the use cases we face: 1) A is enabled in a customer environment, and so there occurs a periodic automated vMotion for VMs backing kuberentes . We'd like to know on which host the actual kubernetes was located at any moment, and if any vCenter version transitions happened over time, new hosts /removed/renamed.
/sig cloud-provider /wg provider-vsphere
The label(s) cannot be applied, because the repository doesn't have them <detailsIn response to : /sig cloud-provider /wg provider-vsphere Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/area provider/vmware

Discussion:
klog.Errorf("Failed to create govmomi client. err: %+v", err) return err } <ins> setVCenterInfoMetric(connection) </ins> return nil } m := session.NewManager(connection.Client)

klog.Errorf("Failed to create govmomi client. err: %+v", err) return err } <ins> setVCenterInfoMetric(connection) </ins> return nil }

package vclib import ( <ins> "sync" </ins> "time" <ins> "github.com/vmware/govmomi/vim25/types" </ins> "k8s.io/component-base/metrics" "k8s.io/component-base/metrics/legacyregistry" )

OperationCreateVolumeWithRawVSANPolicy = "CreateVolumeWithRawVSANPolicyOperation" ) <ins> var vCenterMetric *vcenterMetric func init() { vCenterMetric = &vcenterMetric{ vCenterInfos: make(map[string]types.AboutInfo), mux:          sync.Mutex{}, } } </ins> // vsphereAPIMetric is for recording latency of Single API Call. var vsphereAPIMetric = metrics.NewHistogramVec( &metrics.HistogramOpts{

[]string{"operation"}, ) <ins> var vsphereVersion = metrics.NewDesc( "cloudprovider_vsphere_vcenter_versions", "Versions for connected vSphere vCenters", []string{"hostname", "version", "build"}, nil, metrics.ALPHA, "") </ins> // RegisterMetrics registers all the API and Operation metrics func RegisterMetrics() { legacyregistry.MustRegister(vsphereAPIMetric) legacyregistry.MustRegister(vsphereAPIErrorMetric) legacyregistry.MustRegister(vsphereOperationMetric) legacyregistry.MustRegister(vsphereOperationErrorMetric) <ins> legacyregistry.CustomMustRegister(vCenterMetric) } type vcenterMetric struct { metrics.BaseStableCollector mux          sync.Mutex vCenterInfos map[string]types.AboutInfo } func (collector *vcenterMetric) DescribeWithStability(ch chan<- *metrics.Desc) { ch <- vsphereVersion } func (collector *vcenterMetric) CollectWithStability(ch chan<- metrics.Metric) { collector.mux.Lock() defer collector.mux.Unlock() for vCenter, info := range collector.vCenterInfos { ch <- metrics.NewLazyMetricWithTimestamp(time.Now(), metrics.NewLazyConstMetric(vsphereVersion, metrics.GaugeValue, float64(1), vCenter, info.Version, info.Build)) } } func (collector *vcenterMetric) setAbout(server string, info types.AboutInfo) { collector.mux.Lock() defer collector.mux.Unlock() collector.vCenterInfos[server] = info } func setVCenterInfoMetric(connection *VSphereConnection) { vCenterMetric.setAbout(connection.Hostname, connection.Client.ServiceContent.About) </ins> } // RecordvSphereMetric records the vSphere API and Operation metrics