Skip to content

Commit 7ff264e

Browse files
authored
Merge pull request #35544 from siyuanfoundation/compat
[compat-version] remove unversioned-feature-list from the feature gate test
2 parents 86eb10d + da956bd commit 7ff264e

File tree

2 files changed

+8
-92
lines changed

2 files changed

+8
-92
lines changed

experiment/compatibility-versions/compatibility-versions-feature-gate-test.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ main() {
236236
# Set original paths with fallbacks
237237
export VERSIONED_FEATURE_LIST=${VERSIONED_FEATURE_LIST:-"test/featuregates_linter/test_data/versioned_feature_list.yaml"}
238238
export PREV_VERSIONED_FEATURE_LIST=${PREV_VERSIONED_FEATURE_LIST:-"release-${EMULATED_VERSION}/test/featuregates_linter/test_data/versioned_feature_list.yaml"}
239-
export PREV_UNVERSIONED_FEATURE_LIST=${PREV_UNVERSIONED_FEATURE_LIST:-"release-${EMULATED_VERSION}/test/featuregates_linter/test_data/unversioned_feature_list.yaml"}
240239

241240
# Create and validate previous cluster
242241
git clone --filter=blob:none --single-branch --branch "release-${EMULATED_VERSION}" https://github.com/kubernetes/kubernetes.git "release-${EMULATED_VERSION}"
@@ -269,16 +268,9 @@ main() {
269268
fi
270269
fi
271270

272-
if [ ! -f "$PREV_UNVERSIONED_FEATURE_LIST" ]; then
273-
alt_path="release-${EMULATED_VERSION}/test/compatibility_lifecycle/reference/unversioned_feature_list.yaml"
274-
if [ -f "$alt_path" ]; then
275-
export PREV_UNVERSIONED_FEATURE_LIST="$alt_path"
276-
echo "Using alternative path for PREV_UNVERSIONED_FEATURE_LIST: $alt_path"
277-
fi
278-
fi
279271

280272
VALIDATE_SCRIPT="${VALIDATE_SCRIPT:-${PWD}/../test-infra/experiment/compatibility-versions/validate-compatibility-versions-feature-gates.sh}"
281-
"${VALIDATE_SCRIPT}" "${EMULATED_VERSION}" "${CURRENT_VERSION}" "${LATEST_METRICS}" "${VERSIONED_FEATURE_LIST}" "${PREV_VERSIONED_FEATURE_LIST}" "${PREV_UNVERSIONED_FEATURE_LIST}" "${LATEST_RESULTS}"
273+
"${VALIDATE_SCRIPT}" "${EMULATED_VERSION}" "${CURRENT_VERSION}" "${LATEST_METRICS}" "${VERSIONED_FEATURE_LIST}" "${PREV_VERSIONED_FEATURE_LIST}" "${LATEST_RESULTS}"
282274

283275
# Report results
284276
echo "=== Latest Cluster (${EMULATED_VERSION}) Validation ==="

experiment/compatibility-versions/validate-compatibility-versions-feature-gates.sh

Lines changed: 7 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@
1414
# limitations under the License.
1515

1616
# 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.
1818
#
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>
2020
set -o errexit -o nounset -o pipefail
2121
# 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>"
2424
exit 1
2525
fi
2626
emulated_version="$1" # e.g. "1.32"
2727
current_version="$2" # e.g. "1.33" - the actual version to check for DEPRECATED features
2828
metrics_file="$3" # path to /metrics
2929
feature_list="$4" # current versioned_feature_list.yaml
3030
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"
3332
echo "Validating features for emulated_version=${emulated_version}, current_version=${current_version}..."
3433
rm -f "${results_file}"
3534
touch "${results_file}"
@@ -109,47 +108,6 @@ while IFS= read -r feature_entry; do
109108
expected_value["$feature_name"]="$want"
110109
done < <(echo "$prev_feature_stream")
111110

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")
153111

154112
# For each "expected" feature (versioned):
155113
# - 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
188146
fi
189147
done
190148

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
219149

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
226150

227151
declare -A current_stage
228152
declare -A current_lock
@@ -316,14 +240,14 @@ while IFS= read -r feature_entry; do
316240
current_version_stage["$feature_name"]="${exact_stage^^}" # uppercase
317241
done < <(echo "$current_feature_stream")
318242

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,
320244
# - if it's "1", we fail as "unexpected feature". because new gates not found in previous
321245
# expected gates can only be introduced if they are off by default (0) but not on by default (1)
322246
# UNLESS:
323247
# - new feature is a client-go feature then we do not fail but continue
324248
# - new feature is a actually pre-existing code now being deprecated and as such called a "feature" retroactively for deprecation
325249
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
327251
got="${actual_features[$feature_name]}"
328252
if [[ "$got" == "1" ]]; then
329253
# Check to see if gate is found in client-go and if so, continue

0 commit comments

Comments
 (0)