Commit b4976ecb authored by Doug MacEachern's avatar Doug MacEachern

vSphere: set vCenter client UserAgent

Setting the client UserAgent makes it easier to identify vCenter sessions used by the vSphere Cloud Provider. This is useful to remove sessions that have leaked, such as when a VCP process goes away without calling Logout(). And to test that VCP properly re-authenticates when a session is removed. Example use: govc session.ls | grep kubernetes-cloudprovider | awk '{print $1}' | xargs -n1 govc session.rm
parent ac99da5e
......@@ -20,6 +20,7 @@ import (
"context"
"crypto/tls"
"encoding/pem"
"fmt"
"net"
neturl "net/url"
"sync"
......@@ -29,6 +30,7 @@ import (
"github.com/vmware/govmomi/sts"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/soap"
"k8s.io/kubernetes/pkg/version"
)
// VSphereConnection contains information for connecting to vCenter
......@@ -179,6 +181,9 @@ func (connection *VSphereConnection) NewClient(ctx context.Context) (*vim25.Clie
return nil, err
}
k8sVersion := version.Get().GitVersion
client.UserAgent = fmt.Sprintf("kubernetes-cloudprovider/%s", k8sVersion)
err = connection.login(ctx, client)
if err != nil {
return nil, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment