Passed cilium connectivity tests as a worker node

This commit is contained in:
2026-04-29 02:34:04 +08:00
parent e86b3b3383
commit 6d290a97ae
10 changed files with 614 additions and 277 deletions

View File

@@ -6,6 +6,25 @@ OUTPUT="${2:?output file required}"
mkdir -p "$(dirname "$OUTPUT")"
TMP="$(mktemp)"
BASE_CREATED=0
if [ -f "$OUTPUT" ]; then
BASE="$OUTPUT"
else
BASE="$(mktemp)"
BASE_CREATED=1
: > "$BASE"
fi
cleanup() {
rm -f "$TMP"
if [ "$BASE_CREATED" = "1" ]; then
rm -f "$BASE"
fi
}
trap cleanup EXIT INT TERM
awk '
function trim(s) {
sub(/^[[:space:]]+/, "", s)
@@ -13,33 +32,76 @@ function trim(s) {
return s
}
BEGIN {
for (k in ENVIRON) {
env[k] = ENVIRON[k]
}
}
/^[[:space:]]*#/ || /^[[:space:]]*$/ {
print
next
}
{
line = $0
function parse_key(line, eq, key) {
eq = index(line, "=")
if (eq == 0) {
print line
next
return ""
}
key = trim(substr(line, 1, eq - 1))
val = substr(line, eq + 1)
if (key in env) {
print key "=" env[key]
} else {
print line
if (key !~ /^[A-Za-z_][A-Za-z0-9_]*$/) {
return ""
}
return key
}
function merged_line(key, line) {
if (key ~ /^MKS_/ && key in ENVIRON) {
return key "=" ENVIRON[key]
}
return line
}
# First file: INPUT
phase == 1 {
line = $0
key = parse_key(line)
if (key != "") {
incoming[key] = merged_line(key, line)
if (!(key in input_seen)) {
input_order[++input_count] = key
input_seen[key] = 1
}
}
next
}
# Second file: existing OUTPUT / BASE
phase == 2 {
line = $0
key = parse_key(line)
if (key != "" && key in incoming) {
print incoming[key]
written[key] = 1
next
}
print line
if (key != "") {
written[key] = 1
}
next
}
END {
for (i = 1; i <= input_count; i++) {
key = input_order[i]
if (!(key in written)) {
print incoming[key]
written[key] = 1
}
}
}
' "$INPUT" > "$OUTPUT"
' phase=1 "$INPUT" phase=2 "$BASE" > "$TMP"
mv "$TMP" "$OUTPUT"