Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
machine-api-operator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
paas-tools
okd4-deployment
machine-api-operator
Merge requests
!3
Cherry-pick CERN patches for OKD 4.10 release
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Cherry-pick CERN patches for OKD 4.10 release
cern-4.10-dev
into
cern-4.10
Overview
0
Commits
1
Pipelines
4
Changes
6
Merged
Jack Henschel
requested to merge
cern-4.10-dev
into
cern-4.10
2 years ago
Overview
0
Commits
1
Pipelines
4
Changes
2
Expand
0
0
Merge request reports
Compare
version 1
version 2
bf4c5863
2 years ago
version 1
65b34abd
2 years ago
cern-4.10 (base)
and
version 2
latest version
bf4c5863
1 commit,
2 years ago
version 2
bf4c5863
4 commits,
2 years ago
version 1
65b34abd
1 commit,
2 years ago
Show latest version
2 files
+
79
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
pkg/controller/vsphere/session/session.go
+
15
−
2
Options
@@ -22,6 +22,7 @@ import (
"fmt"
"net/url"
"sync"
"time"
"github.com/vmware/govmomi/vapi/rest"
"github.com/vmware/govmomi/vim25/mo"
@@ -40,6 +41,7 @@ var sessionMU sync.Mutex
const
(
managedObjectTypeTask
=
"Task"
clientTimeout
=
15
*
time
.
Second
)
// Session is a vSphere session with a configured Finder.
@@ -52,6 +54,18 @@ type Session struct {
password
string
}
func
newClientWithTimeout
(
ctx
context
.
Context
,
u
*
url
.
URL
,
insecure
bool
,
timeout
time
.
Duration
)
(
*
govmomi
.
Client
,
error
)
{
clientCreateCtx
,
clientCreateCtxCancel
:=
context
.
WithTimeout
(
ctx
,
timeout
)
defer
clientCreateCtxCancel
()
// It makes call to vcenter during new client creation, so pass context with timeout there.
client
,
err
:=
govmomi
.
NewClient
(
clientCreateCtx
,
u
,
insecure
)
if
err
!=
nil
{
return
nil
,
err
}
client
.
Timeout
=
timeout
return
client
,
nil
}
// GetOrCreate gets a cached session or creates a new one if one does not
// already exist.
func
GetOrCreate
(
@@ -84,11 +98,10 @@ func GetOrCreate(
// Set user to nil there for prevent login during client creation.
// See https://github.com/vmware/govmomi/blob/master/client.go#L91
soapURL
.
User
=
nil
client
,
err
:=
govmomi
.
NewClien
t
(
ctx
,
soapURL
,
insecure
)
client
,
err
:=
newClientWithTimeou
t
(
ctx
,
soapURL
,
insecure
,
clientTimeout
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error setting up new vSphere SOAP client: %w"
,
err
)
}
// Set up user agent before login for being able to track mapi component in vcenter sessions list
client
.
UserAgent
=
"machineAPIvSphereProvider"
if
err
:=
client
.
Login
(
ctx
,
url
.
UserPassword
(
username
,
password
));
err
!=
nil
{
Loading