Skip to content

Expire Git refresh rate when the monitor endpoint is notified - #3342

Open
DDINGJOO wants to merge 1 commit into
spring-cloud:mainfrom
DDINGJOO:gh-2249-expire-refresh-on-webhook
Open

DDINGJOO wants to merge 1 commit into
spring-cloud:mainfrom
DDINGJOO:gh-2249-expire-refresh-on-webhook

Conversation

@DDINGJOO

@DDINGJOO DDINGJOO commented Oct 9, 2026

Copy link
Copy Markdown

Fixes #2249

When spring.cloud.config.server.git.refresh-rate is set, the config server doesn't fetch from the remote until the refresh rate has elapsed. A webhook sent to /monitor notifies the applications, which then fetch their configuration from the config server, but the config server may still serve them the previous commit.

Following the direction in the issue (the config server should learn that a repository changed and expire its refresh rate), this PR:

  • adds JGitEnvironmentRepository#expireRefreshRate(), which makes the next request fetch from the remote. A negative refresh rate (never fetch) is unchanged.
  • overrides it in MultipleJGitEnvironmentRepository to also expire the pattern-matching repositories and the repositories created for URI placeholders.
  • makes PropertyPathEndpoint expire the refresh rate of the config server's Git repositories before notifying the affected applications. Notifications that affect no application, for example because all paths are ignored, don't expire anything. EnvironmentMonitorAutoConfiguration passes the JGitEnvironmentRepository beans to the endpoint; the existing constructors keep working and pass none.

I first considered doing this with a PropertyPathNotifier, but an always-present notifier would defeat the "At least one PropertyPathNotifier must be available" check, so the endpoint does it directly.

This doesn't add a new way to make the server hit the Git server. It only lets the refresh that /monitor already triggers actually fetch, at most once per notification, and the existing webhook validators still apply.

Tests:

  • JGitEnvironmentRepositoryIntegrationTests: with a 60 second refresh rate, a new commit on the remote is not served within the window, and is served after expireRefreshRate().
  • MultipleJGitEnvironmentRepositoryTests: expiring also expires the managed repositories.
  • PropertyPathEndpointTests: the refresh rate is already expired when the notifiers run, and is left untouched when no service is affected.
  • The related server and monitor test classes pass locally (132 tests).

When spring.cloud.config.server.git.refresh-rate is set, the config
server does not fetch from the remote until the refresh rate has
elapsed. A webhook sent to /monitor notifies the applications, which
then fetch their configuration from the config server, but the config
server may still serve the previous commit to them.

Add JGitEnvironmentRepository#expireRefreshRate, which makes the next
request fetch from the remote. MultipleJGitEnvironmentRepository also
expires the repositories it manages. PropertyPathEndpoint expires the
refresh rate of the config server's Git repositories before notifying
the affected applications.

Fixes spring-cloudgh-2249

Signed-off-by: DDINGJOO <173995233+DDINGJOO@users.noreply.github.com>

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optionally force update of git repositories

2 participants