spring-cloud / spring-cloud-kubernetes

Kubernetes integration with Spring Cloud Discovery Client, Configuration, etc...
Apache License 2.0
3.45k stars 1.03k forks source link

Spring Cloud Kubernetes Configuration Watcher issue with two namespaces #1574

Closed TimMickelson closed 6 months ago

TimMickelson commented 7 months ago

Error logs in watcher Consider two POD, pod_a in namespace a, pod_b in namespace b. The Watcher is running in namespace a and is linked to a RabbitMQ. The PODs are refreshed as expected on updates on configmaps, but the watcher has verbose error logs.

The log from the watcher is a loop of error logs:

2024-02-07T11:47:02.785Z ERROR 1 --- [dels.V1Secret-1] i.k.c.informer.cache.ReflectorRunnable   : class io.kubernetes.client.openapi.models.V1Secret#Reflector loop failed unexpectedly

io.kubernetes.client.openapi.ApiException: 
    at io.kubernetes.client.openapi.ApiClient.handleResponse(ApiClient.java:973) ~[client-java-api-17.0.2.jar:na]
    at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:885) ~[client-java-api-17.0.2.jar:na]
    at io.kubernetes.client.informer.SharedInformerFactory$1.list(SharedInformerFactory.java:222) ~[client-java-17.0.2.jar:na]
    at io.kubernetes.client.informer.cache.ReflectorRunnable.run(ReflectorRunnable.java:91) ~[client-java-17.0.2.jar:na]
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[na:na]
    at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source) ~[na:na]
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[na:na]
    at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]

The setup Configuration application on pod_a

spring:
  config:
    activate:
      on-cloud-platform: kubernetes
    import: kubernetes:config
  cloud:
    kubernetes:
      discovery:
        enabled: false
      config:
        name: app_a
        namespace: a

Configuration app_b is the same. They have configmap with same name as spring.application.name on each project.

Configuration on Spring Cloud Kubernetes Config Watcher

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "7"
    meta.helm.sh/release-name: resesok-watcher
    meta.helm.sh/release-namespace: otp
  creationTimestamp: "2024-01-26T12:03:09Z"
  generation: 7
  labels:
    app.kubernetes.io/managed-by: Helm
  name: resesok-watcher
  namespace: otp
  resourceVersion: "667858808"
  uid: f365eaed-1b30-4fe3-90ac-50a8f5cfc066
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: resesok-watcher
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: resesok-watcher
    spec:
      containers:
      - env:
        - name: SPRING_CLOUD_KUBERNETES_RELOAD_NAMESPACES_0
          value: resesok-paratransit
        - name: SPRING_CLOUD_KUBERNETES_RELOAD_NAMESPACES_1
          value: otp
        - name: SPRING_PROFILES_INCLUDE
          value: bus-amqp
        - name: SPRING_APPLICATION_NAME
          value: resesok-watcher
        - name: SPRING_RABBITMQ_USERNAME
          valueFrom:
            secretKeyRef:
              key: username
              name: resesok-watcher-secrets
        - name: SPRING_RABBITMQ_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: resesok-watcher-secrets
        image: springcloud/spring-cloud-kubernetes-configuration-watcher:3.0.4
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /actuator/health/liveness
            port: 8888
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        name: spring-cloud-kubernetes-configuration-watcher
        ports:
        - containerPort: 8888
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /actuator/health/readiness
            port: 8888
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: resesok-watcher
      serviceAccountName: resesok-watcher
      terminationGracePeriodSeconds: 30
wind57 commented 7 months ago

thank you for opening it, but this is not minimal nor reproducible :( what I really meant is a github repo where we can replicate the exact steps. The idea is that we have integration tests with this functionality that don't exhibit such logs, that is why such details are needed.

TimMickelson commented 7 months ago

Ah sorry, I will try to find the time, but it will not happen now, we are in a critical point at work.

spring-cloud-issues commented 6 months ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues commented 6 months ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.