-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Simplify CLI commands by saving rpc-addr and project to context #592
Conversation
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.
Thanks for your contribution! I have a couple of comments:
A. Failure of admin_signup_test in CI
In this PR, I noticed that there are some module updates, and it appears that changing the status code to grpc
v1.55.0
is causing the failure in the admin_signup_test. To address this, how about keeping previous versions and only retaining the viper
installation?
B. CLI user flow
It's important to define the user flow for those using the CLI. Could you provide some examples of CLI usage following this flow:
- Login, Logout
- Login, Switch context with another Login, Logout
- Login, Switch context with another Login, Switch back to the previous context,
Logout
Additionally, we should also verify if these CLI changes have any side effects that need to be checked.
fb87da3
to
d51024f
Compare
7e40b95
to
d51024f
Compare
d51024f
to
4e36603
Compare
Sorry for the late response. A. Failure of admin_signup_test in CI Firstly, I was able to solve the problem by downgrading the grpc version to 1.54.0. However, I have a doubt regarding the actual response code value of the test code. This test code throws the 'Unknown' rpc error codes when the same user tries to sign up. (from google.golang.org/grpc/codes) In fact, when adding the viper library, if the grpc version is upgraded to 1.55.0, the actual value of this test is not 'Unknown' but throws an 'Internal' error code. I think it would be better to the test's intent to use the 'AlreadyExists' code provided by grpc codes. I'm curious about your opinion on this! (For the SignUp function process, errors related to duplicate keys should be wrapped with the 'AlreadyExists' code.) B. CLI user flow Every time a user logs in, they must specify the 'rpcAddr' and 'isInsecure' values as global flags. (mapping : --rpc-addr -> rpcAddr , --insecure -> isInsecure) If you log in with a new 'rpcAddr', the entry in 'auths' increases. 'Context' sub-command has been added. CASE 1 : login -> logout
CASE 2 : login -> switch context with another login -> logout
CASE 3 : login -> switch context with another login -> switch back to the previous context -> logout In this case, the processes (1), (2), (3), and (4) in CASE 2 are the same.
If you find any issues about user flow, I would appreciate your feedback! Regarding the last comment, you mentioned the need to check for side effects due to changes in the CLI. Could you provide specific guidance? Additionally, before this Pull Request gets merged, it seems necessary to update the CLI documentation on the yorkie-team.github.io. Once the discussion about the contents of this pull request is concluded, should I create an issue and then proceed with the work? |
Thank you for the detailed description. But first, please proceed with the following. A. Fix failure in CI
B. Convert Draft to Ready
https://github.com/yorkie-team/yorkie/blob/main/CONTRIBUTING.md#contribution-flow |
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 left one small comment briefly.
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #592 +/- ##
==========================================
+ Coverage 49.40% 49.47% +0.07%
==========================================
Files 69 69
Lines 9917 9951 +34
==========================================
+ Hits 4899 4923 +24
- Misses 4504 4512 +8
- Partials 514 516 +2 ☔ View full report in Codecov by Sentry. |
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.
How about adding name
field in config
, and use name
instead of rpcAddr
for context
commands to easily recognize and switch between contexts?
Ref: https://kubernetes.io/ko/docs/tasks/access-application-cluster/configure-access-multiple-clusters/
cmd/yorkie/config/config.go
Outdated
os.Exit(1) | ||
} | ||
|
||
file, err := os.Open(filepath.Clean(configPathValue)) |
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.
What does this file
do?
Is this required for viper.ReadInConfig()
?
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 had some concerns about this part.
Actually, I don't use the file variable in the section you mentioned.
In the existing CLI command, the Load function of config.go
is used, and the Load function checks for the existence of the config path and config.json file and creates one if it doesn't exist.
viper.ReadInConfig()
primarily reads the configuration values based on the configname, configtype, and config path set in commands.go.
During this process, for users who have installed the yorkie program for the first time, the config.json
does not exist in the ~/.yorkie
directory. Therefore, if simply call viper.ReadInConfig()
, an error occurs.
To resolve this, I utilized the logic of the Load function from config.go
. Do you think there's a need to modify the logic, or would it be better to remove the duplicated logic from the Load method?
(Additionally, the statement path.Join(os.Getenv("HOME"), ".yorkie")
in commands.go seems not to properly find the HOME directory in a Windows environment. Should this also be taken into consideration?)
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.
Do you think there's a need to modify the logic, or would it be better to remove the duplicated logic from the Load method?
It will be better to refactor duplicate codes in Load()
and ReadConfig()
.
Also, since ReadConfig()
name is confusing with Load()
, how about changing this function name to something like Preload()
?
(Additionally, the statement path.Join(os.Getenv("HOME"), ".yorkie") in commands.go seems not to properly find the HOME directory in a Windows environment. Should this also be taken into consideration?)
We need to cover Windows as well. We might need to code like this: https://gist.github.com/miguelmota/f30a04a6d64bd52d7ab59ea8d95e54da
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.
Thank you for the feedback. I will make the changes.
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.
Thanks for your contribution. CLI would be more convenient with context commands. I left a few comments.
A. Cannot logged in to api.yorkie.dev:443
I was not able to log in to api.yorkie.dev:443
with CLI from this PR. Could you find the reason of this?
$ yorkie login -u [ID] -p [PASSWORD] --rpc-addr api.yorkie.dev:443
Error: rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: http2: frame too large"
B. Look and Feel of yorkie context ls
command
Currently, CLI displays lists without borders, but yorkie context ls
command displays list with borders. Could we remove the border from the command to keep UI consistency?
$ yorkie document ls codepair --rpc-addr api.yorkie.dev:443
ID KEY CREATED AT ACCESSED AT UPDATED AT SNAPSHOT
64fe0ef0763112ce41c841d3 codepairs-cxz35r 32 hours 32 hours 32 hours {"content":[],"shapes":[]}
64fc0744763112ce41b34eb1 codepairs-wfkkzq 2 days 2 days 2 days {"content":[{"val":"#"},{"val":" "},{"val":"H"},{"...
C. Display current context in yorkie context ls
It would be useful to display current context in yorkie context ls
. We can refer to kubectl config get-contexts
command.
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
arn:aws:eks:ap-northeast-2:000000000000:cluster/yorkie-eks-XXXXXXXX arn:aws:eks:ap-northeast-2:000000000000:cluster/yorkie-eks-XXXXXXXX arn:aws:eks:ap-northeast-2:000000000000:cluster/yorkie-eks-XXXXXXXX
* arn:aws:eks:ap-northeast-2:000000000000:cluster/yorkie-eks-YYYYYYYY arn:aws:eks:ap-northeast-2:000000000000:cluster/yorkie-eks-YYYYYYYY arn:aws:eks:ap-northeast-2:000000000000:cluster/yorkie-eks-YYYYYYYY
minikube minikube minikube default
@hackerwins A. Cannot log in to api.yorkie.dev:443 I have not encountered this error before. I will try to reproduce the problem state and identify the problem and its solution. If you have any insights or possible causes, I would appreciate it. B. Look and Feel of yorkie context ls command I have fully understood the intent of the feedback for B and C. I will apply this into the pull request. |
@Wu22e Thanks for your reply.
I'm not sure why, but the error did not occur. I'll let you know if it occurs again. |
What this PR does / why we need it:
I have made changes to manage the rpc-addr and insecure global flags in the ~/.yorkie/config.json in the CLI application. In this process, the viper library was used to bind the necessary flag values to viper variables. Moreover, we were able to apply a priority as to which should be read between the user's explicit flag input and the config value.
(The explicit flag is bound to the viper variables before the config value.)
Which issue(s) this PR fixes:
Fixes #544
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation:
This pull request is failing the TestAdminRPCServerBackend/admin_signup_test. I am unable to find the cause of the failure, so I'm asking for help with the issue along with the pull request.
Checklist: