diff --git a/defaults.inc b/defaults.inc index 91c628c..9d713e2 100755 --- a/defaults.inc +++ b/defaults.inc @@ -3,7 +3,7 @@ action="${1:-}" FOLDER='/opt/idssys/ta-proxmenu' -VERS='2026.7.25-54' +VERS='2026.7.25-55' noupdate=' ' diff --git a/inc/deploy-pulse-lxc.sh b/inc/deploy-pulse-lxc.sh index c7dc9d3..fe75d30 100644 --- a/inc/deploy-pulse-lxc.sh +++ b/inc/deploy-pulse-lxc.sh @@ -561,6 +561,41 @@ json.dump(data, sys.stdout, separators=(",", ":")) ' } +TAPM_PULSE_CREATE_PVE_AUTO_REGISTER_TOKEN() { + local token_name="$1" + local output_variable="$2" + local status_variable="$3" + local command_output='' + local command_status=0 + + if command_output="$( + pveum user token add pulse-monitor@pve "$token_name" \ + --privsep 1 --output-format json 2>&1 + )"; then + command_status=0 + else + command_status=$? + fi + + # Older pveum versions reject --output-format and require table parsing. + if (( command_status != 0 )) && + grep -Eqi \ + 'unknown option|unknown command|no such option|unable to parse option|output-format' \ + <<<"$command_output"; then + if command_output="$( + pveum user token add pulse-monitor@pve "$token_name" \ + --privsep 1 2>&1 + )"; then + command_status=0 + else + command_status=$? + fi + fi + + printf -v "$output_variable" '%s' "$command_output" + printf -v "$status_variable" '%s' "$command_status" +} + TAPM_PULSE_REGISTER_CLUSTER() { local ctid="$1" local container_ip="$2" @@ -582,6 +617,12 @@ TAPM_PULSE_REGISTER_CLUSTER() { # shellcheck disable=SC1090 source "$installer" IN_CONTAINER=false + # Pulse v6.1.1's helper shadows the caller's token_output and + # token_status variables, discarding a successful pveum result. + # Override only that helper so auto_register_pve_node receives them. + create_pve_auto_register_token() { + TAPM_PULSE_CREATE_PVE_AUTO_REGISTER_TOKEN "$@" + } # Pulse v6.1.1's installer omits backup_perms from its expected # artifact URLs even when it requests backupPerms=true. That causes it # to reject Pulse's otherwise valid response as "missing setup token." diff --git a/tests/test-pulse.sh b/tests/test-pulse.sh index dce502c..1b8d691 100644 --- a/tests/test-pulse.sh +++ b/tests/test-pulse.sh @@ -92,6 +92,28 @@ assert_failure "Pulse v6.1.1 compatibility rejects missing setup token" \ TAPM_PULSE_NORMALIZE_V611_SETUP_ARTIFACT \ '{"type":"pve","host":"https://pve1:8006"}' 'http://10.10.2.30:7655' +test_pve_token_output_assignment() { + local token_output='' + local token_status=99 + + pveum() { + printf '%s\n' \ + '{"full-tokenid":"pulse-monitor@pve!pulse-test","value":"secret-value"}' + } + TAPM_PULSE_CREATE_PVE_AUTO_REGISTER_TOKEN \ + 'pulse-test' token_output token_status || return 1 + unset -f pveum + + assert_equal \ + '{"full-tokenid":"pulse-monitor@pve!pulse-test","value":"secret-value"}' \ + "$token_output" \ + "Pulse receives pveum token output" + assert_equal 0 "$token_status" "Pulse receives pveum token status" +} + +assert_success "Pulse v6.1.1 pveum output-shadowing workaround" \ + test_pve_token_output_assignment + nodes_json='[ {"node":"pve3","status":"offline"}, {"node":"pve2","status":"online"},