Skip to content

Commit 685f825

Browse files
authored
Merge pull request #8 from thirdgen88/backport-fixes
Backport fixes from 0.2.x branch
2 parents 4f10628 + 9b17e33 commit 685f825

4 files changed

Lines changed: 46 additions & 12 deletions

File tree

ignition/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fixed an issue where `podLabels` were incorrectly applied to StatefulSet metadata instead of pod metadata.
13+
1014
### Changed
1115

1216
- Bumped _appVersion_ for Ignition to 8.1.53.
17+
- Modified the redundant health check script to accept some additional states to facilitate better automated upgrades.
1318

1419
## [0.1.0] - 2025-09-07
1520

ignition/scripts/redundant-health-check.sh

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ port=${GATEWAY_HTTP_PORT:-8088}
1212
status_endpoint="http://localhost:${port}/system/gwinfo"
1313
timeout_secs=3
1414
expected_context_state=RUNNING
15-
expected_redundant_state=Good
15+
expected_redundant_states=(Good OutOfDate Incompatible)
1616

1717
###############################################################################
1818
# Invoke a Redundancy-aware Health Check
@@ -23,7 +23,7 @@ function main() {
2323
exit 1
2424
fi
2525

26-
debug "Status endpoint: ${status_endpoint}, expecting context state: ${expected_context_state}, expecting redundant state: ${expected_redundant_state}, timeout: ${timeout_secs}."
26+
debug "Status endpoint: ${status_endpoint}, expecting context state: ${expected_context_state}, expecting redundant states: [${expected_redundant_states[*]}], timeout: ${timeout_secs}."
2727

2828
curl_output=$(curl -s --max-time "${timeout_secs}" -L -k -f "${status_endpoint}" 2>&1)
2929

@@ -43,17 +43,32 @@ function main() {
4343
echo "FAILED: ContextStatus is ${gwinfo_fields[ContextStatus]}, expected ${expected_context_state}" >&2
4444
exit 1
4545
fi
46-
elif [ "${gwinfo_fields[RedundantState]}" != "${expected_redundant_state}" ]; then
46+
elif ! validate_redundant_state "${gwinfo_fields[RedundantState]}"; then
4747
# Check RedundantNodeActiveStatus field
4848
if [ "${gwinfo_fields[RedundantNodeActiveStatus]}" != "Active" ]; then
49-
echo "FAILED: Not Active and RedundantState is ${gwinfo_fields[RedundantState]}, expected ${expected_redundant_state}" >&2
49+
echo "FAILED: Not Active and RedundantState is ${gwinfo_fields[RedundantState]}, expected one of: [${expected_redundant_states[*]}]" >&2
5050
exit 1
5151
fi
5252
fi
5353
debug "SUCCESS"
5454
exit 0
5555
}
5656

57+
###############################################################################
58+
# Validate redundant state against expected states
59+
###############################################################################
60+
function validate_redundant_state() {
61+
local actual_state="$1"
62+
63+
for expected_state in "${expected_redundant_states[@]}"; do
64+
if [ "${actual_state,,}" = "${expected_state,,}" ]; then
65+
return 0
66+
fi
67+
done
68+
69+
return 1
70+
}
71+
5772
###############################################################################
5873
# Outputs to stderr
5974
###############################################################################
@@ -70,23 +85,29 @@ function debug() {
7085
function usage() {
7186
# usage redundant-health-check.sh
7287
>&2 echo "Usage: $0 [flags] STATUS_ENDPOINT"
73-
>&2 echo "Example: ./redundant-health-check.sh -r Good -s RUNNING http://localhost:8088/system/gwinfo"
88+
>&2 echo "Example: ./redundant-health-check.sh -s RUNNING http://localhost:8088/system/gwinfo"
7489
>&2 echo "Flags:"
75-
>&2 echo " -r <state> - Expected redundant state (default: Good)"
76-
>&2 echo " -s <path/to/gan/secret> - The path to the mounted secret containing the webserver TLS certs/keystore (default: ${WEB_TLS_SECRETS_DIR})"
77-
>&2 echo " -d <path/to/data/folder> - The path to the Ignition data folder (default: ${IGNITION_DATA_DIR})"
90+
>&2 echo " -r <state> - Expected redundant state (can be specified multiple times, defaults to 'Good', 'OutOfDate', and 'Incompatible' when omitted)"
91+
>&2 echo " -s <state> - Expected context state, defaults to 'RUNNING'"
92+
>&2 echo " -t <seconds> - Timeout in seconds for the health check request, defaults to 3 seconds"
7893
>&2 echo " -h - Print this help message"
7994
>&2 echo " -v - Enable verbose output"
8095
}
8196

8297
# Argument Processing
98+
first_expected_state=true
8399
while getopts ":hvr:s:t:" opt; do
84100
case "$opt" in
85101
v)
86102
verbose=1
87103
;;
88104
r)
89-
expected_redundant_state=${OPTARG}
105+
# If this is the first -r argument, clear the default and start fresh
106+
if [ "${first_expected_state}" = true ]; then
107+
expected_redundant_states=()
108+
first_expected_state=false
109+
fi
110+
expected_redundant_states+=("${OPTARG}")
90111
;;
91112
s)
92113
expected_context_state=${OPTARG}

ignition/templates/statefulset.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ metadata:
55
name: {{ template "ignition.fullname" . }}-gateway
66
labels:
77
{{- include "ignition.labels" . | nindent 4 }}
8-
{{- with .Values.podLabels }}
9-
{{- toYaml . | nindent 4 }}
10-
{{- end }}
118
annotations:
129
checksum/config: {{ $configChecksum }}
1310
spec:
@@ -28,6 +25,9 @@ spec:
2825
metadata:
2926
labels:
3027
{{- include "ignition.labels" . | nindent 8 }}
28+
{{- with .Values.podLabels }}
29+
{{- toYaml . | nindent 8 }}
30+
{{- end }}
3131
annotations:
3232
checksum/config: {{ $configChecksum }}
3333
{{- with .Values.podAnnotations }}

ignition/tests/statefulset_test.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ tests:
132132
app.kubernetes.io/instance: ignition
133133
app.kubernetes.io/version: "8.3.0"
134134
helm.sh/chart: ignition-0.1.0
135+
- isSubset:
136+
path: spec.template.metadata.labels
137+
content:
138+
app.kubernetes.io/name: foo
139+
app.kubernetes.io/managed-by: Helm
140+
app.kubernetes.io/instance: ignition
141+
app.kubernetes.io/version: "8.3.0"
142+
helm.sh/chart: ignition-0.1.0
135143
foo: bar
136144
bar: baz
137145
# Verify Pod AntiAffinity is applied correctly

0 commit comments

Comments
 (0)