Corsinvest / cv4pve-autosnap

Automatic snapshot tool for Proxmox VE
https://www.corsinvest.it/cv4pve
GNU General Public License v3.0
413 stars 51 forks source link

Error on fresh install #57

Closed sgtpepperaut closed 2 years ago

sgtpepperaut commented 2 years ago

What happened?

running a simple one liner on a fresh install gives me an error on proxmox 7.1-7 /usr/local/bin/cv4pve-autosnap --host=127.0.0.1 --username="snapshot@pve" --password="MYPASS" --vmid=5020 snap --label="daily" --keep=6

Expected behavior

create a snapshot :)

Relevant log output

ACTION Snap
VMs:              5020
Label:            daily
Keep:             6
State:            False
Timeout:          30000
Timestamp format: yyMMddHHmmss
Max % Storage :   95%
================ EXCEPTION ================
System.IndexOutOfRangeException
Index was outside the bounds of the array.
   at BetterConsoleTables.Table.ToString(Int32[] columnLengths)
   at BetterConsoleTables.Table.ToString()
   at Corsinvest.ProxmoxVE.Api.Extension.Helpers.TableHelper.Create(IEnumerable`1 columns, IEnumerable`1 rows, TableOutputType outputType, Boolean hasInnerRows)
   at Corsinvest.ProxmoxVE.Api.Extension.Helpers.TableHelper.Create(IEnumerable`1 columns, IEnumerable`1 rows, TableOutputType outputType, Boolean hasInnerRows)
   at Corsinvest.ProxmoxVE.AutoSnap.Api.Application.Snap(String vmIdsOrNames, String label, Int32 keep, Boolean state, Int64 timeout, String timestampFormat, Int32 optMaxPercentageStorage)
   at Corsinvest.ProxmoxVE.AutoSnap.ShellCommands.<>c__DisplayClass9_1.<Snap>b__1()
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass144_0.<OnExecute>b__0(CancellationToken _)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Corsinvest.ProxmoxVE.Api.Shell.Helpers.ShellHelper.ExecuteConsoleApp(CommandLineApplication app, String[] args)

Proxmox VE Version

7.1-7

Version (bug)

1.13.2

Version (working)

No response

On what operating system are you experiencing the issue?

Linux

Pull Request

franklupo commented 2 years ago

Hi, can you run with the --debug option and attach the result? Remember to remove the password information from the registry.

Best regards

sgtpepperaut commented 2 years ago

here is the output:

``root@srv1:/usr/local/bin# /usr/local/bin/cv4pve-autosnap --host=127.0.0.1 --username="snapshot@pve" --password="mypass" --vmid=5020 snap --label="daily" --keep=6 --debug Method: POST, Url: https://127.0.0.1:8006/api2/json/access/ticket Parameters: password : mypass username : snapshot realm : pve StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True { "data": { "CSRFPreventionToken": "61C44923:83IcfAEX0xLSEtgC3l1FPctsp86ts9L+6ooBlGWEaEE", "cap": { "nodes": {}, "dc": {}, "storage": {}, "access": {}, "vms": { "VM.Snapshot": 1, "VM.Audit": 1, "VM.Snapshot.Rollback": 1 }, "sdn": {} }, "username": "snapshot@pve", "ticket": "PVE:snapshot@pve:61C44923::jTuYiasr0R6RoUyC0KpLDpN8Ydk9C+4D3yvfIs8AcfQzUGijoPRc0PqjGrqvGwL6f1TTpOeYNlLzJqHsrPIpt+dAGory2EjgnE5R46t9M9PNL1ccKp5XadcbhWribicc4JPQMvUU9HqEhrl80apkMLiuTgdg9VdBmLVM/+kKY98/soMsBMaaVhssE3Tnj8L4233XiutgV6HUfdfInX/AeaLVWURrWGJZMo/WhvZrbio3lgN34IQmfEoul8eUrZdYAcYewiSP8gNUu3sUDq75hz5kt3FLxWOg3LjfWVIdAEgS/IM7kchxRUZ7dO0Gf2Gz1N7JZHxv/iq+i7355CskTw==" } }

ACTION Snap VMs: 5020 Label: daily Keep: 6 State: False Timeout: 30000 Timestamp format: yyMMddHHmmss Max % Storage : 95% Method: GET, Url: https://127.0.0.1:8006/api2/json/cluster/resources?type=vm StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True { "data": [ { "name": "ano-pfsense", "netin": 20613081521, "diskwrite": 30332746240, "netout": 13493524657, "type": "qemu", "mem": 1365996020, "template": 0, "vmid": 5001, "diskread": 176566742, "node": "srv1", "cpu": 0.00590965218071446, "maxcpu": 4, "id": "qemu/5001", "status": "running", "disk": 0, "maxmem": 4194304000, "maxdisk": 6442450944, "uptime": 1452533 }, etc more vms... ] }

Method: GET, Url: https://127.0.0.1:8006/api2/json/cluster/resources?type=storage StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True { "data": [] }

================ EXCEPTION ================ System.IndexOutOfRangeException Index was outside the bounds of the array. at BetterConsoleTables.Table.ToString(Int32[] columnLengths) at BetterConsoleTables.Table.ToString() at Corsinvest.ProxmoxVE.Api.Extension.Helpers.TableHelper.Create(IEnumerable1 columns, IEnumerable1 rows, TableOutputType outputType, Boolean hasInnerRows) at Corsinvest.ProxmoxVE.Api.Extension.Helpers.TableHelper.Create(IEnumerable1 columns, IEnumerable1 rows, TableOutputType outputType, Boolean hasInnerRows) at Corsinvest.ProxmoxVE.AutoSnap.Api.Application.Snap(String vmIdsOrNames, String label, Int32 keep, Boolean state, Int64 timeout, String timestampFormat, Int32 optMaxPercentageStorage) at Corsinvest.ProxmoxVE.AutoSnap.ShellCommands.<>cDisplayClass9_1.b1() at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>cDisplayClass144_0.b0(CancellationToken _) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at Corsinvest.ProxmoxVE.Api.Shell.Helpers.ShellHelper.ExecuteConsoleApp(CommandLineApplication app, String[] args) ================ EXCEPTION ================ System.IndexOutOfRangeException Index was outside the bounds of the array. at BetterConsoleTables.Table.ToString(Int32[] columnLengths) at BetterConsoleTables.Table.ToString() at Corsinvest.ProxmoxVE.Api.Extension.Helpers.TableHelper.Create(IEnumerable1 columns, IEnumerable1 rows, TableOutputType outputType, Boolean hasInnerRows) at Corsinvest.ProxmoxVE.Api.Extension.Helpers.TableHelper.Create(IEnumerable1 columns, IEnumerable1 rows, TableOutputType outputType, Boolean hasInnerRows) at Corsinvest.ProxmoxVE.AutoSnap.Api.Application.Snap(String vmIdsOrNames, String label, Int32 keep, Boolean state, Int64 timeout, String timestampFormat, Int32 optMaxPercentageStorage) at Corsinvest.ProxmoxVE.AutoSnap.ShellCommands.<>cDisplayClass9_1.b1() at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>cDisplayClass144_0.b0(CancellationToken _) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at Corsinvest.ProxmoxVE.Api.Shell.Helpers.ShellHelper.ExecuteConsoleApp(CommandLineApplication app, String[] args)``

franklupo commented 2 years ago

Permission problem read documentation

bwmravec commented 2 years ago

Your user snapshot@pve doesn't have access to storage where you are storing snapshots. Simply add this user with permissions "Datastore.Audit Pool.Audit VM.Audit VM.Snapshot" also to your storage, not only to VM 5020.

thunfischbrot commented 2 years ago

The error message could provide a hint to the permission problem. This might also save you from answering these questions in the future :-)

franklupo commented 2 years ago

Fix in new version