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

revert rest keepalive #18

Merged
merged 1 commit into from Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -91,9 +91,9 @@ RELEASE_REGISTRY := gcr.io/cluster-api-provider-vsphere/release
RELEASE_CONTROLLER_IMG := $(RELEASE_REGISTRY)/$(IMAGE_NAME)

# Development Docker variables
DEV_REGISTRY ?= gcr.io/spectro-images-public/deepak/release/cluster-api-provider-vsphere
DEV_REGISTRY ?= gcr.io/spectro-images-public/release/cluster-api-provider-vsphere
DEV_CONTROLLER_IMG ?= $(DEV_REGISTRY)/cluster-api-vsphere-controller
DEV_TAG ?= spectro-v0.8.1
DEV_TAG ?= spectro-v0.8.1-20220108
DEV_MANIFEST_IMG := $(DEV_CONTROLLER_IMG)

# Set build time variables including git version details
Expand Down
20 changes: 2 additions & 18 deletions pkg/session/session.go
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/session"
"github.com/vmware/govmomi/session/keepalive"
"github.com/vmware/govmomi/vapi/rest"
"github.com/vmware/govmomi/vapi/tags"
"github.com/vmware/govmomi/vim25"
Expand Down Expand Up @@ -144,7 +143,7 @@ func GetOrCreate(ctx context.Context, params *Params) (*Session, error) {
// Assign the finder to the session.
session.Finder = find.NewFinder(session.Client.Client, false)
// Assign tag manager to the session.
manager, err := newManager(ctx, logger, sessionKey, client.Client, soapURL.User, params.feature)
manager, err := newManager(ctx, client.Client, soapURL.User)
if err != nil {
return nil, errors.Wrap(err, "unable to create tags manager")
}
Expand Down Expand Up @@ -214,23 +213,8 @@ func clearCache(sessionKey string) {
}

// newManager creates a Manager that encompasses the REST Client for the VSphere tagging API
func newManager(ctx context.Context, logger logr.Logger, sessionKey string, client *vim25.Client, user *url.Userinfo, feature Feature) (*tags.Manager, error) {
func newManager(ctx context.Context, client *vim25.Client, user *url.Userinfo) (*tags.Manager, error) {
rc := rest.NewClient(client)
if feature.EnableKeepAlive {
rc.Transport = keepalive.NewHandlerREST(rc, feature.KeepAliveDuration, func() error {
s, err := rc.Session(ctx)
if err != nil {
return err
}
if s != nil {
return nil
}

logger.Info("rest client session expired, clearing cache")
clearCache(sessionKey)
return nil
})
}
err := rc.Login(ctx, user)
if err != nil {
return nil, err
Expand Down