Install on OpenShift fail with invalid memory address

I am trying to deploy on OpenShift

The pod is able to connect to the external database and creates tables in it but then crashes

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa3707d]

goroutine 1 [running]:
github.com/sony/sonyflake.(*Sonyflake).NextID(0x0)

github.com/cortezaproject/corteza-server/app/cli.go:141
main.main()
./main.go:13 +0x27

Do you have any suggestions on why I would be getting this error?

1 Like

Here is the deployment

kind: Deployment
apiVersion: apps/v1
metadata:
  name: corteza-server
  namespace: esa-corteza-sbx
  labels:
    app: corteza-server
    app.kubernetes.io/component: corteza-server
    app.kubernetes.io/instance: corteza-server
    app.kubernetes.io/name: corteza-server
    app.kubernetes.io/part-of: corteza-server
    app.openshift.io/runtime-namespace: esa-corteza-sbx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: corteza-server
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: corteza-server
        deploymentconfig: corteza-server
      annotations:
        openshift.io/generated-by: OpenShiftWebConsole
    spec:
      volumes:
        - name: corteza-server-1
          emptyDir: {}
      containers:
        - resources:
            limits:
              memory: 1Gi
          terminationMessagePath: /dev/termination-log
          name: corteza-server
          env:
            - name: DB_DSN
              value: >-
                postgres://corteza:corteza@remotehost:5432/corteza
            - name: DOMAIN
              value: corteza-server-esa-corteza-sbx.apps.sbxocp.amerhonda.com
            - name: HTTP_ADDR
              value: ':8080'
            - name: LOG_DEBUG
              value: 'true'
          ports:
            - containerPort: 8080
              protocol: TCP
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: corteza-server-1
              mountPath: /data
          terminationMessagePolicy: File
          image: >-
            cortezaproject/corteza-server:2022.9.2
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext: {}
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600

Could be this: sonyflake causing crash on startup · Issue #15 · cortezaproject/corteza-server · GitHub

I wanted to thank you for the quick response and code fix. I was able to get it to work on OpenShift by adding SONYFLAKE_MACHINE_ID environment variable. For others here is a sample deployment

kind: Deployment
apiVersion: apps/v1
metadata:
  name: corteza-server
  labels:
    app: corteza-server
    app.kubernetes.io/component: corteza-server
    app.kubernetes.io/instance: corteza-server
    app.kubernetes.io/name: corteza-server
    app.kubernetes.io/part-of: corteza-server
    app.openshift.io/runtime-namespace: esa-corteza-sbx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: corteza-server
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: corteza-server
        deploymentconfig: corteza-server
      annotations:
        openshift.io/generated-by: OpenShiftWebConsole
    spec:
      volumes:
        - name: corteza-server-1
          emptyDir: {}
      containers:
        - resources:
            limits:
              memory: 1Gi
          terminationMessagePath: /dev/termination-log
          name: corteza-server
          env:
            - name: DB_DSN
              value: >-
                postgres://corteza:corteza@remotehost:5432/corteza
            - name: DOMAIN
              value: corteza.example.domain.com
            - name: HTTP_ADDR
              value: ':8080'
            - name: ACTIONLOG_DEBUG
              value: 'true'
            - name: LOG_DEBUG
              value: 'true'
            - name: LOG_LEVEL
              value: debug
            - name: SONYFLAKE_MACHINE_ID
              value: '1'
            - name: HTTP_WEBAPP_ENABLED
              value: 'true'
            - name: VIRTUAL_HOST
              value: corteza.example.domain.com
          ports:
            - containerPort: 8080
              protocol: TCP
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: corteza-server-1
              mountPath: /data
          terminationMessagePolicy: File
          image: >-
            cortezaproject/corteza:2022.9.3
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext: {}
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600
1 Like