Skip to content

Commit 4efe366

Browse files
committed
fix up the test
1 parent bf4ed94 commit 4efe366

File tree

2 files changed

+57
-52
lines changed

2 files changed

+57
-52
lines changed

Makefile

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -197,40 +197,38 @@ e2e-test:
197197

198198
.PHONY: e2e-test-bgp
199199
e2e-test-bgp:
200-
KUBECONFIG=$(KUBECONFIG_PATH) kubectl -n kube-system patch daemonset ccm-linode --patch '\
201-
spec:\
202-
template:\
203-
spec:\
204-
containers:\
205-
- name: ccm-linode\
206-
args:\
207-
- --leader-elect-resource-lock=leases\
208-
- --v=3\
209-
- --secure-port=10253\
210-
- --webhook-secure-port=0\
211-
- --enable-route-controller=true\
212-
- --vpc-name=capl-cluster\
213-
- --configure-cloud-routes=true\
214-
- --cluster-cidr=10.0.0.0/8\
215-
- --load-balancer-type=cilium-bgp\
216-
- --bgp-node-selector=cilium-bgp-peering=true\
217-
- --ip-holder-suffix=e2e-test
200+
# Add bgp peering label to non control plane nodes
201+
KUBECONFIG=$(KUBECONFIG_PATH) kubectl label nodes $$(kubectl get nodes --no-headers |\
202+
grep -v control-plane | awk '{print $$1}') cilium-bgp-peering=true --overwrite
203+
204+
# First patch: Add the necessary RBAC permissions
218205
KUBECONFIG=$(KUBECONFIG_PATH) kubectl patch clusterrole ccm-linode-clusterrole --type='json' \
219-
-p='[{\
220-
"op": "add",\
221-
"path": "/rules/-",\
222-
"value": {\
223-
"apiGroups": ["cilium.io"],\
224-
"resources": ["ciliumloadbalancerippools", "ciliumbgppeeringpolicies"],\
225-
"verbs": ["get", "list", "watch", "create", "update", "patch", "delete"]\
226-
}\
227-
}]'
206+
-p='[{\
207+
"op": "add",\
208+
"path": "/rules/-",\
209+
"value": {\
210+
"apiGroups": ["cilium.io"],\
211+
"resources": ["ciliumloadbalancerippools", "ciliumbgppeeringpolicies"],\
212+
"verbs": ["get", "list", "watch", "create", "update", "patch", "delete"]\
213+
}\
214+
}]'
215+
216+
# Patch: Append new args to the existing ones
217+
KUBECONFIG=$(KUBECONFIG_PATH) kubectl patch daemonset ccm-linode -n kube-system --type='json' \
218+
-p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--bgp-node-selector=cilium-bgp-peering=true"},\
219+
{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--load-balancer-type=cilium-bgp"},\
220+
{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--ip-holder-suffix=$(CLUSTER_NAME)"}]'
221+
222+
# Wait for rollout
223+
KUBECONFIG=$(KUBECONFIG_PATH) kubectl -n kube-system rollout status daemonset/ccm-linode --timeout=300s
224+
225+
# Run the tests
228226
CLUSTER_NAME=$(CLUSTER_NAME) \
229-
MGMT_KUBECONFIG=$(MGMT_KUBECONFIG_PATH) \
230-
KUBECONFIG=$(KUBECONFIG_PATH) \
231-
REGION=$(LINODE_REGION) \
232-
LINODE_TOKEN=$(LINODE_TOKEN) \
233-
chainsaw test e2e/test/lb-cilium-bgp
227+
MGMT_KUBECONFIG=$(MGMT_KUBECONFIG_PATH) \
228+
KUBECONFIG=$(KUBECONFIG_PATH) \
229+
REGION=$(LINODE_REGION) \
230+
LINODE_TOKEN=$(LINODE_TOKEN) \
231+
chainsaw test e2e/lb-cilium-bgp
234232

235233
#####################################################################
236234
# OS / ARCH

e2e/lb-cilium-bgp/chainsaw-test.yaml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,42 @@ spec:
7777
NODE_ID=$(kubectl get $node -o jsonpath='{.spec.providerID}' | sed 's|linode://||')
7878
echo "Node ID: $NODE_ID"
7979
80-
SHARED_IPS=$(curl -H "Authorization: Bearer $LINODE_TOKEN" \
81-
"https://api.linode.com/v4/linode/instances/$NODE_ID/ips" | \
82-
jq -r '.ipv4.shared[].address')
80+
# Get node IPs with error handling
81+
NODE_IP_RESPONSE=$(curl -s -H "Authorization: Bearer $LINODE_TOKEN" \
82+
"https://api.linode.com/v4/linode/instances/$NODE_ID/ips")
83+
84+
# Check if shared IPs exist, if not use empty array
85+
SHARED_IPS=$(echo "$NODE_IP_RESPONSE" | jq -r '.ipv4.shared[]?.address // empty')
8386
echo "shared IPs: $SHARED_IPS"
8487
85-
if ! echo "$SHARED_IPS" | grep -q "$LB_IP"; then
88+
if [ -n "$SHARED_IPS" ] && ! echo "$SHARED_IPS" | grep -q "$LB_IP"; then
8689
echo "LoadBalancer IP $LB_IP not found in shared IPs of node $node"
8790
exit 1
8891
fi
92+
done
8993
9094
# Check if the nanode has the shared IP
91-
NANODE_ID=$(curl -H "Authorization: Bearer $LINODE_TOKEN" \
92-
"https://api.linode.com/v4/linode/instances" | \
93-
jq -r '.data[] | select(.label | endswith("e2e-test")) | .id')
94-
95-
NANODE_IPS=$(curl -H "Authorization: Bearer $LINODE_TOKEN" \
96-
"https://api.linode.com/v4/linode/instances/$NANODE_ID/ips" | \
97-
jq -r '.ipv4.public[].address')
95+
NANODE_RESPONSE=$(curl -s -H "Authorization: Bearer $LINODE_TOKEN" \
96+
"https://api.linode.com/v4/linode/instances")
9897
99-
if ! echo "$NANODE_IPS" | grep -q "$LB_IP"; then
100-
echo "LoadBalancer IP not found in nanode (IP placeholder) IPs"
101-
exit 1
102-
fi
98+
NANODE_ID=$(echo "$NANODE_RESPONSE" | \
99+
jq -r '.data[] | select(.label | endswith("$CLUSTER_NAME")) | .id')
103100
104-
# Delete the nanode
105-
curl -X DELETE -H "Authorization: Bearer $LINODE_TOKEN" \
106-
"https://api.linode.com/v4/linode/instances/$NANODE_ID"
107-
108-
done
101+
if [ -n "$NANODE_ID" ]; then
102+
NANODE_IP_RESPONSE=$(curl -s -H "Authorization: Bearer $LINODE_TOKEN" \
103+
"https://api.linode.com/v4/linode/instances/$NANODE_ID/ips")
104+
105+
NANODE_IPS=$(echo "$NANODE_IP_RESPONSE" | jq -r '.ipv4.public[]?.address // empty')
106+
107+
if [ -n "$NANODE_IPS" ] && ! echo "$NANODE_IPS" | grep -q "$LB_IP"; then
108+
echo "LoadBalancer IP not found in nanode (IP placeholder) IPs"
109+
exit 1
110+
fi
111+
112+
# Delete the nanode
113+
curl -s -X DELETE -H "Authorization: Bearer $LINODE_TOKEN" \
114+
"https://api.linode.com/v4/linode/instances/$NANODE_ID"
115+
fi
109116
check:
110117
($error == null): true
111118
(contains($stdout, 'LoadBalancer IP not found in shared IPs of node')): false

0 commit comments

Comments
 (0)