-
Notifications
You must be signed in to change notification settings - Fork 949
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
feature: add update daemon config function #1514
feature: add update daemon config function #1514
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1514 +/- ##
==========================================
- Coverage 41.25% 41.14% -0.11%
==========================================
Files 255 257 +2
Lines 16837 16924 +87
==========================================
+ Hits 6946 6964 +18
- Misses 9024 9094 +70
+ Partials 867 866 -1
|
cli/update_daemon.go
Outdated
"github.com/spf13/cobra" | ||
) | ||
|
||
// updateDescription is used to describe update command in detail and auto generate command doc. |
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.
%s/update/updatedaemon ?
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.
fine
Could you tell us more about why we need this? @rudyfly |
} | ||
|
||
// write config to file | ||
fd, err := os.OpenFile(udc.configFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) |
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.
it will overwrite the origin config?
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.
yes, overwrite is right.
@allencloud I have update the pr's description, please see |
cli/update_daemon.go
Outdated
) | ||
|
||
// updateDescription is used to describe updatedaemon command in detail and auto generate command doc. | ||
var daemonUpdateDescription = "Update daemon's configurations, including debug level, image proxy, label, manager white list, " + |
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.
more doc needed here.
Could add integration test in z_cli_daemon_test.go, for example verify online update |
c97e20a
to
92fbd46
Compare
@Letty5411 Add |
test/z_cli_daemon_test.go
Outdated
|
||
command.PouchRun("updatedaemon", "--label", "aaa=bbb").Assert(c, icmd.Success) | ||
|
||
ret := command.PouchRun("info") |
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.
Use: ret = RunWithSpecifiedDaemon(&cfg, "version")
Or it will send request to the default pouchd instead of the testing one.
test/z_cli_daemon_test.go
Outdated
|
||
defer cfg.KillDaemon() | ||
|
||
command.PouchRun("updatedaemon", "--label", "aaa=bbb").Assert(c, icmd.Success) |
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.
Use: ret = RunWithSpecifiedDaemon(&cfg, "updatedaemon", "--label", "aaa=bbb")
LGTM |
Add update daemon config function. If pouchd is alive, it will change daemon config if it supports, and then change the config file. If pouchd is dead, it just update the daemon config file. Pouchd dead: You can specified the config file by set `--config-file` to update, more functions you can see by `pouch updatedaemon --help` Signed-off-by: Rudy Zhang <[email protected]>
Ⅰ. Describe what this PR did
Currently, update daemon only supports with restful api, there is no cli command,
so need add it, in addition, it only supports update with pouchd is alive, so we need
update config file when pouchd is dead.
Pouch daemon config file is json format, it's hard to modify
with shell script, so add this function to change the config file easily.
Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. Describe how you did it
If pouchd is alive, it will change, daemon config if it supports,
and then change the config file. If pouchd is dead, it just update
the daemon config file. Currently, online update only support
image-proxy
andlabel
, more options will be supported at thefollowing few prs.
pouchd offline set:
You can specified the config file by set
--config-file
to update,if pouchd is alive, you can set
--offline=true
to modify config file only,more functions you can see by
pouch updatedaemon --help
Ⅳ. Describe how to verify it
Online update
offline update
Ⅴ. Special notes for reviews
Signed-off-by: Rudy Zhang [email protected]