Skip to content

Conversation

@wswsmao
Copy link
Contributor

@wswsmao wswsmao commented Nov 21, 2025

Fixes: #2178

This PR implements hot reloading, but only for fs configurations. My rationale is to reserve this feature for settings that are truly optional improvements.

The fs settings fit this model perfectly: the system is fully functional out-of-the-box, but users can tweak them for better results. Because the "best" value can be subjective or workload-dependent, users may want to adjust them frequently. Hot reloading makes this process of discovery and tuning seamless.

For higher-level settings that control fundamental behavior, hot reloading offers little benefit and introduces potential risk. A restart is the more appropriate mechanism for enabling or altering core features.

@wswsmao wswsmao force-pushed the hotreload branch 2 times, most recently from 8486693 to 9615064 Compare November 21, 2025 07:55
@wswsmao wswsmao closed this Nov 21, 2025
@wswsmao wswsmao reopened this Nov 21, 2025
@wswsmao wswsmao closed this Nov 21, 2025
@wswsmao wswsmao reopened this Nov 21, 2025
@wswsmao
Copy link
Contributor Author

wswsmao commented Dec 9, 2025

@ktock

defer w.mu.Unlock()

if w.lastConfig != nil {
revertBlacklistedChanges(ctx, w.lastConfig, &newFsConfig)
Copy link
Member

Choose a reason for hiding this comment

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

It looks like each package manages its own whitelist in UpdateConfig. Why do we need an additional blacklist here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, remove it

The config file can be passed to stargz snapshotter using `containerd-stargz-grpc`'s `--config` option.

## Configuration hot reload
Copy link
Member

Choose a reason for hiding this comment

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

The benefit of this feature compared to the FUSE manager (which already supports safe restarts) should be documented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@wswsmao
Copy link
Contributor Author

wswsmao commented Jan 6, 2026

All reviews done @ktock

Copy link
Member

@ktock ktock left a comment

Choose a reason for hiding this comment

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

Can we make it optional and enable only when a flag is specified to contaienrd-stargz-grpc to keep the consistency with the behaviour of the previous versions of the snapshotter? We should also have tests for this feature and docs about which exact field support the hot reloading.

Comment on lines +79 to +83
if event.Name == absFilePath {
// Trigger on Write, Create, Rename, or Chmod events
// such as vim, nano, etc.
if event.Has(fsnotify.Write) || event.Has(fsnotify.Create) ||
event.Has(fsnotify.Rename) || event.Has(fsnotify.Chmod) {
Copy link
Member

Choose a reason for hiding this comment

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

fsnotify.Rename

If the file is renamed, the next change won't be detected, will it? Is this an expected behaviour?


// WatchConfig monitors the specified configuration file for changes.
// It triggers the config reload when a change is detected.
func WatchConfig(
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to export this symbol.

Comment on lines +67 to +69
var (
debounceTimer *time.Timer
mu sync.Mutex
Copy link
Member

Choose a reason for hiding this comment

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

Why is debounceTimer protected by the mutex? Is this accessed from multiple goroutines? I cound't find new goroutine creation from inside of this function.


watchDir := filepath.Dir(absFilePath)

watcher, err := fsnotify.NewWatcher()
Copy link
Member

Choose a reason for hiding this comment

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

Does this work in the rootless settings?

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.

Implement Hot Reloading for Configuration

2 participants