Fix watcher (#1013)

* initial fix

Co-authored-by: Ryan Baxter <rbaxter@vmware.com>
This commit is contained in:
erabii
2022-05-17 23:24:29 +03:00
committed by GitHub
parent 01eaac9e43
commit 56fbef5fa6
9 changed files with 43 additions and 40 deletions

View File

@@ -3,9 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spring-cloud-kubernetes-controllers</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>3.0.0-SNAPSHOT</version>
<artifactId>spring-cloud-kubernetes-controllers</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -21,6 +21,7 @@ import io.fabric8.kubernetes.client.KubernetesClient;
import reactor.core.publisher.Mono;
import org.springframework.cloud.bus.BusProperties;
import org.springframework.cloud.bus.event.PathDestinationFactory;
import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent;
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy;
@@ -39,7 +40,7 @@ public class BusEventBasedConfigMapWatcherChangeDetector extends ConfigMapWatche
private ApplicationEventPublisher applicationEventPublisher;
private BusProperties busProperties;
private final BusProperties busProperties;
public BusEventBasedConfigMapWatcherChangeDetector(AbstractEnvironment environment,
ConfigReloadProperties properties, KubernetesClient kubernetesClient, ConfigurationUpdateStrategy strategy,
@@ -54,8 +55,8 @@ public class BusEventBasedConfigMapWatcherChangeDetector extends ConfigMapWatche
@Override
protected Mono<Void> triggerRefresh(ConfigMap configMap) {
this.applicationEventPublisher.publishEvent(
new RefreshRemoteApplicationEvent(configMap, busProperties.getId(), configMap.getMetadata().getName()));
this.applicationEventPublisher.publishEvent(new RefreshRemoteApplicationEvent(configMap, busProperties.getId(),
new PathDestinationFactory().getDestination(configMap.getMetadata().getName())));
return Mono.empty();
}

View File

@@ -21,6 +21,7 @@ import io.fabric8.kubernetes.client.KubernetesClient;
import reactor.core.publisher.Mono;
import org.springframework.cloud.bus.BusProperties;
import org.springframework.cloud.bus.event.PathDestinationFactory;
import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent;
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy;
@@ -39,7 +40,7 @@ public class BusEventBasedSecretsWatcherChangeDetector extends SecretsWatcherCha
private ApplicationEventPublisher applicationEventPublisher;
private BusProperties busProperties;
private final BusProperties busProperties;
public BusEventBasedSecretsWatcherChangeDetector(AbstractEnvironment environment, ConfigReloadProperties properties,
KubernetesClient kubernetesClient, ConfigurationUpdateStrategy strategy,
@@ -54,8 +55,8 @@ public class BusEventBasedSecretsWatcherChangeDetector extends SecretsWatcherCha
@Override
protected Mono<Void> triggerRefresh(Secret secret) {
this.applicationEventPublisher.publishEvent(
new RefreshRemoteApplicationEvent(secret, busProperties.getId(), secret.getMetadata().getName()));
this.applicationEventPublisher.publishEvent(new RefreshRemoteApplicationEvent(secret, busProperties.getId(),
new PathDestinationFactory().getDestination(secret.getMetadata().getName())));
return Mono.empty();
}

View File

@@ -0,0 +1,10 @@
spring:
cloud:
bus:
enabled: true
stream:
default-binder: rabbit
management:
health:
rabbit:
enabled: true

View File

@@ -0,0 +1,6 @@
spring:
cloud:
bus:
enabled: true
stream:
default-binder: kafka

View File

@@ -13,27 +13,9 @@ management:
health:
rabbit:
enabled: false
probes:
enabled: true
endpoint:
health:
probes:
enabled: true
server:
port: 8888
---
spring:
profiles: bus-amqp
cloud:
bus:
enabled: true
stream:
default-binder: rabbit
management:
health:
rabbit:
enabled: true
---
spring:
profiles: bus-kafka
cloud:
bus:
enabled: true
stream:
default-binder: kafka

View File

@@ -62,15 +62,13 @@ public class BusEventBasedConfigMapWatcherChangeDetectorTests {
private BusEventBasedConfigMapWatcherChangeDetector changeDetector;
private ConfigurationWatcherConfigurationProperties configurationWatcherConfigurationProperties;
private BusProperties busProperties;
@Before
public void setup() {
MockEnvironment mockEnvironment = new MockEnvironment();
ConfigReloadProperties configReloadProperties = new ConfigReloadProperties();
configurationWatcherConfigurationProperties = new ConfigurationWatcherConfigurationProperties();
ConfigurationWatcherConfigurationProperties configurationWatcherConfigurationProperties = new ConfigurationWatcherConfigurationProperties();
busProperties = new BusProperties();
changeDetector = new BusEventBasedConfigMapWatcherChangeDetector(mockEnvironment, configReloadProperties,
client, updateStrategy, fabric8ConfigMapPropertySourceLocator, busProperties,

View File

@@ -9,22 +9,27 @@ spring:
autoconfigure:
exclude: org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration
management:
health:
probes:
enabled: true
endpoint:
health:
probes:
enabled: true
---
spring:
profiles: bus-amqp
cloud:
bus:
enabled: true
stream:
default-binder: rabbit
config:
activate:
on-profile: bus-amqp
---
spring:
profiles: bus-kafka
cloud:
bus:
enabled: true
stream:
default-binder: kafka
default-binder: kafka
config:
activate:
on-profile: bus-kafka

View File

@@ -122,7 +122,7 @@ public class ActuatorRefreshRabbitMQIT {
() -> rest.getForEntity("http://localhost:80/it", String.class).getStatusCode().is2xxSuccessful());
// Wait a bit before we verify
await().pollInterval(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(90)).until(() -> {
await().pollInterval(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(120)).until(() -> {
Boolean value = rest.getForObject("http://localhost:80/it", Boolean.class);
log.info("Returned " + value + " from http://localhost:80/it");
return value;