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

feature: add runtime config #1366

Merged
merged 1 commit into from
Jun 11, 2018
Merged

feature: add runtime config #1366

merged 1 commit into from
Jun 11, 2018

Conversation

Ace-Tang
Copy link
Contributor

@Ace-Tang Ace-Tang commented May 21, 2018

  1. support add-runtime in daemon
  2. fix parse daemon flags twice
  3. add runtime info in pouch info

Signed-off-by: Ace-Tang aceapril@126.com

Ⅰ. Describe what this PR did

  1. support add-runtime in daemon
  2. fix parse daemon flags twice, which make flags be set for twice
  3. add runtime info in pouch info
  4. fix slice-type flags merge not take effect, move merge flags
    operation in runDaemon, since(*cobra.Command).Execute() will do flags
    parse.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented May 22, 2018

Codecov Report

Merging #1366 into master will increase coverage by 0.09%.
The diff coverage is 38.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1366      +/-   ##
==========================================
+ Coverage   40.45%   40.55%   +0.09%     
==========================================
  Files         253      254       +1     
  Lines       16466    16500      +34     
==========================================
+ Hits         6662     6692      +30     
- Misses       8948     8949       +1     
- Partials      856      859       +3
Impacted Files Coverage Δ
cli/info.go 0% <0%> (ø) ⬆️
daemon/mgr/container.go 49.29% <0%> (ø) ⬆️
daemon/mgr/system.go 73.27% <100%> (+0.23%) ⬆️
daemon/config/config.go 17.77% <5.26%> (-1.96%) ⬇️
main.go 62.5% <60%> (+0.24%) ⬆️
config/opt/runtime.go 66.66% <66.66%> (ø)
daemon/mgr/network.go 69.43% <0%> (+0.48%) ⬆️
ctrd/container.go 50.18% <0%> (+0.72%) ⬆️
... and 4 more

main.go Outdated
@@ -106,21 +102,17 @@ func setupFlags(cmd *cobra.Command) {
flagSet.BoolVar(&cfg.EnableProfiler, "enable-profiler", false, "Set if pouchd setup profiler")
flagSet.StringVar(&cfg.Pidfile, "pidfile", "/var/run/pouch.pid", "Save daemon pid")
flagSet.IntVar(&cfg.OOMScoreAdjust, "oom-score-adj", -500, "Set the oom_score_adj for the daemon")
}
cfg.Runtimes = make(map[string]types.Runtime)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do alloc memory at here, NewRuntime will alloc memory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we want get pointer of cfg.Runtime and cfg.Runtime should have been initialized, or use secondary pointer is ok, but seems also need one more line xx = &cfg.Runtimes, NewRuntime(&xx)

func iterateConfig(origin map[string]interface{}, config map[string]interface{}) {
for k, v := range origin {
if k == "add-runtime" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks so strange.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, for the history reason, TLS config is a map type.

return rt
}

// Set implement Runtime as pflag.Value interface
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should add unit test for this function.

@Ace-Tang
Copy link
Contributor Author

Ace-Tang commented Jun 7, 2018

@rudyfly @allencloud , I have update as the comment said, PTAL.

@Ace-Tang
Copy link
Contributor Author

Ace-Tang commented Jun 8, 2018

CI fail because of

FAIL: /go/src/github.com/alibaba/pouch/test/cli_upgrade_test.go:41: PouchUpgradeSuite.TestPouchUpgrade
/go/src/github.com/alibaba/pouch/test/cli_upgrade_test.go:49:
    res.Assert(c, icmd.Success)
/go/src/github.com/alibaba/pouch/vendor/github.com/gotestyourself/gotestyourself/icmd/command.go:61:
    t.Fatalf("at %s:%d - %s\n", filepath.Base(file), line, err.Error())
... Error: at cli_upgrade_test.go:49 - 
Command:  /usr/local/bin/pouch upgrade --name TestPouchUpgrade registry.hub.docker.com/library/busybox:1.25
ExitCode: 1
Error:    exit status 1
Stdout:   
Stderr:   Error: {"message":"failed to create new container: failed to create task for container(aef77d7aded6db9eeca779b0efc70918453096e78c2d09e4d027d24745ef5677): OCI runtime create failed: container_linux.go:265: starting container process caused \"process_linux.go:348: container init caused \\\"process_linux.go:331: running prestart hook 0 caused \\\\\\\"error running hook: exit status 1, stdout: , stderr: time=\\\\\\\\\\\\\\\"2018-06-07T13:56:40Z\\\\\\\\\\\\\\\" level=fatal msg=\\\\\\\\\\\\\\\"no sandbox present for aef77d7aded6db9eeca779b0efc70918453096e78c2d09e4d027d24745ef5677\\\\\\\\\\\\\\\" \\\\\\\\n\\\\\\\"\\\"\": unknown"}
Failures:
ExitCode was 1 expected 0
Expected no error

and

FAIL: /go/src/github.com/alibaba/pouch/test/cli_restart_test.go:34: PouchRestartSuite.TestPouchRestart
/go/src/github.com/alibaba/pouch/test/cli_restart_test.go:42:
    res.Assert(c, icmd.Success)
/go/src/github.com/alibaba/pouch/vendor/github.com/gotestyourself/gotestyourself/icmd/command.go:61:
    t.Fatalf("at %s:%d - %s\n", filepath.Base(file), line, err.Error())
... Error: at cli_restart_test.go:42 - 
Command:  /usr/local/bin/pouch restart -t 1 TestPouchRestart
ExitCode: 1
Error:    exit status 1
Stdout:   
Stderr:   Error: {"message":"service endpoint with name dbb09939 already exists"}
Failures:
ExitCode was 1 expected 0
Expected no error

As already know fail test.

1. support add-runtime in daemon
2. fix parse daemon flags twice, which make flags be set for twice
3. add runtime info in pouch info
4. fix slice-type flags merge not take effect, move merge flags
operation in runDaemon, since(*cobra.Command).Execute() will do flags
parse.

Signed-off-by: Ace-Tang <aceapril@126.com>
@rudyfly
Copy link
Collaborator

rudyfly commented Jun 11, 2018

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Jun 11, 2018
@rudyfly rudyfly merged commit e5ad144 into AliyunContainerService:master Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants