EDGEPOD-85 Add ability to enable coredump for OMEC apps
Core files will be generated when config.coreDump.enabled is set to
true. Path of the generated core files can be configured by setting
config.coreDump.path, which is set to /tmp/coredump by default.
Change-Id: I5149751ba091a1f49e2eee91a14889898301a7bf
diff --git a/omec/omec-data-plane/Chart.yaml b/omec/omec-data-plane/Chart.yaml
index 0cf088f..e20e7bf 100644
--- a/omec/omec-data-plane/Chart.yaml
+++ b/omec/omec-data-plane/Chart.yaml
@@ -19,4 +19,4 @@
name: omec-data-plane
icon: https://guide.opencord.org/logos/cord.svg
-version: 0.1.9
+version: 0.1.10
diff --git a/omec/omec-data-plane/templates/_helpers.tpl b/omec/omec-data-plane/templates/_helpers.tpl
index af69c64..24733ea 100644
--- a/omec/omec-data-plane/templates/_helpers.tpl
+++ b/omec/omec-data-plane/templates/_helpers.tpl
@@ -34,3 +34,23 @@
{{- $wtf := $context.Template.Name | replace $last $name -}}
{{ include $wtf $context }}
{{- end -}}
+
+{{/*
+Render init container for coredump.
+*/}}
+{{- define "omec-data-plane.coredump_init" -}}
+{{- $pod := index . 0 -}}
+{{- $context := index . 1 -}}
+- name: {{ $pod }}-coredump-init
+ image: {{ $context.Values.images.tags.init | quote }}
+ imagePullPolicy: {{ $context.Values.images.pullPolicy }}
+ securityContext:
+ privileged: true
+ runAsUser: 0
+ command: ["bash", "-xc"]
+ args:
+ - echo '/tmp/coredump/core.%h.%e.%t' > /mnt/host-rootfs/proc/sys/kernel/core_pattern
+ volumeMounts:
+ - name: host-rootfs
+ mountPath: /mnt/host-rootfs
+{{- end -}}
diff --git a/omec/omec-data-plane/templates/bin/_spgwu-run.sh.tpl b/omec/omec-data-plane/templates/bin/_spgwu-run.sh.tpl
index ff0e476..3d77d81 100644
--- a/omec/omec-data-plane/templates/bin/_spgwu-run.sh.tpl
+++ b/omec/omec-data-plane/templates/bin/_spgwu-run.sh.tpl
@@ -17,6 +17,10 @@
set -ex
+{{- if .Values.config.coreDump.enabled }}
+cp /bin/ngic_dataplane /tmp/coredump/
+{{- end }}
+
mkdir -p /opt/dp/config
cd /opt/dp/config
cp /etc/dp/config/{cdr.cfg,dp_config.cfg,interface.cfg} .
diff --git a/omec/omec-data-plane/templates/statefulset-spgwu.yaml b/omec/omec-data-plane/templates/statefulset-spgwu.yaml
index 35b6304..f3452d4 100644
--- a/omec/omec-data-plane/templates/statefulset-spgwu.yaml
+++ b/omec/omec-data-plane/templates/statefulset-spgwu.yaml
@@ -75,10 +75,21 @@
mountPath: /opt/dp/scripts/setup-af-iface.sh
subPath: setup-af-iface.sh
{{- end }}
+ {{- if .Values.config.coreDump.enabled }}
+{{ tuple "spgwc" . | include "omec-data-plane.coredump_init" | indent 8 }}
+ {{- end }}
containers:
- name: spgwu
image: {{ .Values.images.tags.spgwu | quote }}
imagePullPolicy: {{ .Values.images.pullPolicy | quote }}
+ securityContext:
+ {{- if .Values.config.coreDump.enabled }}
+ privileged: true
+ runAsUser: 0
+ {{- end }}
+ capabilities:
+ add:
+ - IPC_LOCK
stdin: true
tty: true
env:
@@ -104,6 +115,10 @@
subPath: run.sh
- name: dp-config
mountPath: /etc/dp/config
+ {{- if .Values.config.coreDump.enabled }}
+ - name: coredump
+ mountPath: /tmp/coredump
+ {{- end }}
resources:
requests:
{{- if .Values.resources.enabled }}
@@ -119,10 +134,6 @@
{{- if .Values.config.sriov.enabled }}
intel.com/sriov_vfio: 2
{{- end }}
- securityContext:
- capabilities:
- add:
- - IPC_LOCK
volumes:
- name: dp-script
configMap:
@@ -132,3 +143,11 @@
configMap:
name: spgwu
defaultMode: 420
+ {{- if .Values.config.coreDump.enabled }}
+ - name: host-rootfs
+ hostPath:
+ path: /
+ - name: coredump
+ hostPath:
+ path: {{ .Values.config.coreDump.path }}
+ {{- end }}
diff --git a/omec/omec-data-plane/values.yaml b/omec/omec-data-plane/values.yaml
index b1cb1fd..7c0a8b8 100644
--- a/omec/omec-data-plane/values.yaml
+++ b/omec/omec-data-plane/values.yaml
@@ -38,6 +38,9 @@
memory: 8Gi
config:
+ coreDump:
+ enabled: false
+ path: /tmp/coredump
sriov:
enabled: true
spgwu: