pvesh set returns "malformed JSON string"

isaak1983

New Member
Oct 26, 2016
2
0
1
40
I trying to change LXC container (1166) description via pvesh utility and get error:

Code:
root@dp-nd03:~# pvesh  set /nodes/dp-nd07/lxc/1166/config  --description "check_description"
malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)") at /usr/share/perl5/PVE/CLI/pvesh.pm line 125.

but if I run the same command on the node where the container is running, it works without errors

Code:
root@dp-nd07:~# pvesh  set /nodes/dp-nd07/lxc/1166/config  --description "check_description"

Some info about pve version:

Code:
pveversion -v
proxmox-ve: 5.3-1 (running kernel: 4.15.18-9-pve)
pve-manager: 5.3-8 (running version: 5.3-8/2929af8e)
pve-kernel-4.15: 5.2-12
pve-kernel-4.15.18-9-pve: 4.15.18-30
pve-kernel-4.4.134-1-pve: 4.4.134-112
pve-kernel-4.4.67-1-pve: 4.4.67-92
pve-kernel-4.4.35-1-pve: 4.4.35-77
pve-kernel-4.4.19-1-pve: 4.4.19-66
corosync: 2.4.4-pve1
criu: 2.11.1-1~bpo90
glusterfs-client: 3.8.8-1
ksm-control-daemon: 1.2-2
libjs-extjs: 6.0.1-2
libpve-access-control: 5.1-3
libpve-apiclient-perl: 2.0-5
libpve-common-perl: 5.0-43
libpve-guest-common-perl: 2.0-19
libpve-http-server-perl: 2.0-11
libpve-storage-perl: 5.0-35
libqb0: 1.0.3-1~bpo9
lvm2: 2.02.168-pve6
lxc-pve: 3.1.0-1
lxcfs: 3.0.2-2
novnc-pve: 1.0.0-2
proxmox-widget-toolkit: 1.0-22
pve-cluster: 5.0-33
pve-container: 2.0-33
pve-docs: 5.3-1
pve-edk2-firmware: 1.20181023-1
pve-firewall: 3.0-16
pve-firmware: 2.0-6
pve-ha-manager: 2.0-6
pve-i18n: 1.0-9
pve-libspice-server1: 0.14.1-1
pve-qemu-kvm: 2.12.1-1
pve-xtermjs: 1.0-5
qemu-server: 5.0-44
smartmontools: 6.5+svn4324-1
spiceterm: 3.0-5
vncterm: 1.5-3

I think problem in proxy_handler function (i replaced empty string by $json = "{}" and the error disappeared) or in the
Code:
 --output-format json
which returned empty string

Code:
sub proxy_handler {
    my ($node, $remip, $path, $cmd, $param) = @_;

    my $args = [];
    foreach my $key (keys %$param) {
        next if $key eq 'quiet' || $key eq 'output-format'; # just to  be sure
        push @$args, "--$key", $param->{$key};
    }

    my $remcmd = ['ssh', '-o', 'BatchMode=yes', "root\@$remip",
                  'pvesh', '--noproxy', $cmd, $path,
                  '--output-format', 'json'];

    if (scalar(@$args)) {
        my $cmdargs = [String::ShellQuote::shell_quote(@$args)];
        push @$remcmd, @$cmdargs;
    }

    my $json = '';
    PVE::Tools::run_command($remcmd, errmsg => "proxy handler failed",
                            outfunc => sub { $json .= shift });

    return decode_json($json);
}
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!