Support reloading of gerrit.config
This change introduces a mechanism to allow reloading of the @GerritServerConfig. To execute a reload of gerrit.config, the SSH command "reload-config" is provided. Challenges and implementation: ------------------------------ Most callers that inject @GerritServerConfig are @Singletons. These @Singletons will only parse the GerritServerConfig once and then build and store more suitable datastructures to work from. To allow these modules to react on config changes, a caller can now implement GerritConfigListener, which will enable the caller to receive notifications of future config updates. The GerritConfigListener provides: void configUpdated(ConfigUpdatedEvent event); The ConfigUpdatedEvent provides the old config and the new one. Implementing classes of the listener are expected to do three things: 1. Investigate if any of the updated config values are of interest. The ConfigUpdatedEvent provides helper methods for this purpose: public boolean isSectionUpdated(String section) public boolean isValueUpdated(String section, String subsection, String name) (+ various overloaded versions of these) 2. React to the configuration changes (if any) and apply them 3. Accept or reject the entries of interest: public void accept(Set<ConfigKey> entries) public void accept(String section) public void reject(Set<ConfigKey> entries) (+ various overloaded versions of these) When a section (or specific config keys) are accepted or rejected, the ConfigUpdatedEvent will build a diff of what changes were accepted and present it to the administrator that issued a configuration reload. For instance, in this case, 4 config rows where added(+), 2 removed(-1) and 1 modified. All but one change were accepted, hence the user would get this output: $ ssh $HOST -p 29418 gerrit reload-config Accepted configuration changes: - suggest.maxSuggestedReviewers = 10 - suggest.accounts = 50 * addreviewer.maxAllowed = [100 => 1000] + sshd.requestLog = true + commentlink.changeid.link = #/q/$1 + commentlink.changeid.match = (I[0-9a-f]{8,40}) Rejected configuration changes: + gc.startTime = Fri 10:30 Documentation: -------------- We start by documenting the config entries that support config reloads (which number will be increasing over time). When we support reloading of the majority of config settings, the documentation can switch to documenting the config entries that does _not_ support config reloading instead. Roadmap: -------- This change will be followed by a couple of changes that introduces reloadable config support for: suggest-reviewers, sshd-log and commentlinks. Other stuff TODO includes: * REST end point * Rejection messages (to allow for an explanation on why the value was not accepted) * Test cases * An option to allow displaying the current effective configuration * A lot of implementations of the GerritConfigListener. Change-Id: I4bd6f389731af303ef9ba5d1d73f173d869c62e4
This commit is contained in:
@@ -284,6 +284,8 @@ public class GerritGlobalModule extends FactoryModule {
|
||||
bind(TransferConfig.class);
|
||||
|
||||
bind(GcConfig.class);
|
||||
DynamicSet.setOf(binder(), GerritConfigListener.class);
|
||||
|
||||
bind(ChangeCleanupConfig.class);
|
||||
bind(AccountDeactivator.class);
|
||||
|
||||
|
Reference in New Issue
Block a user