Problems trying to retrieve a published image.
Creating a container and publishing causes not being allowed to list any image or edit its configurations.
Error: json: error calling MarshalJSON for type time.Time: Time.MarshalJSON: year outside of range [0,9999]
dmesg)lxc info NAME --show-log)lxc config show NAME --expanded)lxc monitor while reproducing the issue)@cyberwillis can you make sure that your local copy of go-dqlite is up to date?
There were some issues with date handling in there which @freeekanayaka fixed recently, I wonder if that's the issue you're hitting here.
Nevermind, same issue here, so this is a current problem.
@freeekanayaka assigning this to you
stgraber@castiana:~/data/code/lxc/lxd-pkg-snap (latest-edge)$ lxd sql global "SELECT * FROM images;"
Error: json: error calling MarshalJSON for type time.Time: Time.MarshalJSON: year outside of range [0,9999]
root@castiana:~/data/code/lxc/lxd-pkg-snap (latest-edge)# lxd sql global ".sync"
root@castiana:~/data/code/lxc/lxd-pkg-snap (latest-edge)# sqlite3 /var/lib/lxd/database/global/db.bin
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> SELECT * FROM images;
369|2a7896bae0f2322559e5b9452b0adf58a5a76f7b772fa6906c825407ea6c3386|ubuntu-16.04-server-cloudimg-amd64-lxd.tar.xz|165454668|0|2|2018-07-23 20:00:00-04:00|2021-04-20 20:00:00-04:00|2018-07-24 20:18:48-04:00|1|2018-07-23 23:07:44-04:00|1
394|1eb516370fe8957b99bbd02b6dd57152b9f4e31f7b21e7e882c997426ae1aeb1|cosmic-server-cloudimg-amd64-lxd.tar.xz|182313740|0|2|2018-07-31 00:00:00+00:00|2019-07-18 00:00:00+00:00|2018-08-01 20:00:41.215300266+00:00|1|2018-08-02 20:35:35.027976428+00:00|1
395|7247ff2fcd4bb63820725b60049887d2ffcc8ee8e29d65f2a324e93bcd80d545|lxd.tar.xz|3781332|0|2|2018-08-02 00:00:00+00:00|1970-01-01 00:00:00+00:00|2018-08-02 19:40:09.476702968+00:00|1|2018-08-03 02:31:55.915384295+00:00|1
396|092dc405a5c9318f88fa2a894ec712d34e7132bb456d8dc20516c4c4bbf09073||3849735|0|2|0001-01-01 00:00:00+00:00|0001-01-01 00:00:00+00:00|2018-08-03 02:32:23.975887182+00:00|0||0
sqlite>
sqlite3 output on a LXD 3.3 system:
sqlite> SELECT * FROM images;
34|7247ff2fcd4bb63820725b60049887d2ffcc8ee8e29d65f2a324e93bcd80d545|lxd.tar.xz|3781332|0|2|2018-08-02 00:00:00+00:00|1970-01-01 00:00:00+00:00|2018-08-03 02:35:31+00:00|1|2018-08-03 02:35:32+00:00|1
35|869429262d8d8bcd809b6ceba0b14ebcc1cd1c8497a16bf4ad29c788621021bf||3851627|0|2|0001-01-01 00:00:00+00:00|0001-01-01 00:00:00+00:00|2018-08-03 02:35:36+00:00|0||0
sqlite>
So the committed database data is correct, it's reading it back from the database that fails in go-dqlite
@cyberwillis note that deleting with lxc image delete c1 should work fine to get you unstuck.
it's true! my bad on the description...
@stgraber I'm probably missing something but I could not reproduce the issue (latest master code of everything):
free@x1:/srv/src/go/src/github.com/lxc/lxd/test/deps$ LXD_DIR=/tmp/lxd sudo -E /home/free/go/bin/lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]:
Name of the storage backend to use (btrfs, dir) [default=btrfs]: dir
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]: no
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]:
Would you like LXD to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes] no
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:
free@x1:/srv/src/go/src/github.com/lxc/lxd/test/deps$ LXD_DIR=/tmp/lxd sudo -E /home/free/go/bin/lxc init images:alpine/edge c1
Creating c1
The container you are starting doesn't have any network attached to it.
To create a new network, use: lxc network create
To attach a network to a container, use: lxc network attach
free@x1:/srv/src/go/src/github.com/lxc/lxd/test/deps$ LXD_DIR=/tmp/lxd sudo -E /home/free/go/bin/lxc publish c1 --alias c1
Container published with fingerprint: 869429262d8d8bcd809b6ceba0b14ebcc1cd1c8497a16bf4ad29c788621021bf
free@x1:/srv/src/go/src/github.com/lxc/lxd/test/deps$ LXD_DIR=/tmp/lxd sudo -E /home/free/go/bin/lxc image list
+-------+--------------+--------+------------------------------------+--------+--------+------------------------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | SIZE | UPLOAD DATE |
+-------+--------------+--------+------------------------------------+--------+--------+------------------------------+
| c1 | 869429262d8d | no | | x86_64 | 3.67MB | Aug 3, 2018 at 12:53pm (UTC) |
+-------+--------------+--------+------------------------------------+--------+--------+------------------------------+
| | 7247ff2fcd4b | no | Alpine edge amd64 (20180802_13:00) | x86_64 | 3.61MB | Aug 3, 2018 at 12:53pm (UTC) |
+-------+--------------+--------+------------------------------------+--------+--------+------------------------------+
free@x1:/srv/src/go/src/github.com/lxc/lxd/test/deps$
@freeekanayaka try on a system that's not on UTC time.
stgraber@castiana:~$ lxc image list
+-------+--------------+--------+---------------------------------------------+--------+----------+-------------------------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | SIZE | UPLOAD DATE |
+-------+--------------+--------+---------------------------------------------+--------+----------+-------------------------------+
| | 2a7896bae0f2 | no | ubuntu 16.04 LTS amd64 (release) (20180724) | x86_64 | 157.79MB | Jul 25, 2018 at 12:18am (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+-------------------------------+
| | 7247ff2fcd4b | no | Alpine edge amd64 (20180802_13:00) | x86_64 | 3.61MB | Aug 2, 2018 at 7:40pm (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+-------------------------------+
| | f8edf5d99112 | no | ubuntu 18.10 amd64 (daily) (20180802) | x86_64 | 174.66MB | Aug 3, 2018 at 2:35am (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+-------------------------------+
stgraber@castiana:~$ lxc init images:alpine/edge c1
Creating c1
stgraber@castiana:~$ lxc publish c1
Container published with fingerprint: 869429262d8d8bcd809b6ceba0b14ebcc1cd1c8497a16bf4ad29c788621021bf
stgraber@castiana:~$ lxc image list
Error: json: error calling MarshalJSON for type time.Time: Time.MarshalJSON: year outside of range [0,9999]
stgraber@castiana:~$ lxc image delete 869429262d8d8bcd809b6ceba0b14ebcc1cd1c8497a16bf4ad29c788621021bf
stgraber@castiana:~$ lxc image list
+-------+--------------+--------+---------------------------------------------+--------+----------+-------------------------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | SIZE | UPLOAD DATE |
+-------+--------------+--------+---------------------------------------------+--------+----------+-------------------------------+
| | 2a7896bae0f2 | no | ubuntu 16.04 LTS amd64 (release) (20180724) | x86_64 | 157.79MB | Jul 25, 2018 at 12:18am (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+-------------------------------+
| | 7247ff2fcd4b | no | Alpine edge amd64 (20180802_13:00) | x86_64 | 3.61MB | Aug 2, 2018 at 7:40pm (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+-------------------------------+
| | f8edf5d99112 | no | ubuntu 18.10 amd64 (daily) (20180802) | x86_64 | 174.66MB | Aug 3, 2018 at 2:35am (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+-------------------------------+
stgraber@castiana:~$
Bingo !
โ ~ lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]:
Name of the storage backend to use (btrfs, dir, lvm, zfs) [default=zfs]:
Create a new ZFS pool? (yes/no) [default=yes]:
Would you like to use an existing block device? (yes/no) [default=no]:
Size in GB of the new loop device (1GB minimum) [default=36GB]: 50
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]: no
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: br0
Would you like LXD to be available over the network? (yes/no) [default=no]: yes
Address to bind LXD to (not including port) [default=all]:
Port to bind LXD to [default=8443]:
Trust password for new clients:
Again:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes] no
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: no
โ ~ lxc launch ubuntu:16.04 c1
Creating c1
Starting c1
โ ~ lxc ls
+------+---------+---------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+---------+---------------------+------+------------+-----------+
| c1 | RUNNING | 192.168.1.41 (eth0) | | PERSISTENT | 0 |
+------+---------+---------------------+------+------------+-----------+
โ ~ lxc image ls
+-------+--------------+--------+---------------------------------------------+--------+----------+-----------------------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | SIZE | UPLOAD DATE |
+-------+--------------+--------+---------------------------------------------+--------+----------+-----------------------------+
| | 2a7896bae0f2 | no | ubuntu 16.04 LTS amd64 (release) (20180724) | x86_64 | 157.79MB | Aug 3, 2018 at 3:58pm (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+-----------------------------+
โ ~ lxd sql global "SELECT * FROM images;"
|id|fingerprint|filename|size|public|architecture|creation_date|expiry_date|upload_date|cached|last_use_date|auto_update|
|1|2a7896bae0f2322559e5b9452b0adf58a5a76f7b772fa6906c825407ea6c3386|ubuntu-16.04-server-cloudimg-amd64-lxd.tar.xz|1.65454668e+08|0|2|2018-07-23T21:00:00-03:00|2021-04-20T21:00:00-03:00| 2018-08-03T12:58:37.738155693-03:00|1|2018-08-03T12:58:37.822998126-03:00|1|
โ ~ lxc stop c1
โ ~ lxc publish c1 --alias=c1
Container published with fingerprint: 8420819c5a236f932f5d276d605c2e2f832c24d284a046b8a02d8c63b9d744e0
โ ~ lxd sql global "SELECT * FROM images;"
Error: json: error calling MarshalJSON for type time.Time: Time.MarshalJSON: year outside of range [0,9999]
โ ~ lxd sql global ".sync"
โ ~ sudo sqlite3 /var/lib/lxd/database/global/db.bin
SQLite version 3.24.0 2018-06-04 19:24:41
Enter ".help" for usage hints.
sqlite> SELECT * FROM images;
1|2a7896bae0f2322559e5b9452b0adf58a5a76f7b772fa6906c825407ea6c3386|ubuntu-16.04-server-cloudimg-amd64-lxd.tar.xz|165454668|0|2|2018-07-24 00:00:00+00:00|2021-04-21 00:00:00+00:00|2018-08-03 15:58:37.738155693+00:00|1|2018-08-03 15:58:37.822998126+00:00|1
2|8420819c5a236f932f5d276d605c2e2f832c24d284a046b8a02d8c63b9d744e0||205577424|0|2|0001-01-01 00:00:00+00:00|0001-01-01 00:00:00+00:00|2018-08-03 16:03:38.648482565+00:00|0||0
sqlite>
Updating my global db I could access it again
lxd sql global "UPDATE images SET last_use_date='2018-08-03 15:58:37.822998126+00:00' WHERE id='2';"
โ ~ lxc image ls
+-------+--------------+--------+---------------------------------------------+--------+----------+-----------------------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | SIZE | UPLOAD DATE |
+-------+--------------+--------+---------------------------------------------+--------+----------+-----------------------------+
| c1 | 8420819c5a23 | no | | x86_64 | 196.05MB | Aug 3, 2018 at 4:03pm (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+-----------------------------+
| | 2a7896bae0f2 | no | ubuntu 16.04 LTS amd64 (release) (20180724) | x86_64 | 157.79MB | Aug 3, 2018 at 3:58pm (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+-----------------------------+
At first only executing make deps and make won't solved, because the building process only updated dqlite sources temporarly. But updating manually CanonicalLtd/dqlite and CanonicalLtd/go-dqlite then executing make deps and make did the job. Thank you !
It's working.