Skip to content

Commit 3f75f9f

Browse files
committed
WIP fixes for CI build
1 parent 48af945 commit 3f75f9f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

smoketest/scripts/cli/test_load-balancing_wan.py

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def test_table_routes(self):
103103
cmd_in_netns(ns3, 'ip link set dev eth0 up')
104104

105105
# Set load-balancing configuration
106+
self.cli_set(base_path + ['wan', 'hook', '/bin/true'])
106107
self.cli_set(base_path + ['wan', 'interface-health', iface1, 'failure-count', '2'])
107108
self.cli_set(base_path + ['wan', 'interface-health', iface1, 'nexthop', '203.0.113.1'])
108109
self.cli_set(base_path + ['wan', 'interface-health', iface1, 'success-count', '1'])

src/helpers/vyos-load-balancer.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
def health_check(ifname, conf, state, test_defaults):
4141
# Run health tests for interface
4242

43+
if get_ipv4_address(ifname) is None:
44+
return False
45+
4346
if 'test' not in conf:
4447
resp_time = test_defaults['resp-time']
4548
target = conf['nexthop']
@@ -78,7 +81,7 @@ def on_state_change(lb, ifname, state):
7881
if 'hook' in lb:
7982
script_path = os.path.join('/config/scripts/', lb['hook'])
8083
state_str = 'ACTIVE' if state else 'FAILED'
81-
run(script_path, env=[f'WLB_INTERFACE_NAME={ifname}', f'WLB_INTERFACE_STATE={state_str}'])
84+
run(script_path, env={'WLB_INTERFACE_NAME': ifname, 'WLB_INTERFACE_STATE': state_str})
8285

8386
print(f'INFO: State change: {ifname} -> {state}')
8487

@@ -168,13 +171,14 @@ def get_config():
168171
index = 1
169172
for ifname, health_conf in lb['interface_health'].items():
170173
table_num = lb['mark_offset'] + index
174+
addr = get_ipv4_address(ifname)
171175
lb['health_state'][ifname] = {
172-
'if_addr': get_ipv4_address(ifname),
176+
'if_addr': addr,
173177
'failure_count': 0,
174178
'success_count': 0,
175179
'last_success': 0,
176180
'last_failure': 0,
177-
'state': True,
181+
'state': addr is not None,
178182
'state_changed': False,
179183
'table_number': table_num,
180184
'mark': hex(table_num)
@@ -196,7 +200,7 @@ def get_config():
196200
run('ip route flush cache')
197201

198202
if 'flush_connections' in lb:
199-
run('conntrack -F')
203+
run('conntrack --delete')
200204
run('conntrack -F expect')
201205

202206
with open(wlb_status_file, 'w') as f:
@@ -274,7 +278,7 @@ def handle_sigterm(signum, frame):
274278
run('ip route flush cache')
275279

276280
if 'flush_connections' in lb:
277-
run('conntrack -F')
281+
run('conntrack --delete')
278282
run('conntrack -F expect')
279283

280284
with open(wlb_status_file, 'w') as f:

0 commit comments

Comments
 (0)