Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/images/kubectl-ko
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ xxctl(){
checkLeader(){
component="$1"; shift
set +o pipefail
count=$(kubectl get ep ovn-$component -n $KUBE_OVN_NS -o yaml | grep "ip:" | wc -l)
count=$(kubectl get endpointslice -l kubernetes.io/service-name=ovn-$component -n $KUBE_OVN_NS -o jsonpath='{.items[*].endpoints[*].addresses[0]}' | sort | uniq | wc -l)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current jsonpath command only retrieves the first address of each endpoint, which can lead to an inaccurate count of active endpoints. This can cause the leader election to fail if multiple endpoints are present but only one address is retrieved.[^1]

count=$(kubectl get endpointslice -l kubernetes.io/service-name=ovn-$component -n $KUBE_OVN_NS -o go-template='{{len .items}}')

set -o pipefail
if [ $count -eq 0 ]; then
echo "no ovn-$component exists !!"
Expand Down
Loading