|
14 | 14 | # limitations under the License.
|
15 | 15 |
|
16 | 16 | # This script validates feature gates from a Kubernetes cluster's /metrics endpoint
|
17 |
| -# against expected values defined in versioned and unversioned feature lists. |
| 17 | +# against expected values defined in a versioned feature list. |
18 | 18 | #
|
19 |
| -# Usage: validate-compatibility-versions-feature-gates.sh <emulated_version> <current_version> <metrics_file> <feature_list> <prev_feature_list> <prev_unversioned_feature_list> <results_file> |
| 19 | +# Usage: validate-compatibility-versions-feature-gates.sh <emulated_version> <current_version> <metrics_file> <feature_list> <prev_feature_list> <results_file> |
20 | 20 | set -o errexit -o nounset -o pipefail
|
21 | 21 | # Check arg count
|
22 |
| -if [[ $# -ne 7 ]]; then |
23 |
| - echo "Usage: ${0} <emulated_version> <current_version> <metrics_file> <feature_list> <prev_feature_list> <prev_unversioned_feature_list> <results_file>" |
| 22 | +if [[ $# -ne 6 ]]; then |
| 23 | + echo "Usage: ${0} <emulated_version> <current_version> <metrics_file> <feature_list> <prev_feature_list> <results_file>" |
24 | 24 | exit 1
|
25 | 25 | fi
|
26 | 26 | emulated_version="$1" # e.g. "1.32"
|
27 | 27 | current_version="$2" # e.g. "1.33" - the actual version to check for DEPRECATED features
|
28 | 28 | metrics_file="$3" # path to /metrics
|
29 | 29 | feature_list="$4" # current versioned_feature_list.yaml
|
30 | 30 | prev_feature_list="$5" # previous versioned_feature_list.yaml
|
31 |
| -prev_unversioned_feature_list="$6" # previous unversioned_feature_list.yaml |
32 |
| -results_file="$7" |
| 31 | +results_file="$6" |
33 | 32 | echo "Validating features for emulated_version=${emulated_version}, current_version=${current_version}..."
|
34 | 33 | rm -f "${results_file}"
|
35 | 34 | touch "${results_file}"
|
@@ -109,47 +108,6 @@ while IFS= read -r feature_entry; do
|
109 | 108 | expected_value["$feature_name"]="$want"
|
110 | 109 | done < <(echo "$prev_feature_stream")
|
111 | 110 |
|
112 |
| -# Build the "expected_unversioned" sets from previous unversioned_feature_list.yaml |
113 |
| -# => expected_unversioned_stage[featureName], expected_unversioned_lock[featureName], expected_unversioned_value[featureName] |
114 |
| -declare -A expected_unversioned_stage |
115 |
| -declare -A expected_unversioned_lock |
116 |
| -declare -A expected_unversioned_value |
117 |
| - |
118 |
| -unversioned_feature_stream="$( |
119 |
| - yq e -o=json '.' "${prev_unversioned_feature_list}" \ |
120 |
| - | jq -c '.[]' |
121 |
| -)" |
122 |
| - |
123 |
| -while IFS= read -r unversioned_feature_entry; do |
124 |
| - unversioned_feature_name=$(echo "${unversioned_feature_entry}" | jq -r '.name') |
125 |
| - unversioned_specs_json=$(echo "${unversioned_feature_entry}" | jq -c '.versionedSpecs') # Although named versionedSpecs in YAML, it's unversioned list. |
126 |
| - |
127 |
| - # Unversioned should always use the first spec (assuming only one exists or first one is the default) |
128 |
| - target_unversioned_spec="$( |
129 |
| - echo "${unversioned_specs_json}" \ |
130 |
| - | jq -r '.[0]' # Get the first spec |
131 |
| - )" |
132 |
| - |
133 |
| - # If no spec, skip (should not happen in valid file) |
134 |
| - if [[ -z "$target_unversioned_spec" || "$target_unversioned_spec" == "null" ]]; then |
135 |
| - continue |
136 |
| - fi |
137 |
| - |
138 |
| - # Read fields - these are default values for unversioned features |
139 |
| - raw_unversioned_stage=$(echo "$target_unversioned_spec" | jq -r '.preRelease') # Can use this or default to GA |
140 |
| - unversioned_lockToDefault=$(echo "$target_unversioned_spec" | jq -r '.lockToDefault') |
141 |
| - unversioned_defaultVal=$(echo "$target_unversioned_spec" | jq -r '.default') |
142 |
| - |
143 |
| - # Convert defaultVal (true/false) -> 1/0 |
144 |
| - unversioned_want="0" |
145 |
| - if [[ "$unversioned_defaultVal" == "true" ]]; then |
146 |
| - unversioned_want="1" |
147 |
| - fi |
148 |
| - |
149 |
| - expected_unversioned_stage["$unversioned_feature_name"]="$raw_unversioned_stage" |
150 |
| - expected_unversioned_lock["$unversioned_feature_name"]="$unversioned_lockToDefault" |
151 |
| - expected_unversioned_value["$unversioned_feature_name"]="$unversioned_want" |
152 |
| -done < <(echo "$unversioned_feature_stream") |
153 | 111 |
|
154 | 112 | # For each "expected" feature (versioned):
|
155 | 113 | # - If missing from /metrics => fail unless stage==ALPHA or lock==true or is a deprecated feature that is listed as properly removed.
|
@@ -188,41 +146,7 @@ for feature_name in "${!expected_stage[@]}"; do
|
188 | 146 | fi
|
189 | 147 | done
|
190 | 148 |
|
191 |
| -# For each "expected_unversioned" feature: |
192 |
| -# - If missing from /metrics => fail unless stage==ALPHA or lock==true |
193 |
| -# - If present => compare numeric value |
194 |
| -for unversioned_feature_name in "${!expected_unversioned_stage[@]}"; do |
195 |
| - unversioned_stage="${expected_unversioned_stage[$unversioned_feature_name]}" |
196 |
| - unversioned_locked="${expected_unversioned_lock[$unversioned_feature_name]}" |
197 |
| - unversioned_want="${expected_unversioned_value[$unversioned_feature_name]}" |
198 |
| - |
199 |
| - got="${actual_features[$unversioned_feature_name]:-}" # empty if missing |
200 |
| - # If present, but stage==ALPHA => no checks are done |
201 |
| - if [[ "$unversioned_stage" == "ALPHA" ]]; then |
202 |
| - continue |
203 |
| - fi |
204 |
| - |
205 |
| - if [[ -z "$got" ]]; then |
206 |
| - # Missing from metrics |
207 |
| - if [[ "$unversioned_locked" == "true" ]]; then |
208 |
| - continue |
209 |
| - fi |
210 |
| - # Deprecated feature that was removed, these can continue. These can only be features that are not in the |
211 |
| - # scope of compatibility version(e.g kuebelet). |
212 |
| - if [[ "$REMOVED_FEATURE_LIST" == *"$feature_name"* ]]; then |
213 |
| - continue |
214 |
| - fi |
215 |
| - echo "FAIL: expected unversioned feature gate '$unversioned_feature_name' not found in metrics (lockToDefault=${unversioned_locked})" \ |
216 |
| - >> "${results_file}" |
217 |
| - continue |
218 |
| - fi |
219 | 149 |
|
220 |
| - # If present, compare true/false enabled value |
221 |
| - if [[ "$got" != "$unversioned_want" ]]; then |
222 |
| - echo "FAIL: unversioned feature '$unversioned_feature_name' expected value $unversioned_want, got $got" \ |
223 |
| - >> "${results_file}" |
224 |
| - fi |
225 |
| -done |
226 | 150 |
|
227 | 151 | declare -A current_stage
|
228 | 152 | declare -A current_lock
|
@@ -316,14 +240,14 @@ while IFS= read -r feature_entry; do
|
316 | 240 | current_version_stage["$feature_name"]="${exact_stage^^}" # uppercase
|
317 | 241 | done < <(echo "$current_feature_stream")
|
318 | 242 |
|
319 |
| -# For each actual feature in /metrics not in the "expected" maps (versioned OR unversioned), |
| 243 | +# For each actual feature in /metrics not in the "expected" map, |
320 | 244 | # - if it's "1", we fail as "unexpected feature". because new gates not found in previous
|
321 | 245 | # expected gates can only be introduced if they are off by default (0) but not on by default (1)
|
322 | 246 | # UNLESS:
|
323 | 247 | # - new feature is a client-go feature then we do not fail but continue
|
324 | 248 | # - new feature is a actually pre-existing code now being deprecated and as such called a "feature" retroactively for deprecation
|
325 | 249 | for feature_name in "${!actual_features[@]}"; do
|
326 |
| - if [[ -z "${expected_stage[$feature_name]:-}" ]] && [[ -z "${expected_unversioned_stage[$feature_name]:-}" ]]; then |
| 250 | + if [[ -z "${expected_stage[$feature_name]:-}" ]]; then |
327 | 251 | got="${actual_features[$feature_name]}"
|
328 | 252 | if [[ "$got" == "1" ]]; then
|
329 | 253 | # Check to see if gate is found in client-go and if so, continue
|
|
0 commit comments