eclipse-basyx / basyx-java-components

java-components
MIT License
25 stars 31 forks source link

AAS Server crashes after contacting registry in kubernetes deployment #35

Closed HansG89 closed 2 years ago

HansG89 commented 2 years ago

I tried to use the provided images eclipsebasyx/aas-registry:1.0.4 and eclipsebasyx/aas-server:1.0.2 to use them in a local kubernetes testing environment. When I don't provide a registry URL to the AAS Server, everything works fine. I can load an aasx file from a persistent kubernetes storage and of course the AAS does not get registered. When I provide a registry URL something strange happens. I can access the registry with its kubernetes internal DNS name and the AAS successfully gets registered. But afterwards the AAS server immediately crashes with the logs attached. Any idea how to further debug this issue?

08:43:33.919 [main] INFO org.eclipse.basyx.components.aas.executable.AASServerExecutable - Starting BaSyx AASServer component...
08:43:33.970 [main] INFO org.eclipse.basyx.components.configuration.BaSyxConfiguration - Loading properties from file '/usr/share/config/context.properties'
08:43:33.971 [main] INFO org.eclipse.basyx.components.configuration.BaSyxConfiguration - Loading from inputStream: java.io.FileInputStream@2401f4c3
08:43:33.972 [main] INFO org.eclipse.basyx.components.configuration.BaSyxConfiguration - contextHostname: 'localhost'
08:43:33.973 [main] INFO org.eclipse.basyx.components.configuration.BaSyxConfiguration - contextPath: '/aasServer'
08:43:33.973 [main] INFO org.eclipse.basyx.components.configuration.BaSyxConfiguration - contextPort: '4001'
08:43:33.978 [main] INFO org.eclipse.basyx.components.configuration.BaSyxConfiguration - Loading properties from file '/usr/share/config/aas.properties'
08:43:33.978 [main] INFO org.eclipse.basyx.components.configuration.BaSyxConfiguration - Loading from inputStream: java.io.FileInputStream@39ed3c8d
08:43:33.979 [main] INFO org.eclipse.basyx.components.configuration.BaSyxConfiguration - aas.backend: 'InMemory'
08:43:33.979 [main] INFO org.eclipse.basyx.components.configuration.BaSyxConfiguration - registry.path: 'http://aas-registry-service.basys.svc.cluster.local:4000/registry/'
08:43:33.979 [main] INFO org.eclipse.basyx.components.configuration.BaSyxConfiguration - aas.source: '/usr/share/config/data/demo-aas.aasx'
08:43:34.136 [main] INFO org.eclipse.basyx.components.aas.AASServerComponent - Create the server...
08:43:34.435 [main] INFO org.eclipse.basyx.components.aas.AASServerComponent - Registry loaded at "http://aas-registry-service.basys.svc.cluster.local:4000/registry/"
08:43:34.435 [main] INFO org.eclipse.basyx.components.aas.AASServerComponent - Loading aas from aasx "/usr/share/config/data/demo-aas.aasx"
08:43:35.718 [main] WARN org.eclipse.basyx.submodel.metamodel.map.qualifier.Referable - The passed idShort AAS_VUVG-LK10-B52-T-M5-1H2L-S_1 is not valid! It has to satisfy the RegEx [a-zA-Z][a-zA-Z0-9_]+
08:43:35.816 [main] WARN org.eclipse.basyx.submodel.metamodel.map.qualifier.Referable - The passed idShort TechnicalData_(Zvei) is not valid! It has to satisfy the RegEx [a-zA-Z][a-zA-Z0-9_]+
08:43:35.818 [main] WARN org.eclipse.basyx.submodel.metamodel.map.qualifier.Referable - The passed idShort Exhaust-air_function is not valid! It has to satisfy the RegEx [a-zA-Z][a-zA-Z0-9_]+
08:43:35.837 [main] DEBUG org.eclipse.basyx.components.xml.XMLAASBundleFactory - Found Submodel Documentation for AAS AAS_VUVG-LK10-B52-T-M5-1H2L-S_1
08:43:35.838 [main] DEBUG org.eclipse.basyx.components.xml.XMLAASBundleFactory - Found Submodel MCAD for AAS AAS_VUVG-LK10-B52-T-M5-1H2L-S_1
08:43:35.839 [main] DEBUG org.eclipse.basyx.components.xml.XMLAASBundleFactory - Found Submodel Nameplate for AAS AAS_VUVG-LK10-B52-T-M5-1H2L-S_1
08:43:35.841 [main] DEBUG org.eclipse.basyx.components.xml.XMLAASBundleFactory - Found Submodel Identification for AAS AAS_VUVG-LK10-B52-T-M5-1H2L-S_1
08:43:35.842 [main] DEBUG org.eclipse.basyx.components.xml.XMLAASBundleFactory - Found Submodel TechnicalData_(Zvei) for AAS AAS_VUVG-LK10-B52-T-M5-1H2L-S_1
08:43:35.956 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping aasx/Documentation/DKI3WebDataSheet_0004.pdf to root folder:
08:43:35.979 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping to /usr/share/files/aasx/Documentation
08:43:36.004 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping aasx/Documentation/DKI3WebDataSheet_0005.pdf to root folder:
08:43:36.005 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping to /usr/share/files/aasx/Documentation
08:43:36.013 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping aasx/Identification/FestoLogo.png to root folder:
08:43:36.015 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping to /usr/share/files/aasx/Identification
08:43:36.016 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping TechnicalData_ZVEI/product_image_00.jpg to root folder:
08:43:36.016 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping to /usr/share/files/TechnicalData_ZVEI
08:43:36.017 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping aasx/Nameplate/CE_Marking_2016.png to root folder:
08:43:36.018 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping to /usr/share/files/aasx/Nameplate
08:43:36.021 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping aasx/files/574226_VUVG-L14-T32C-AT-G18-1R8L.html to root folder:
08:43:36.021 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping to /usr/share/files/aasx/files
08:43:36.026 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping thumbnail.jpg to root folder:
08:43:36.027 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping to /usr/share/files
08:43:36.027 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping aasx/Identification/FestoLogo.png to root folder:
08:43:36.027 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping to /usr/share/files/aasx/Identification
08:43:36.028 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping aasx/Identification/AssetQrCode.png to root folder:
08:43:36.028 [main] INFO org.eclipse.basyx.components.aas.aasx.AASXPackageManager - Unzipping to /usr/share/files/aasx/Identification
08:43:36.029 [main] INFO org.eclipse.basyx.components.aas.AASServerComponent - Using InMemory backend
08:43:37.796 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
08:43:37.805 [main] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
08:43:37.806 [main] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 8
08:43:37.810 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
08:43:37.814 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
08:43:37.815 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
08:43:37.817 [main] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: available
08:43:37.820 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true
08:43:37.820 [main] DEBUG io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9
08:43:37.820 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): available
08:43:37.820 [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
08:43:37.821 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: /tmp (java.io.tmpdir)
08:43:37.821 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
08:43:37.826 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: 464519168 bytes
08:43:37.826 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
08:43:37.829 [main] DEBUG io.netty.util.internal.CleanerJava6 - java.nio.ByteBuffer.cleaner(): available
08:43:37.829 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
08:43:38.246 [main] INFO org.eclipse.basyx.components.aas.AASServerComponent - Start the server
Feb 02, 2022 8:43:38 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-4001"]
Feb 02, 2022 8:43:39 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Feb 02, 2022 8:43:39 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
Feb 02, 2022 8:43:39 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.41
Killed
FrankSchnicke commented 2 years ago

Many thanks for this report. From the log, it looks like it jumps from

INFO: Starting service [Tomcat] Feb 02, 2022 8:43:39 AM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/8.5.41

directly to

Killed

Is there no Exception message or anything similar?

What are the exact steps that lead to this error, does it crash right after registering the AAS at the registry?

HansG89 commented 2 years ago

Thank you for your quick reply

Is there no Exception message or anything similar?

No further exception details in the log

What are the exact steps that lead to this error

I provided kubernetes deployments for the registry and the aas server. The aas server uses a persistent volume, which is basically a volume mount to the host. It contains the aasx file.

When I remove the registry.path form aas.properties the AAS gets successfully registered in the server and I can query it. But as soon as I add the registry.path and point it to a DNS name inside my cluster (e.g. http://aas-registry-service.basys.svc.cluster.local:4000/registry/) the aas server crashes. The funny thing is, that the AAS gets registered before the crash. So when I query my registry, I can see the aas. But there is no further line of code after starting the server

FrankSchnicke commented 2 years ago

Thank you very much for providing further details. We will try to reproduce the issue on our end update the Issue accordingly.

HansG89 commented 2 years ago

Thank you very much for providing further details. We will try to reproduce the issue on our end update the Issue accordingly.

I figured out the problem. It was just an issue in the k8s resource limits. I limited the amount of RAM for the AAS Server to 100Mi which seems to be enough for an empty server without any loaded .aasx file but as soon as the file gots loaded, k8s kills the pod because it exceeds memory limits. So no issue in the application code but a configuration problem. Stupid me!

This is my working config:

AAS Registry

registry-config.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: registry-config
  namespace: basys
data:
  context.properties: |
    contextPath=
    contextHostname=localhost
    contextPort=4000

registry.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: aas-registry
  namespace: basys
  labels:
    app: aas-registry
spec:
  selector:
    matchLabels:
      app: aas-registry
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: aas-registry
    spec:
      containers:
      - name: aas-registry
        image: eclipsebasyx/aas-registry:1.0.4
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
          limits:
            cpu: 100m
            memory: 500Mi
        livenessProbe:
          tcpSocket:
            port: 4000
          initialDelaySeconds: 5
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 3
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /api/v1/registry
            port: 4000
          initialDelaySeconds: 5
          timeoutSeconds: 2
          successThreshold: 1
          failureThreshold: 3
          periodSeconds: 10
        ports:
        - containerPort: 4000
          name: registry-server
        volumeMounts:
        - name: registry-config-volume
          mountPath: /usr/share/config/context.properties
          subPath: context.properties
      volumes:
        - name: registry-config-volume
          configMap:
            name: registry-config
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: aas-registry-service
  namespace: basys
spec:
  type: ClusterIP
  selector:
    app: aas-registry
  ports:
  - name: registry-server-port
    protocol: TCP
    port: 4000
    targetPort: 4000

AAS Server

storage.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: aasx-files-volume
  namespace: basys
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/Users/xxx/aasx-files"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: aasx-files-claim
  namespace: basys
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

aas-server-config.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: aas-server-config
  namespace: basys
data:
  context.properties: |
    contextPath=
    contextHostname=localhost
    contextPort=4001
  aas.properties: |
    aas.backend=InMemory
    aas.source=/usr/share/config/data/demo-aas.aasx
    registry.path=http://aas-registry-service.basys.svc.cluster.local:4000

aas-server.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: aas-server
  namespace: basys
  labels:
    app: aas-server
spec:
  selector:
    matchLabels:
      app: aas-server
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: aas-server
    spec:
      containers:
      - name: aas-server
        image: eclipsebasyx/aas-server:1.0.2
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
          limits:
            cpu: 200m
            memory: 500Mi
        livenessProbe:
          tcpSocket:
            port: 4001
          initialDelaySeconds: 5
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 3
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /shells
            port: 4001
          initialDelaySeconds: 5
          timeoutSeconds: 2
          successThreshold: 1
          failureThreshold: 3
          periodSeconds: 10
        ports:
        - containerPort: 4001
          name: aas-server
        volumeMounts:
        - name: aas-server-config-volume
          mountPath: /usr/share/config/context.properties
          subPath: context.properties
        - name: aas-server-config-volume
          mountPath: /usr/share/config/aas.properties
          subPath: aas.properties
        - mountPath: /usr/share/config/data
          name: aasx-files-storage
      volumes:
        - name: aas-server-config-volume
          configMap:
            name: aas-server-config
        - name: aasx-files-storage
          persistentVolumeClaim:
            claimName: aasx-files-claim
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: aas-server-service
  namespace: basys
spec:
  type: ClusterIP
  selector:
    app: aas-server
  ports:
  - name: aas-server-port
    protocol: TCP
    port: 4001
    targetPort: 4001
FrankSchnicke commented 2 years ago

I'm happy that you could solve this issue. Many thanks also for providing your Kubernetes config!