Skip to content

Commit 1a85468

Browse files
bramweltclaude
andcommitted
fix(LFXV2-1698): address PR #36 review comments
- Convert Job and ConfigMap to Helm hooks (post-install/post-upgrade) with before-hook-creation,hook-succeeded delete policy; ConfigMap uses weight 0, Job uses weight 1 to ensure ordering - Add securityContext.allowPrivilegeEscalation: false to Job container - Remove AUTH_OPTS shell variable; inline credentials directly as -u "${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD}" to avoid unquoted variable expansion - Fix nindent formatting in ConfigMap to remove leading whitespace before Files.Get template call 🤖 Generated with [Claude Code](https://claude.com/claude-code) Issue: LFXV2-1698 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
1 parent 8971941 commit 1a85468

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

charts/lfx-v2-indexer-service/templates/indexing-configmap.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ kind: ConfigMap
77
metadata:
88
name: {{ .Release.Name }}-opensearch-index-config
99
namespace: {{ .Release.Namespace }}
10+
annotations:
11+
"helm.sh/hook": post-install,post-upgrade
12+
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
13+
"helm.sh/hook-weight": "0"
1014
data:
1115
resources-index.json: |
12-
{{ .Files.Get "files/opensearch-resources-index.json" | nindent 4 }}
16+
{{- .Files.Get "files/opensearch-resources-index.json" | nindent 4 }}
1317
{{- end }}

charts/lfx-v2-indexer-service/templates/job.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ kind: Job
88
metadata:
99
name: {{ .Release.Name }}-opensearch-index-setup
1010
namespace: {{ .Release.Namespace }}
11+
annotations:
12+
"helm.sh/hook": post-install,post-upgrade
13+
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
14+
"helm.sh/hook-weight": "1"
1115
spec:
1216
ttlSecondsAfterFinished: {{ $job.ttlSecondsAfterFinished }}
1317
backoffLimit: {{ $job.backoffLimit }}
@@ -50,6 +54,8 @@ spec:
5054
value: {{ .Values.opensearch.auth.password | quote }}
5155
{{- end }}
5256
{{- end }}
57+
securityContext:
58+
allowPrivilegeEscalation: false
5359
volumeMounts:
5460
- name: index-config
5561
mountPath: /config
@@ -61,19 +67,16 @@ spec:
6167
set -e
6268
OPENSEARCH_URL="{{ .Values.opensearch.url | trimSuffix "/" }}"
6369
INDEX_NAME="{{ .Values.opensearch.index }}"
64-
{{- if .Values.opensearch.auth.enabled }}
65-
AUTH_OPTS="-u ${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD}"
66-
{{- end }}
6770
6871
# Check if index already exists
69-
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" {{ if .Values.opensearch.auth.enabled }}${AUTH_OPTS} {{ end }}--head "${OPENSEARCH_URL}/${INDEX_NAME}")
72+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" {{ if .Values.opensearch.auth.enabled }}-u "${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD}" {{ end }}--head "${OPENSEARCH_URL}/${INDEX_NAME}")
7073
7174
if [ "$HTTP_CODE" = "200" ]; then
7275
echo "Index '${INDEX_NAME}' already exists, skipping creation"
7376
exit 0
7477
elif [ "$HTTP_CODE" = "404" ]; then
7578
echo "Index '${INDEX_NAME}' does not exist, creating..."
76-
curl -f {{ if .Values.opensearch.auth.enabled }}${AUTH_OPTS} {{ end }}-X PUT "${OPENSEARCH_URL}/${INDEX_NAME}" \
79+
curl -f {{ if .Values.opensearch.auth.enabled }}-u "${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD}" {{ end }}-X PUT "${OPENSEARCH_URL}/${INDEX_NAME}" \
7780
-H 'Content-Type: application/json' \
7881
-d @/config/resources-index.json
7982
echo "Index '${INDEX_NAME}' created successfully"

0 commit comments

Comments
 (0)