Skip to content

Instantly share code, notes, and snippets.

@RamLavi
Last active January 23, 2025 08:29
Show Gist options
  • Select an option

  • Save RamLavi/57a7accdc71c25e98e7a7e231111565a to your computer and use it in GitHub Desktop.

Select an option

Save RamLavi/57a7accdc71c25e98e7a7e231111565a to your computer and use it in GitHub Desktop.
OVNK flake finder
#!/usr/bin/env bash
set -Eeuo pipefail
################################################################################
# Usage: ./check_flakes.sh <INPUT_FILE> [<GITHUB_TOKEN>]
#
# Description:
# Reads each line from <INPUT_FILE>. If a line includes "[CHECK]" then:
# 1. Extracts the text after "[CHECK]" (the test name).
# 2. Queries GitHub for an existing kind/ci-flake issue containing that test
# name in its title.
# 3. Removes "[CHECK]" and replaces the test name with `test_name`,
# appending either " - <issue_url>" or " - FLAKE NOT FOUND, CHECK MANUALLY".
# Otherwise, prints the line unchanged.
#
# Example:
# ./check_flakes.sh failing_tests.txt
# ./check_flakes.sh failing_tests.txt ghp_YourGitHubToken
################################################################################
function usage() {
echo "Usage: $0 <INPUT_FILE> [<GITHUB_TOKEN>]"
exit 1
}
# Check arguments
if [[ $# -lt 1 ]]; then
usage
fi
INPUT_FILE="$1"
GITHUB_TOKEN="${2:-}"
# ------------------------------------------------------------------------------
# find_flaky_issue: Search GitHub for an open "kind/ci-flake" issue in
# ovn-kubernetes/ovn-kubernetes whose title contains the given test_name.
# Returns the first matching issue URL or an empty string if none found.
# ------------------------------------------------------------------------------
function find_flaky_issue() {
local test_name="$1"
local token="$2"
local github_api="https://api.github.com"
local search_endpoint="${github_api}/search/issues"
# Construct the query:
# - is:issue
# - is:open
# - in:title "<test_name>"
# - repo:ovn-kubernetes/ovn-kubernetes
# - label:kind/ci-flake
#
# e.g., is:issue is:open in:title "SomeTest" repo:ovn-kubernetes/ovn-kubernetes label:kind/ci-flake
local query="is:issue is:open in:title \"${test_name}\" repo:ovn-kubernetes/ovn-kubernetes label:kind/ci-flake"
# Build headers (add Authorization if token is provided)
local headers=(
-H "Accept: application/vnd.github+json"
)
if [[ -n "$token" ]]; then
headers+=(-H "Authorization: Bearer $token")
fi
# Run the search request
local response
response="$(curl -sS "${headers[@]}" --get --data-urlencode "q=$query" "$search_endpoint")"
# Parse total_count to see if there's at least one match
local total_count
total_count="$(jq -r '.total_count' <<< "$response" 2>/dev/null || echo 0)"
if [[ "$total_count" -gt 0 ]]; then
# Return the first matching issue's HTML URL
jq -r '.items[0].html_url' <<< "$response"
else
echo ""
fi
}
# ------------------------------------------------------------------------------
# Process the file line by line.
# ------------------------------------------------------------------------------
while IFS= read -r line; do
# If the line includes "[CHECK]", transform it accordingly
if [[ "$line" =~ \[CHECK\] ]]; then
# Extract everything after '[CHECK]'
# e.g. line might be " - [CHECK]Should validate something"
# We'll remove everything up to "[CHECK]" to isolate the test name
test_name="${line#*\[CHECK\]}"
# Trim leading spaces (if any)
test_name="${test_name#"${test_name%%[![:space:]]*}"}"
# Find a flaky issue (if one exists)
issue_url="$(find_flaky_issue "$test_name" "$GITHUB_TOKEN")"
# Everything up to [CHECK] for later re-use (preserves indentation and dash)
# e.g. " - "
leading="${line%%\[CHECK\]*}"
if [[ -n "$issue_url" ]]; then
# If found, append the issue URL
echo "${leading}\`${test_name}\` - ${issue_url}"
else
# Otherwise, let the user know it wasn't found
echo "${leading}\`${test_name}\` - FLAKE NOT FOUND, CHECK MANUALLY"
fi
else
# If no "[CHECK]", just print the line as-is
echo "$line"
fi
done < "$INPUT_FILE"
$ ./check_known_flakes.sh failed $mytoken
- [e2e (shard-conformance, noHA, local, dualstack, snatGW, 1br, ic-single-node-zones)](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915566066?pr=4850#logs)
- `should be able to switch session affinity for NodePort service` - https://github.com/ovn-kubernetes/ovn-kubernetes/issues/3947
- [e2e (control-plane, noHA, local, ipv6, noSnatGW, 1br, ic-single-node-zones)](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915570144?pr=4850#logs)
- `Should validate flow data of br-int is sent to an external gateway [It] with sflow` - https://github.com/ovn-kubernetes/ovn-kubernetes/issues/4221
- [e2e (external-gateway, noHA, shared, ipv4, noSnatGW, 2br, ic-single-node-zones)](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915572703?pr=4850#logs)
- `Should validate ICMP connectivity to an external gateway's loopback address via a gateway pod [It] ipv4` - https://github.com/ovn-kubernetes/ovn-kubernetes/issues/4474
- `Should validate ICMP connectivity to multiple external gateways for an ECMP scenario [It] IPV4` - FLAKE NOT FOUND, CHECK MANUALLY
- [e2e (network-segmentation, noHA, shared, dualstack, noSnatGW, 1br, ic-single-node-zones, disable-...](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915574506?pr=4850#logs)
- `Should validate the egress IP functionality against remote hosts [It] disabling egress nodes impeding GRCP health check` - https://github.com/ovn-kubernetes/ovn-kubernetes/issues/4144
- [e2e (network-segmentation, noHA, local, dualstack, noSnatGW, 1br, ic-single-node-zones)](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915574772?pr=4850#logs)
- `pod connected to ClusterUserDefinedNetwork CR & managed NADs cannot be deleted when being used` - https://github.com/ovn-kubernetes/ovn-kubernetes/issues/4966
- [e2e (network-segmentation, noHA, shared, dualstack, SnatGW, 1br, ic-disabled)](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915575084?pr=4850#logs)
- `pod connected to ClusterUserDefinedNetwork [BeforeEach] CR & managed NADs cannot be deleted when being used` - https://github.com/ovn-kubernetes/ovn-kubernetes/issues/4966
- [e2e (shard-conformance, noHA, local, dualstack, snatGW, 1br, ic-single-node-zones)](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915566066?pr=4850#logs)
- [CHECK]should be able to switch session affinity for NodePort service
- [e2e (control-plane, noHA, local, ipv6, noSnatGW, 1br, ic-single-node-zones)](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915570144?pr=4850#logs)
- [CHECK]Should validate flow data of br-int is sent to an external gateway [It] with sflow
- [e2e (external-gateway, noHA, shared, ipv4, noSnatGW, 2br, ic-single-node-zones)](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915572703?pr=4850#logs)
- [CHECK]Should validate ICMP connectivity to an external gateway's loopback address via a gateway pod [It] ipv4
- [CHECK]Should validate ICMP connectivity to multiple external gateways for an ECMP scenario [It] IPV4
- [e2e (network-segmentation, noHA, shared, dualstack, noSnatGW, 1br, ic-single-node-zones, disable-...](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915574506?pr=4850#logs)
- [CHECK]Should validate the egress IP functionality against remote hosts [It] disabling egress nodes impeding GRCP health check
- [e2e (network-segmentation, noHA, local, dualstack, noSnatGW, 1br, ic-single-node-zones)](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915574772?pr=4850#logs)
- [CHECK]pod connected to ClusterUserDefinedNetwork CR & managed NADs cannot be deleted when being used
- [e2e (network-segmentation, noHA, shared, dualstack, SnatGW, 1br, ic-disabled)](https://github.com/ovn-kubernetes/ovn-kubernetes/actions/runs/12882315028/job/35915575084?pr=4850#logs)
- [CHECK]pod connected to ClusterUserDefinedNetwork [BeforeEach] CR & managed NADs cannot be deleted when being used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment