Skip to content

Add conf-dir option and merge toml files#3310

Closed
yylt wants to merge 1 commit intocontainerd:masterfrom
yylt:dev
Closed

Add conf-dir option and merge toml files#3310
yylt wants to merge 1 commit intocontainerd:masterfrom
yylt:dev

Conversation

@yylt
Copy link
Copy Markdown
Contributor

@yylt yylt commented May 29, 2019

  • add conf-dir option
  • merge toml files into global config

Fix #3289

Signed-off-by: yylt [email protected]

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented May 29, 2019

Build succeeded.

@Yikun
Copy link
Copy Markdown
Contributor

Yikun commented May 29, 2019

recheck

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented May 29, 2019

Build succeeded.

  • containerd-build-arm64 : RETRY_LIMIT in 4m 47s (non-voting)

Copy link
Copy Markdown
Member

@mxpv mxpv left a comment

Choose a reason for hiding this comment

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

Can you add tests to make sure merging logic works as expected?

Comment thread services/server/server.go

// MergeConfd search file in confd , require filename like [0-0]-xx.toml
// merge conf by Positive sequence into config
func MergeConfd(config *srvconfig.Config, confd string) error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think config merging logic should reside in config package as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should I mock some .toml file in config directory? I think it's useless when use empty directory .

Copy link
Copy Markdown
Member

@mxpv mxpv Jun 2, 2019

Choose a reason for hiding this comment

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

I'm not sure what you mean by mocking a .toml file. I suggest to split the code up into something like:

- config.LoadFromFile(path string) <- loads a Config from a single file.
- config.merge(cfg ...Config) <- merges existing set of Config structs into one final struct 
- config.search(dir, mask string) <- searches config files by mask
- config.LoadFromDir(dir string) <- search+LoadFromFile+merge

This way you can test merge/search/load easily.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thank your suggestion, I will modify and push it later

@crosbymichael
Copy link
Copy Markdown
Member

What is the logic for how the configs are merged? Does it go by sections in the toml file and replaces that entire section or does it go by fields ?

@yylt
Copy link
Copy Markdown
Contributor Author

yylt commented Jun 13, 2019

What is the logic for how the configs are merged? Does it go by sections in the toml file and replaces that entire section or does it go by fields ?

i think it should go by sections and replaces section when section is not null

@crosbymichael
Copy link
Copy Markdown
Member

Does this change make the --config flag obsolete? We will need to manage backwards compatibility so that it continues to work.

@mxpv
Copy link
Copy Markdown
Member

mxpv commented Jun 20, 2019

Does this change make the --config flag obsolete? We will need to manage backwards compatibility so that it continues to work.

@crosbymichael This still makes the merging logic/file order a bit unclear.
Maybe we can get something similar to nginx config handler?
Where --config path defines master config file, and inside this file we define a list of imports we want to include. This way the merging logic is ordered and controlled, and we stay backward compatible.
Something like:

[debug]
  level = "debug"

imports = ["conf.d/1.toml", "conf.d/*_runtime.toml"]

@crosbymichael
Copy link
Copy Markdown
Member

@mxpv I like that idea as it's explicit and people understand the changes.

@Random-Liu @yylt does this work for your usecases or does it still introduce issues with editing the master config?

@yylt
Copy link
Copy Markdown
Contributor Author

yylt commented Jun 24, 2019

@mxpv I like that idea as it's explicit and people understand the changes.

@Random-Liu @yylt does this work for your usecases or does it still introduce issues with editing the master config?

In the beginning , add --conf.d flag to import config files in alphabetical order, it will not change the master config, I think it's minor modification, so it will backwards compatible .

I'm sorry for have not work on it for a long time

@dmcgowan dmcgowan added this to the 1.3 milestone Aug 19, 2019
@mxpv mxpv mentioned this pull request Aug 22, 2019
@dmcgowan
Copy link
Copy Markdown
Member

This one has been carried

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config.d

5 participants