Skip to content

Commit d232389

Browse files
committed
Update 2026-04-02
1 parent 33fcf95 commit d232389

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

extensions/network-namespace/network-namespace-wrapper.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,14 +791,25 @@ cmd_destroy() {
791791

792792
local vsd; vsd=$(_vpc_state_dir)
793793

794-
# Remove public veth pairs tracked under VPC/net state dir
794+
# Remove public veth pairs that belong to THIS tier (guarded by .tier file).
795+
# IPs owned by other tiers are left untouched so those tiers keep working.
796+
# Backward compat: if no .tier file exists assume the IP belongs here.
795797
if [ -d "${vsd}/ips" ]; then
796798
for f in "${vsd}/ips/"*.pvlan; do
797799
[ -f "${f}" ] || continue
800+
local tier_f; tier_f="${f%.pvlan}.tier"
801+
if [ -f "${tier_f}" ]; then
802+
local owner_tier; owner_tier=$(cat "${tier_f}" 2>/dev/null || true)
803+
if [ -n "${owner_tier}" ] && [ "${owner_tier}" != "${NETWORK_ID}" ]; then
804+
log "destroy: skipping veth for $(basename "${f%.pvlan}") (owned by tier ${owner_tier})"
805+
continue
806+
fi
807+
fi
798808
local pvlan pveth_h
799809
pvlan=$(cat "${f}")
800810
pveth_h=$(pub_veth_host_name "${pvlan}" "${CHOSEN_ID}")
801811
ip link del "${pveth_h}" 2>/dev/null || true
812+
rm -f "${f}" "${f%.pvlan}" "${tier_f}" 2>/dev/null || true
802813
done
803814
fi
804815

@@ -925,6 +936,8 @@ cmd_assign_ip() {
925936
echo "${SOURCE_NAT}" > "${vsd}/ips/${PUBLIC_IP}"
926937
# Save public VLAN so add-static-nat / add-port-forward can look it up
927938
echo "${PUBLIC_VLAN}" > "${vsd}/ips/${PUBLIC_IP}.pvlan"
939+
# Save owning tier (network ID) so cmd_destroy only cleans up its own IPs
940+
echo "${NETWORK_ID}" > "${vsd}/ips/${PUBLIC_IP}.tier"
928941

929942
_dump_iptables "${NAMESPACE}"
930943
release_lock
@@ -1006,7 +1019,8 @@ cmd_release_ip() {
10061019
fi
10071020

10081021
rm -f "${vsd}/ips/${PUBLIC_IP}" \
1009-
"${vsd}/ips/${PUBLIC_IP}.pvlan"
1022+
"${vsd}/ips/${PUBLIC_IP}.pvlan" \
1023+
"${vsd}/ips/${PUBLIC_IP}.tier"
10101024

10111025
_dump_iptables "${NAMESPACE}"
10121026
release_lock

0 commit comments

Comments
 (0)