mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
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
This commit is contained in:
parent
ac99da5e3e
commit
b4976ecb17
@ -20,6 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
neturl "net/url"
|
neturl "net/url"
|
||||||
"sync"
|
"sync"
|
||||||
@ -29,6 +30,7 @@ import (
|
|||||||
"github.com/vmware/govmomi/sts"
|
"github.com/vmware/govmomi/sts"
|
||||||
"github.com/vmware/govmomi/vim25"
|
"github.com/vmware/govmomi/vim25"
|
||||||
"github.com/vmware/govmomi/vim25/soap"
|
"github.com/vmware/govmomi/vim25/soap"
|
||||||
|
"k8s.io/kubernetes/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
// VSphereConnection contains information for connecting to vCenter
|
// VSphereConnection contains information for connecting to vCenter
|
||||||
@ -179,6 +181,9 @@ func (connection *VSphereConnection) NewClient(ctx context.Context) (*vim25.Clie
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
k8sVersion := version.Get().GitVersion
|
||||||
|
client.UserAgent = fmt.Sprintf("kubernetes-cloudprovider/%s", k8sVersion)
|
||||||
|
|
||||||
err = connection.login(ctx, client)
|
err = connection.login(ctx, client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user