-
Notifications
You must be signed in to change notification settings - Fork 54
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
inform user to login to OCM if the backplane failed due to that #486
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #486 +/- ##
==========================================
+ Coverage 45.66% 45.71% +0.04%
==========================================
Files 72 82 +10
Lines 5961 6224 +263
==========================================
+ Hits 2722 2845 +123
- Misses 2895 3027 +132
- Partials 344 352 +8
|
Thanks for the PR
LGTM. |
pkg/ocm/ocmWrapper.go
Outdated
if err != nil { | ||
if strings.Contains(err.Error(), ocmNotLoggedInMessage) { | ||
return nil, fmt.Errorf("please make sure you have logged into OCM, " + | ||
"use \"ocm login --use-auth-code --url $ENV\" to login ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit:
"use \"ocm login --use-auth-code --url $ENV\" to login ") | |
return nil, fmt.Errorf("Failed to create OCM connection: please ensure you are logged into OCM using the command \"ocm login --use-auth-code --url $ENV\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "Failed to create OCM connection:" will be included in the OCM side error message, I just update the second part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good then.
pkg/ocm/ocmWrapper.go
Outdated
ocmNotLoggedInMessage := "Not logged in" | ||
|
||
// Setup connection at the first try | ||
connection, err := ocm.NewConnection().Build() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls hook OCM_URL
env hack for fixing the reported issue
urlenv := os.Getenv("OCM_URL")
if urlenv != "" {
url, _ := urls.ResolveGatewayURL(urlenv, nil)
os.Setenv("OCM_URL", url)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I was about to include this part into the code... not finished yet
pkg/ocm/ocmWrapper.go
Outdated
ocmNotLoggedInMessage := "Not logged in" | ||
|
||
// Setup connection at the first try | ||
connection, err := ocm.NewConnection().Build() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we cache the connection in DefaultOCMInterfaceImpl
struct for optimized performance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As currently, in each function, it will close the connection in the end. So the connection itself it is reusable.
Will create a new card to handle this cached connection case.
e6b9588
to
2cc21d9
Compare
pkg/ocm/ocmWrapper.go
Outdated
if err != nil { | ||
if strings.Contains(err.Error(), ocmNotLoggedInMessage) { | ||
return nil, fmt.Errorf("please ensure you are logged into OCM by using the command " + | ||
"\"ocm login --use-auth-code --url $ENV\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it always true?
According to ocm login docs
ocm login --help
.....
--use-auth-code Login using OAuth Authorization Code. This should be used for most cases where a browser is available. See --use-device-code for remote hosts and containers.
--use-device-code Login using OAuth Device Code. This should only be used for remote hosts and containers where browsers are not available. See --use-auth-code for all other sce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not 100% percent sure what would be the use case for --use-device-code.
But I think we can just simply mention to use ocm login
@bmeng: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bmeng, samanthajayasinghe The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
(feature)
What this PR does / Why we need it?
OCM offline token disabled, backplane login would fail if OCM not logged in, inform the user to do the ocm login if it is not when executing the backplane commands
Which Jira/Github issue(s) does this PR fix?
Resolves #OSD-21603
Special notes for your reviewer
Unit Test Coverage
Guidelines
Test coverage checks
Pre-checks (if applicable)