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

config: avoid to use default dir if root is valid #393

Merged
merged 3 commits into from
Mar 6, 2023

Conversation

sctb512
Copy link
Member

@sctb512 sctb512 commented Mar 3, 2023

In the default configuration for snapshotter we fill the cacheDir and LogDir:

    logConfig := &c.LoggingConfig
    if len(logConfig.LogDir) == 0 {
		logConfig.LogDir = filepath.Join(c.Root, logging.DefaultLogDirName)
	}
    cacheConfig := &c.CacheManagerConfig
	if len(cacheConfig.CacheDir) == 0 {
		cacheConfig.CacheDir = filepath.Join(c.Root, "cache")
	}

But we do not fill these elements after loading the configuration from the `toml' file and parsing the arguments. This results in cacheDir and LogDir not being in snapshotter's RootDir.

@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +1.24 🎉

Comparison is base (d925eb5) 27.88% compared to head (fbb7a33) 29.13%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #393      +/-   ##
==========================================
+ Coverage   27.88%   29.13%   +1.24%     
==========================================
  Files          40       40              
  Lines        4077     4074       -3     
==========================================
+ Hits         1137     1187      +50     
+ Misses       2801     2741      -60     
- Partials      139      146       +7     
Impacted Files Coverage Δ
config/config.go 34.23% <ø> (+5.28%) ⬆️
config/default.go 75.00% <ø> (+75.00%) ⬆️
config/global.go 38.70% <100.00%> (+6.56%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -65,6 +66,17 @@ func main() {
}
}

if snapshotterConfig.Root != "" {
logConfig := &snapshotterConfig.LoggingConfig
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these implementations be put into config.MergeConfig or defaultSnapshotterConfig.FillUpWithDefaults()?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think FillUpWithDefaults might not work. But putting the implementation in config.MergeConfig makes more sense.

@sctb512 sctb512 force-pushed the fix-incorrect-configuration branch 3 times, most recently from 5cdb7f0 to 664e4cd Compare March 5, 2023 03:45
Copy link
Member

@changweige changweige left a comment

Choose a reason for hiding this comment

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

In fact, cache dir and log dir do not have to locate under snapshotter's root. It can be anywhere as per the user's configurations.

@sctb512
Copy link
Member Author

sctb512 commented Mar 5, 2023

In fact, cache dir and log dir do not have to locate under snapshotter's root. It can be anywhere as per the user's configurations.

Got it. Should we keep the cache dir and log dir under the root directory if the user does not specify these values.
The problems I encountered was that the cache dir and log dir are always in /var/lib/containerd-nydus even I specify another root directory.

@changweige
Copy link
Member

In fact, cache dir and log dir do not have to locate under snapshotter's root. It can be anywhere as per the user's configurations.

Got it. Should we keep the cache dir and log dir under the root directory if the user does not specify these values.

Yes. We should always put the log dir and cache dir under custom root dir

config/config.go Outdated
cacheConfig.CacheDir = filepath.Join(to.Root, "cache")
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Could we move the above code into ProcessConfigurations? I think MergeConfig is only a thin layer to merge default configurations and custom configurations. But we can tweak the merged configurations in ProcessConfigurations

Copy link
Member Author

@sctb512 sctb512 Mar 6, 2023

Choose a reason for hiding this comment

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

Done. PTAL.

@changweige
Copy link
Member

Need rebase

Signed-off-by: Bin Tang <tangbin.bin@bytedance.com>
Signed-off-by: Bin Tang <tangbin.bin@bytedance.com>
Signed-off-by: Bin Tang <tangbin.bin@bytedance.com>
@sctb512 sctb512 force-pushed the fix-incorrect-configuration branch from 664e4cd to fbb7a33 Compare March 6, 2023 02:32
Copy link
Member

@changweige changweige left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@changweige changweige merged commit cbb02e3 into containerd:main Mar 6, 2023
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.

None yet

4 participants