Skip to content

Skipping configmap events due to The current number of PropertySources does not match the ones loaded from Kubernetes - No reload will take place #2008

@aarrsseni

Description

@aarrsseni

Describe the bug
spring-cloud-kubernetes-commons: 3.3.0
I have such configuration:

  cloud:
    kubernetes:
      reload:
        enabled: true
        monitoring-config-maps: true
        monitoring-secrets: true
        mode: event
      config:
        namespace: ${namespace}
        sources:
          - name: ${configmap1}
          - name: ${configmap2}
        enable-api: true
        include-profile-specific-sources: false
      secrets:
        namespace: ${namespace}
        sources:
          - name: ${secrets1}
          - name: ${secrets2}
        enable-api: true
        include-profile-specific-sources: false

The issue is that if I'm modifying secrets I'm getting the event and all the relevant logic is triggered.
When only configmap is changed I'm getting: The current number of PropertySources does not match the ones loaded from Kubernetes - No reload will take place.
This happens because (k8s property sources size != app property sources size). In my case k8s property sources size: 2 and app property sources size: 4.
I assume that this is happening because of the code from ConfigReloadUtil.findPropertySources:

if (source instanceof BootstrapPropertySource<?> bootstrapPropertySource) {
				PropertySource<?> propertySource = bootstrapPropertySource.getDelegate();
				LOG.debug(() -> "bootstrap delegate class : " + propertySource.getClass());
				if (sourceClass.isInstance(propertySource)) {
					sources.add(propertySource);
				}
				else if (propertySource instanceof MountConfigMapPropertySource mountConfigMapPropertySource) {
					// we know that the type is correct here
					managedSources.add((S) mountConfigMapPropertySource);
				}
				else if (propertySource instanceof SecretsPropertySource secretsPropertySource) {
					// we know that the type is correct here
					managedSources.add((S) secretsPropertySource);
				}
			}

The if clause for SecretsPropertySource was added recently as part of this commit 52d47e2 and I assume it causes such behavior.
Could anybody please share why was it added?
It looks like a bug or maybe some additional configuration is required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions