diff --git a/CHANGES.md b/CHANGES.md index 4e3c6c65d7bdaabbd990e0c540929b46a721783e..995cce823db56f08c9b667bd4cb8ffdecf68f9c1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,7 @@ Release Notes. * Fix NPE when thrift field is nested in plugin `thrift` * Fix possible NullPointerException in agent's ES plugin. * Fix the conversion problem of float type in ConfigInitializer. +* Fixed part of the dynamic configuration of ConfigurationDiscoveryService that does not take effect under certain circumstances. #### OAP-Backend * BugFix: filter invalid Envoy access logs whose socket address is empty. diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/dynamic/ConfigurationDiscoveryService.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/dynamic/ConfigurationDiscoveryService.java index 963d0b643672f50858b5d96213dca4fffa296b0e..ed596adfcf25a25d190aeff2c3bf2aaabc4e6c8b 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/dynamic/ConfigurationDiscoveryService.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/dynamic/ConfigurationDiscoveryService.java @@ -62,6 +62,8 @@ public class ConfigurationDiscoveryService implements BootService, GRPCChannelLi private String uuid; private final Register register = new Register(); + private volatile int lastRegisterWatcherSize; + private volatile ScheduledFuture getDynamicConfigurationFuture; private volatile GRPCChannelStatus status = GRPCChannelStatus.DISCONNECT; private volatile ConfigurationDiscoveryServiceGrpc.ConfigurationDiscoveryServiceBlockingStub configurationDiscoveryServiceBlockingStub; @@ -206,6 +208,15 @@ public class ConfigurationDiscoveryService implements BootService, GRPCChannelLi try { ConfigurationSyncRequest.Builder builder = ConfigurationSyncRequest.newBuilder(); builder.setService(Config.Agent.SERVICE_NAME); + + // Some plugin will register watcher later. + final int size = register.keys().size(); + if (lastRegisterWatcherSize != size) { + // reset uuid, avoid the same uuid causing the configuration not to be updated. + uuid = null; + lastRegisterWatcherSize = size; + } + if (null != uuid) { builder.setUuid(uuid); }