From 97c42d2f86a54c3070b55ef6b74e8508f3e3f782 Mon Sep 17 00:00:00 2001 From: zifeihan Date: Thu, 20 May 2021 07:52:49 +0800 Subject: [PATCH] Fixed part of the dynamic configuration of ConfigurationDiscoveryService that does not take effect under certain circumstances. (#6975) --- CHANGES.md | 1 + .../conf/dynamic/ConfigurationDiscoveryService.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 4e3c6c65d7..995cce823d 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 963d0b6436..ed596adfcf 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); } -- GitLab