Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upgrade label issue with latest bitnami chart (CASMPET-6831) #36

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/cray-etcd-base/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#
apiVersion: v2
name: cray-etcd-base
version: 1.1.0
version: 1.1.1
description: This chart should never be installed directly, instead it is intended to be a sub-chart.
home: https://github.com/Cray-HPE/cray-etcd
dependencies:
Expand Down
34 changes: 30 additions & 4 deletions charts/cray-etcd-base/templates/migration-jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,38 @@ spec:
chown -R 1001:1001 $snapshot_dir
ns={{ .Release.Namespace }}
cluster="{{ include "cray-etcd-base.fullname" . }}"
ss_name="${cluster}-bitnami-etcd"

if ! kubectl get endpoints ${cluster}-etcd-client -n ${ns} -o json > /dev/null 2>&1 ; then
#
# There is no old etcd-operator managed chart installed, let's see if this
# is a fresh install or upgrade.
#
has_label=$(kubectl get statefulsets.apps -n services -l 'app.kubernetes.io/component=etcd' --no-headers 2>/dev/null | awk "/${ss_name}/")
if [ -n "$has_label" ]; then
#
# The new label has already been applied, we don't need to do
# anything special here.
#
echo "The 'app.kubernetes.io/component=etcd' label has already been applied to ${ss_name}, continuing..."
exit 0
fi

kubectl get endpoints ${cluster}-etcd-client -n ${ns} -o json > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "${cluster}-etcd-client not found, assuming upgrade to bitnami chart has been completed..."
exit 0
members=$(kubectl get pod -n $ns -o wide -o=custom-columns=NAME:.metadata.name | awk "/${ss_name}/ && !/snapshotter|defrag/")
if [ -n "$members" ]; then
echo "Ensuring ${ss_name} members have 'app.kubernetes.io/component=etcd' label for bitnami 9.x chart upgrade..."
for member in ${members}; do
echo "Adding label to ${member}"
kubectl label pod -n ${ns} ${member} app.kubernetes.io/component=etcd --overwrite
done
echo "Deleting statefulset for ${ss_name} allowing K8S to recreate"
kubectl delete statefulset -n ${ns} ${ss_name} --cascade=orphan
else
echo "No previous installations detected requiring special handling..."
fi
exit 0
fi

echo "${cluster}-etcd-client found, proceeding with migrating current data..."

cat > /tmp/upload-snapshot.py <<EOF
Expand Down
2 changes: 1 addition & 1 deletion charts/cray-etcd-test/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies:
version: "~10.0.0"
repository: https://artifactory.algol60.net/artifactory/csm-helm-charts
- name: cray-etcd-base
version: "~1.0.0"
version: "~1.1.0"
repository: https://artifactory.algol60.net/artifactory/csm-helm-charts
description: "Test etcd chart"
home: "https://github.com/Cray-HPE/cray-etcd-test"
Expand Down
Loading