Skip to content

Conversation

imeoer
Copy link
Collaborator

@imeoer imeoer commented Sep 17, 2025

This pull request introduces a dynamic, hot-reloadable configuration system to the project, replacing the previous static configuration approach. The new system uses an atomic wrapper for configuration, allowing the application to reload configuration changes at runtime without restarting. This is supported by a file watcher and extensive refactoring to ensure all code accesses configuration via the new atomic interface. Additionally, a new test verifies the reload behavior, and some dependencies were updated to support these changes.

Key changes include:

Dynamic Configuration Reloading:

  • Introduced a new Config type that wraps the configuration in an atomic.Value, enabling safe concurrent access and hot-reloading of configuration changes at runtime (pkg/config/config.go, pkg/config/watcher.go). [1] [2]
  • Added a file watcher using fsnotify to monitor the configuration file for changes and automatically reload it when updated (pkg/config/watcher.go).

Refactoring for Atomic Configuration Access:

  • Refactored all usages of configuration throughout the codebase to access configuration values through the new atomic Config interface (i.e., cfg.Get().Field) instead of direct struct access. This affects files such as pkg/server/server.go, pkg/server/http.go, pkg/provider/provider.go, pkg/client/grpc.go, and others. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

Configuration Structure Enhancements:

  • Split the configuration into RawConfig (actual config fields) and Config (atomic wrapper), and added support for human-readable disk size fields via the new HumanizeSize type. [1] [2]
  • Fixed a typo in the configuration field name (TraceEndpoointTraceEndpoint).

Testing and Dependency Updates:

  • Added a new unit test (pkg/config/config_test.go) that verifies configuration hot-reloading works as expected.
  • Updated dependencies in go.mod to add fsnotify (for file watching), gomonkey (for testing), and moved golang.org/x/sys from indirect to direct dependency. [1] [2] [3]

Build and Test Improvements:

  • Improved the Makefile to streamline testing, including all packages except the main server package in standard tests and running the server tests separately.

These changes collectively make the configuration system more robust and flexible, allowing runtime updates and laying groundwork for future dynamic behavior.

@imeoer imeoer force-pushed the maximum-disk-usage-limit branch 4 times, most recently from 3ad5455 to e8f5394 Compare September 18, 2025 03:54
@imeoer imeoer changed the title feat: support maximum disk usage limit feat: support disk usage limit Sep 18, 2025
@imeoer imeoer force-pushed the maximum-disk-usage-limit branch from e8f5394 to 701ca73 Compare September 18, 2025 03:59
@imeoer imeoer marked this pull request as ready for review September 18, 2025 03:59
aftersnow
aftersnow previously approved these changes Sep 18, 2025
Copy link

@aftersnow aftersnow left a comment

Choose a reason for hiding this comment

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

lgtm

Add features.disk_usage_limit option to limit the disk
usage of model storage:

- disk_usage_limit == 0: reject if available disk space < model size;
- disk_usage_limit > 0: reject if (disk_usage_limit - used space) < model size;

And support automatic reloading of config to ensure the
daemonset pod can promptly detect this option.

Signed-off-by: imeoer <yansong.ys@antgroup.com>
- The assignment `*cfg = *newCfg` in `func (cfg *Config) reload(path string)` could
lead to a data race. Avoid this by refactoring using `atomic.Value`.
- Previously, `make test` didn't actually work, this commit fixes it as well.

Signed-off-by: imeoer <yansong.ys@antgroup.com>
@imeoer imeoer force-pushed the maximum-disk-usage-limit branch from 6809214 to 715f8a6 Compare September 19, 2025 02:14
@imeoer imeoer requested a review from aftersnow September 19, 2025 02:44
Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@imeoer imeoer merged commit 6fbe66c into modelpack:main Sep 19, 2025
6 checks passed
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.

4 participants