Skip to content

Commit 2768387

Browse files
danwinshipopenshift-cherrypick-robot
authored and
openshift-cherrypick-robot
committed
Reorder the steps in iptables-alerter
Check if iptables rules exist for the pod before checking if we've already logged an event; no reason to ping the apiserver for every pod since most of them won't have iptables rules.
1 parent e05b4b1 commit 2768387

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

bindata/network/iptables-alerter/002-script.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ data:
4747
fi
4848
netns=$(basename "${netns_path}")
4949
50-
# Check if we already logged an event for it
51-
events=$(kubectl get events -n "${pod_namespace}" -l pod-uid="${pod_uid}" 2>/dev/null)
52-
if [[ -n "${events}" ]]; then
53-
echo "Skipping pod ${pod_namespace}/${pod_name} which we already logged an event for."
54-
continue
55-
fi
56-
5750
# Set iptables_output to the first iptables rule in the pod's network
5851
# namespace, if any. (We use `awk` here rather than `grep` intentionally
5952
# to avoid awkwardness with grep's exit status on no match.)
@@ -66,6 +59,13 @@ data:
6659
continue
6760
fi
6861
62+
# Check if we already logged an event for it
63+
events=$(kubectl get events -n "${pod_namespace}" -l pod-uid="${pod_uid}" 2>/dev/null)
64+
if [[ -n "${events}" ]]; then
65+
echo "Skipping pod ${pod_namespace}/${pod_name} which we already logged an event for."
66+
continue
67+
fi
68+
6969
echo "Logging event for ${pod_namespace}/${pod_name} which has iptables rules"
7070
7171
# eg "2023-10-19T15:45:10.353846Z"

0 commit comments

Comments
 (0)