WSO2 Identity Server Shutdown hook triggered

Viewed 73

I am trying to launch WSO2 Identity server using helm and server shutdowns abruptly after MAILTO sender is started.

I am following wso2 documentation here for setting up using helm.

The sql server and everything gets started fine. When I look in the logs for identity server pod, the trace shows an error where shutdown hook is initiated. There is no other information regarding the reason behind.

Following is the helm chart being used for deploying the server:

kind: StatefulSet
metadata:
  name: wso2is-pattern-1-identity-server-statefulset
  namespace: wso2local
  uid: c00d52bc-d099-488b-9ff9-69cb7fbf7a99
  resourceVersion: '76433'
  generation: 5
  creationTimestamp: '2022-09-01T10:03:30Z'
  labels:
    app.kubernetes.io/managed-by: Helm
  annotations:
    meta.helm.sh/release-name: wso2-test
    meta.helm.sh/release-namespace: wso2local
  managedFields:
    - manager: helm
      operation: Update
      apiVersion: apps/v1
      time: '2022-09-01T10:03:30Z'
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            .: {}
            f:meta.helm.sh/release-name: {}
            f:meta.helm.sh/release-namespace: {}
          f:labels:
            .: {}
            f:app.kubernetes.io/managed-by: {}
        f:spec:
          f:podManagementPolicy: {}
          f:replicas: {}
          f:revisionHistoryLimit: {}
          f:selector: {}
          f:serviceName: {}
          f:template:
            f:metadata:
              f:annotations:
                .: {}
                f:checksum.is.bin: {}
                f:checksum.is.conf: {}
              f:labels:
                .: {}
                f:deployment: {}
                f:monitoring: {}
            f:spec:
              f:containers:
                k:{"name":"identity-server"}:
                  .: {}
                  f:env:
                    .: {}
                    k:{"name":"JVM_MEM_OPTS"}:
                      .: {}
                      f:name: {}
                      f:value: {}
                    k:{"name":"NODE_IP"}:
                      .: {}
                      f:name: {}
                      f:valueFrom:
                        .: {}
                        f:fieldRef: {}
                  f:image: {}
                  f:imagePullPolicy: {}
                  f:lifecycle:
                    .: {}
                    f:preStop:
                      .: {}
                      f:exec:
                        .: {}
                        f:command: {}
                  f:livenessProbe:
                    .: {}
                    f:failureThreshold: {}
                    f:httpGet:
                      .: {}
                      f:path: {}
                      f:port: {}
                      f:scheme: {}
                    f:periodSeconds: {}
                    f:successThreshold: {}
                  f:name: {}
                  f:ports:
                    .: {}
                    k:{"containerPort":9443,"protocol":"TCP"}:
                      .: {}
                      f:containerPort: {}
                      f:protocol: {}
                    k:{"containerPort":9763,"protocol":"TCP"}:
                      .: {}
                      f:containerPort: {}
                      f:protocol: {}
                  f:readinessProbe:
                    .: {}
                    f:failureThreshold: {}
                    f:httpGet:
                      .: {}
                      f:path: {}
                      f:port: {}
                      f:scheme: {}
                    f:periodSeconds: {}
                    f:successThreshold: {}
                  f:resources:
                    .: {}
                    f:limits:
                      .: {}
                      f:cpu: {}
                      f:memory: {}
                    f:requests:
                      .: {}
                      f:cpu: {}
                      f:memory: {}
                  f:securityContext:
                    .: {}
                    f:runAsUser: {}
                  f:startupProbe:
                    .: {}
                    f:exec:
                      .: {}
                      f:command: {}
                    f:failureThreshold: {}
                    f:periodSeconds: {}
                    f:successThreshold: {}
                    f:timeoutSeconds: {}
                  f:terminationMessagePath: {}
                  f:terminationMessagePolicy: {}
                  f:volumeMounts:
                    .: {}
                    k:{"mountPath":"/home/wso2carbon/wso2-artifact-volume/repository/components/dropins"}:
                      .: {}
                      f:mountPath: {}
                      f:name: {}
                    k:{"mountPath":"/home/wso2carbon/wso2-config-volume/bin"}:
                      .: {}
                      f:mountPath: {}
                      f:name: {}
                    k:{"mountPath":"/home/wso2carbon/wso2-config-volume/repository/conf/deployment.toml"}:
                      .: {}
                      f:mountPath: {}
                      f:name: {}
                      f:subPath: {}
              f:dnsPolicy: {}
              f:initContainers:
                .: {}
                k:{"name":"init-is-db"}:
                  .: {}
                  f:command: {}
                  f:image: {}
                  f:imagePullPolicy: {}
                  f:name: {}
                  f:resources: {}
                  f:terminationMessagePath: {}
                  f:terminationMessagePolicy: {}
                k:{"name":"init-mysql-connector-download"}:
                  .: {}
                  f:command: {}
                  f:image: {}
                  f:imagePullPolicy: {}
                  f:name: {}
                  f:resources: {}
                  f:terminationMessagePath: {}
                  f:terminationMessagePolicy: {}
                  f:volumeMounts:
                    .: {}
                    k:{"mountPath":"/mysql-connector-jar"}:
                      .: {}
                      f:mountPath: {}
                      f:name: {}
              f:restartPolicy: {}
              f:schedulerName: {}
              f:securityContext: {}
              f:serviceAccount: {}
              f:serviceAccountName: {}
              f:terminationGracePeriodSeconds: {}
              f:volumes:
                .: {}
                k:{"name":"identity-server-bin"}:
                  .: {}
                  f:configMap:
                    .: {}
                    f:defaultMode: {}
                    f:name: {}
                  f:name: {}
                k:{"name":"identity-server-conf"}:
                  .: {}
                  f:configMap:
                    .: {}
                    f:defaultMode: {}
                    f:name: {}
                  f:name: {}
                k:{"name":"mysql-connector-jar"}:
                  .: {}
                  f:emptyDir: {}
                  f:name: {}
          f:updateStrategy:
            f:rollingUpdate:
              .: {}
              f:partition: {}
            f:type: {}
    - manager: kube-controller-manager
      operation: Update
      apiVersion: apps/v1
      time: '2022-09-01T10:12:48Z'
      fieldsType: FieldsV1
      fieldsV1:
        f:status:
          f:collisionCount: {}
          f:currentReplicas: {}
          f:currentRevision: {}
          f:observedGeneration: {}
          f:replicas: {}
          f:updateRevision: {}
      subresource: status
    - manager: node-fetch
      operation: Update
      apiVersion: apps/v1
      time: '2022-09-01T11:22:16Z'
      fieldsType: FieldsV1
      fieldsV1:
        f:spec:
          f:template:
            f:spec:
              f:containers:
                k:{"name":"identity-server"}:
                  f:livenessProbe:
                    f:timeoutSeconds: {}
                  f:readinessProbe:
                    f:initialDelaySeconds: {}
                    f:timeoutSeconds: {}
                  f:startupProbe:
                    f:initialDelaySeconds: {}
  selfLink: >-
    /apis/apps/v1/namespaces/wso2local/statefulsets/wso2is-pattern-1-identity-server-statefulset
status:
  observedGeneration: 5
  replicas: 1
  currentReplicas: 1
  currentRevision: wso2is-pattern-1-identity-server-statefulset-64cc67fc85
  updateRevision: wso2is-pattern-1-identity-server-statefulset-57c444f47c
  collisionCount: 0
  availableReplicas: 0
spec:
  replicas: 2
  selector:
    matchLabels:
      deployment: wso2is
      monitoring: jmx
  template:
    metadata:
      creationTimestamp: null
      labels:
        deployment: wso2is
        monitoring: jmx
      annotations:
        checksum.is.bin: cb0616cf02f9ede88abc214692596be0481794ba7c6437b96b5665949ba030eb
        checksum.is.conf: a108b1792060c91aa6424fadc6626ea97c7b669be0fd05978a02fb89f0f2a537
    spec:
      volumes:
        - name: identity-server-conf
          configMap:
            name: wso2is-pattern-1-identity-server-conf
            defaultMode: 420
        - name: identity-server-bin
          configMap:
            name: wso2is-pattern-1-identity-server-bin
            defaultMode: 420
        - name: mysql-connector-jar
          emptyDir: {}
      initContainers:
        - name: init-is-db
          image: busybox:1.31
          command:
            - sh
            - '-c'
            - >-
              echo -e "Checking for the availability of MySQL Server
              deployment"; while ! nc -z wso2is-mysql-db-service 3306; do sleep
              1; printf "-"; done; echo -e "  >> MySQL Server has started";
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
        - name: init-mysql-connector-download
          image: busybox:1.32
          command:
            - /bin/sh
            - '-c'
            - >
              set -e

              connector_version=8.0.17

              wget
              https://repo1.maven.org/maven2/mysql/mysql-connector-java/${connector_version}/mysql-connector-java-${connector_version}.jar
              -P /mysql-connector-jar/
          resources: {}
          volumeMounts:
            - name: mysql-connector-jar
              mountPath: /mysql-connector-jar
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      containers:
        - name: identity-server
          image: wso2/wso2is:5.11.0
          ports:
            - containerPort: 9763
              protocol: TCP
            - containerPort: 9443
              protocol: TCP
          env:
            - name: NODE_IP
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: status.podIP
            - name: JVM_MEM_OPTS
              value: '-Xms1024m -Xmx2048m'
          resources:
            limits:
              cpu: '2'
              memory: 4Gi
            requests:
              cpu: '1'
              memory: 2Gi
          volumeMounts:
            - name: identity-server-conf
              mountPath: >-
                /home/wso2carbon/wso2-config-volume/repository/conf/deployment.toml
              subPath: deployment.toml
            - name: identity-server-bin
              mountPath: /home/wso2carbon/wso2-config-volume/bin
            - name: mysql-connector-jar
              mountPath: >-
                /home/wso2carbon/wso2-artifact-volume/repository/components/dropins
          livenessProbe:
            httpGet:
              path: /carbon/admin/login.jsp
              port: 9443
              scheme: HTTPS
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /api/health-check/v1.0/health
              port: 9443
              scheme: HTTPS
            initialDelaySeconds: 100
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          startupProbe:
            exec:
              command:
                - /bin/sh
                - '-c'
                - nc -z localhost 9443
            initialDelaySeconds: 300
            timeoutSeconds: 1
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 30
          lifecycle:
            preStop:
              exec:
                command:
                  - sh
                  - '-c'
                  - ${WSO2_SERVER_HOME}/bin/wso2server.sh stop
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: Always
          securityContext:
            runAsUser: 802
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: wso2is-pattern-1-svc-account
      serviceAccount: wso2is-pattern-1-svc-account
      securityContext: {}
      schedulerName: default-scheduler
  serviceName: wso2is-pattern-1-identity-service
  podManagementPolicy: OrderedReady
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      partition: 0
  revisionHistoryLimit: 10

Here is the logs trace:

[2022-09-01 11:26:49,499] []  INFO {org.wso2.carbon.humantask.deployer.HumanTaskDeployer} - Initializing HumanTask Deployer for tenant -1234.
[2022-09-01 11:26:49,581] []  INFO {org.apache.axis2.transport.mail.MailTransportSender} - MAILTO Sender started
[2022-09-01 11:26:56,787] []  INFO {org.wso2.carbon.core.init.CarbonServerManager} - Shutdown hook triggered....
[2022-09-01 11:26:56,782] []  INFO {org.wso2.carbon.bpel.core.internal.BPELServiceComponent} - Shutting down BPEL Server........
[2022-09-01 11:26:57,055] []  INFO {org.apache.ode.bpel.engine.BpelServerImpl} - BPEL Server Stopped.
[2022-09-01 11:26:57,077] []  INFO {org.wso2.carbon.core.init.CarbonServerManager} - Gracefully shutting down WSO2 Identity Server...
[2022-09-01 11:26:57,143] []  INFO {org.wso2.carbon.core.ServerManagement} - Starting to switch to maintenance mode...
[2022-09-01 11:26:57,152] []  INFO {org.wso2.carbon.core.ServerManagement} - Stopped all transport listeners
[2022-09-01 11:26:57,155] []  INFO {org.wso2.carbon.core.ServerManagement} - Waiting for request service completion...
[2022-09-01 11:26:57,180] []  INFO {org.wso2.carbon.bpel.core.ode.integration.BPELServerImpl} - BPEL Server shutdown completed.
[2022-09-01 11:26:57,191] []  INFO {org.wso2.carbon.core.ServerManagement} - All requests have been served.
[2022-09-01 11:26:57,193] []  INFO {org.wso2.carbon.core.ServerManagement} - Waiting for deployment completion...
[2022-09-01 11:26:57,253] []  INFO {org.wso2.carbon.core.ServerManagement} - All deployment tasks have been completed.
[2022-09-01 11:26:57,255] []  INFO {org.wso2.carbon.core.ServerManagement} - Waiting for server task completion...
[2022-09-01 11:26:57,271] []  INFO {org.wso2.carbon.registry.core.internal.RegistryCoreServiceComponent} - Writing logs 
[2022-09-01 11:26:57,486] []  INFO {org.wso2.carbon.humantask.core.HumanTaskServerShutdown} - Shutting down human task scheduler
[2022-09-01 11:26:57,540] []  INFO {org.wso2.carbon.core.ServerManagement} - All server tasks have been completed.
[2022-09-01 11:26:57,542] []  INFO {org.wso2.carbon.core.init.CarbonServerManager} - Shutting down WSO2 Identity Server...
[2022-09-01 11:26:57,987] []  INFO {org.wso2.carbon.core.init.CarbonServerManager} - Shutting down OSGi framework...
[2022-09-01 11:26:58,142]  INFO {org.wso2.carbon.core.init.CarbonServerManager} - Shutdown complete 
1 Answers

For the container, the lifecycle hook is defined as follows. Based on the shared data it seems the container has not started within the time interval and it has triggered the lifecycle hook.

 lifecycle:
            preStop:
              exec:
                command:
                  - sh
                  - '-c'
                  - ${WSO2_SERVER_HOME}/bin/wso2server.sh stop

You can remove the probes and let the container start first or else you can adjust the probe configurations as well.

Related