Skip to content

Commit

Permalink
fix: Avoid CrashLoop when keystore secret has no data
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Hobbs <timothy.hobbs@servicelayers.com>
  • Loading branch information
hobti01 committed Jun 21, 2023
1 parent 6c202a2 commit 0b243d1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
14 changes: 12 additions & 2 deletions charts/opensearch/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security
---
## [1.20.3]
### Added
- Avoid CrashLoop when keystore secret has no data
### Changed
### Deprecated
### Removed
### Fixed
### Security
---
## [1.20.2]
### Added
- Support string type for extraObjects
Expand Down Expand Up @@ -307,7 +316,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated
### Removed
### Fixed
- Fixed `image.pullPolicy` Helm value not setting the `imagePullPolicy` for the "opensearch" container
- Fixed `image.pullPolicy` Helm value not setting the `imagePullPolicy` for the "opensearch" container
### Security
---
## [1.7.0]
Expand Down Expand Up @@ -600,7 +609,8 @@ config:
### Fixed
### Security

[Unreleased]: https://github.com/opensearch-project/helm-charts/compare/opensearch-1.20.2...HEAD
[Unreleased]: https://github.com/opensearch-project/helm-charts/compare/opensearch-1.20.3...HEAD
[1.20.3]: https://github.com/opensearch-project/helm-charts/compare/opensearch-1.20.2...opensearch-1.20.3
[1.20.2]: https://github.com/opensearch-project/helm-charts/compare/opensearch-1.20.1...opensearch-1.20.2
[1.20.1]: https://github.com/opensearch-project/helm-charts/compare/opensearch-1.20.0...opensearch-1.20.1
[1.20.0]: https://github.com/opensearch-project/helm-charts/compare/opensearch-1.19.2...opensearch-1.20.0
Expand Down
2 changes: 1 addition & 1 deletion charts/opensearch/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.20.2
version: 1.20.3

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
23 changes: 12 additions & 11 deletions charts/opensearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ spec:
- name: keystore-{{ .secretName }}
secret: {{ toYaml . | nindent 12 }}
{{- end }}
{{ end }}
{{- end }}
{{- if .Values.extraVolumes }}
# Currently some extra blocks accept strings
# to continue with backwards compatibility this is being kept
Expand Down Expand Up @@ -237,8 +237,8 @@ spec:
- 'chown -R 1000:1000 /usr/share/opensearch/data'
securityContext:
runAsUser: 0
resources:
{{ toYaml .Values.initResources | nindent 10 }}
resources:
{{- toYaml .Values.initResources | nindent 10 }}
volumeMounts:
- name: "{{ template "opensearch.uname" . }}"
mountPath: {{ .Values.opensearchHome }}/data
Expand All @@ -261,9 +261,9 @@ spec:
runAsUser: 0
privileged: true
resources:
{{ toYaml .Values.initResources | nindent 10 }}
{{- toYaml .Values.initResources | nindent 10 }}
{{- end }}
{{ if .Values.keystore }}
{{- if .Values.keystore }}
- name: keystore
image: "{{ template "opensearch.dockerRegistry" . }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
Expand All @@ -277,6 +277,7 @@ spec:
{{ .Values.opensearchHome }}/bin/opensearch-keystore create
for i in /tmp/keystoreSecrets/*/*; do
[ -f "$i" ] || continue
key=$(basename $i)
echo "Adding file $i to keystore key $key"
{{ .Values.opensearchHome }}/bin/opensearch-keystore add-file "$key" "$i"
Expand All @@ -291,16 +292,16 @@ spec:
cp -a {{ .Values.opensearchHome }}/config/opensearch.keystore /tmp/keystore/
env: {{ toYaml .Values.extraEnvs | nindent 10 }}
envFrom: {{ toYaml .Values.envFrom | nindent 10 }}
resources:
{{ toYaml .Values.initResources | nindent 10 }}
resources:
{{- toYaml .Values.initResources | nindent 10 }}
volumeMounts:
- name: keystore
mountPath: /tmp/keystore
{{- range .Values.keystore }}
- name: keystore-{{ .secretName }}
mountPath: /tmp/keystoreSecrets/{{ .secretName }}
{{- end }}
{{ end }}
{{- end }}
{{- if .Values.extraInitContainers }}
# Currently some extra blocks accept strings
# to continue with backwards compatibility this is being kept
Expand Down Expand Up @@ -330,7 +331,7 @@ spec:
bash opensearch-docker-entrypoint.sh
{{- end }}

image: "{{ template "opensearch.dockerRegistry" . }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
readinessProbe:
Expand All @@ -357,7 +358,7 @@ spec:
- name: metrics
containerPort: {{ .Values.metricsPort }}
resources:
{{ toYaml .Values.resources | indent 10 }}
{{- toYaml .Values.resources | nindent 10 }}
env:
- name: node.name
valueFrom:
Expand Down Expand Up @@ -513,7 +514,7 @@ spec:
sleep infinity &
wait $!
resources:
{{ toYaml .Values.sidecarResources | indent 10 }}
{{- toYaml .Values.sidecarResources | nindent 10 }}
env:
- name: NODE_NAME
valueFrom:
Expand Down

0 comments on commit 0b243d1

Please sign in to comment.