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

exit if restclient session is unauthorized #22

Open
wants to merge 2 commits into
base: spectro-v1alpha4
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package session
import (
"context"
"net/url"
"os"
"sync"
"time"

Expand Down Expand Up @@ -113,6 +114,13 @@ func GetOrCreate(ctx context.Context, params *Params) (*Session, error) {
// if keepalive is enabled we depend upon roundtripper to reestablish the connection
// and remove the key if it could not
if params.feature.EnableKeepAlive {
restSession, restClientError := cachedSession.TagManager.Session(context.Background())
if restSession == nil && restClientError == nil {
if err := cachedSession.SessionManager.Logout(context.Background()); err != nil {
logger.V(0).Info("unable to logout vim client when rest client is already expired")
}
os.Exit(1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we add more logs before exit

}
return &cachedSession, nil
}
var err error
Expand Down