From 88dadeb17c16d11c725b48cf9683dbd09c057763 Mon Sep 17 00:00:00 2001 From: Mikko Reinikainen Date: Tue, 12 May 2026 20:37:34 +0300 Subject: [PATCH] Add timeouts to nmcli commands - Default timeout 10 seconds sometimes isn't enough on a slower machine, like an emulated virtual machine --- .../ytl-linux-digabi2-examnet/lib/network.just | 14 +++++++------- .../ytl-linux-digabi2-examnet/test/examnet.test.ts | 12 +++++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/ytl-linux-digabi2-examnet/lib/network.just b/packages/ytl-linux-digabi2-examnet/lib/network.just index bc406e8..069e48d 100644 --- a/packages/ytl-linux-digabi2-examnet/lib/network.just +++ b/packages/ytl-linux-digabi2-examnet/lib/network.just @@ -57,16 +57,16 @@ configure-networkmanager connection-name interface-name ip-and-netmask: just log info "Configuring NetworkManager connection '{{connection-name}}' for interface '{{interface-name}}' with IP and netmask '{{ip-and-netmask}}'" just log debug "Checking if NetworkManager connection '{{connection-name}}' already exists" - if nmcli connection show "{{connection-name}}" > /dev/null 2>&1; then + if nmcli --wait 30 connection show "{{connection-name}}" > /dev/null 2>&1; then just log debug "NetworkManager connection '{{connection-name}}' already exists, deleting it before creating a new one" - if ! nmcli connection delete "{{connection-name}}"; then + if ! nmcli --wait 30 connection delete "{{connection-name}}"; then just log error "Failed to delete existing NetworkManager connection '{{connection-name}}'" exit $EXIT_CODE_CANNOT_CONFIGURE_EXAMNET fi fi just log debug "Adding NetworkManager connection '{{connection-name}}' for interface '{{interface-name}}' with IP and netmask '{{ip-and-netmask}}'" - if ! nmcli connection add \ + if ! nmcli --wait 30 connection add \ type ethernet \ ifname "{{interface-name}}" \ con-name "{{connection-name}}" \ @@ -78,10 +78,10 @@ configure-networkmanager connection-name interface-name ip-and-netmask: fi just log debug "Disabling IPv6 for NetworkManager connection '{{connection-name}}'" - nmcli connection modify "{{connection-name}}" ipv6.method disabled + nmcli --wait 30 connection modify "{{connection-name}}" ipv6.method disabled just log debug "Bringing up NetworkManager connection '{{connection-name}}'" - nmcli connection up "{{connection-name}}" + nmcli --wait 60 connection up "{{connection-name}}" just log info "Successfully configured NetworkManager connection '{{connection-name}}' for interface '{{interface-name}}' with IP and netmask '{{ip-and-netmask}}'" @@ -89,7 +89,7 @@ get-connections error-code: #!/usr/bin/env bash set -euo pipefail - if ! CONNECTIONS=$(nmcli -f UUID,NAME connection show); then + if ! CONNECTIONS=$(nmcli --wait 30 --fields UUID,NAME connection show); then just log error "Failed to enumerate NetworkManager connections" exit {{error-code}} fi @@ -101,7 +101,7 @@ delete-connection connection-name connection-uuid error-code: set -euo pipefail just log debug "Deleting NetworkManager connection '{{connection-name}}' with UUID {{connection-uuid}}" - if ! nmcli connection delete "{{connection-uuid}}"; then + if ! nmcli --wait 30 connection delete "{{connection-uuid}}"; then just log error "Failed to delete NetworkManager connection '{{connection-name}}' with UUID {{connection-uuid}}" exit {{error-code}} fi diff --git a/packages/ytl-linux-digabi2-examnet/test/examnet.test.ts b/packages/ytl-linux-digabi2-examnet/test/examnet.test.ts index b6c0daa..71951ff 100644 --- a/packages/ytl-linux-digabi2-examnet/test/examnet.test.ts +++ b/packages/ytl-linux-digabi2-examnet/test/examnet.test.ts @@ -1438,21 +1438,23 @@ function callApparmorParser(profile: string) { } function callNmicliConnectionShow(connectionName: string) { - return { cmd: 'nmcli', argv: ['connection', 'show', connectionName] } + return { cmd: 'nmcli', argv: ['--wait', '30', 'connection', 'show', connectionName] } } function callNmicliConnectionDelete(connectionName: string) { - return { cmd: 'nmcli', argv: ['connection', 'delete', connectionName] } + return { cmd: 'nmcli', argv: ['--wait', '30', 'connection', 'delete', connectionName] } } function callNmicliConnectionModify(connectionName: string) { - return { cmd: 'nmcli', argv: ['connection', 'modify', connectionName, 'ipv6.method', 'disabled'] } + return { cmd: 'nmcli', argv: ['--wait', '30', 'connection', 'modify', connectionName, 'ipv6.method', 'disabled'] } } function callNmicliConnectionAdd(connectionName: string, ipRange: string) { return { cmd: 'nmcli', argv: [ + '--wait', + '30', 'connection', 'add', 'type', @@ -1472,7 +1474,7 @@ function callNmicliConnectionAdd(connectionName: string, ipRange: string) { } function callNmicliConnectionUp(deviceName: string) { - return { cmd: 'nmcli', argv: ['connection', 'up', deviceName] } + return { cmd: 'nmcli', argv: ['--wait', '60', 'connection', 'up', deviceName] } } function callNmonline(timeout: number = 30) { @@ -1495,7 +1497,7 @@ function callSed(path: string) { } function callNmcli() { - return { cmd: 'nmcli', argv: ['-f', 'UUID,NAME', 'connection', 'show'] } + return { cmd: 'nmcli', argv: ['--wait', '30', '--fields', 'UUID,NAME', 'connection', 'show'] } } function callOpenssl(path: string) {