Skip to content

Commit

Permalink
tests/container-copy: wait for host time to stabilize before creating VM
Browse files Browse the repository at this point in the history
This is attempting to avoid having the guest's time being behind the host:

```
==> Add the target VM as a remote LXD
++ lxc exec target -- lxc config trust add --name host --quiet
+ token=eyJjbGllbnRfbmFtZSI6Imhvc3QiLCJmaW5nZXJwcmludCI6IjY0NjRkZGY3MWIyZTZlZjRhNDBlYTZmY2ZlNzY5Nzg2Zjk0NDc5OTIyYmM4ZWM1OWU0YmMzZmJjZjEzZTM3YTAiLCJhZGRyZXNzZXMiOlsiMTAuMTAyLjExLjEzNTo4NDQzIiwiW2ZkNDI6OTMxODo0YWQ0OmRiY2Q6MjE2OjNlZmY6ZmUxZDo5ZTkyXTo4NDQzIiwiMTAuMTA3LjI1MC4xOjg0NDMiLCJbZmQ0MjplZDc4OjcyYTI6OGRjMzo6MV06ODQ0MyJdLCJzZWNyZXQiOiI2ZTIzOTcxMmRjZGY0YzEzZmZmYWZhOWI5ZTkyNDdlNGZhZjE2MTQ2YzFjMmZhYTE2ZjIzZTllM2ZmNzZlN2NjIiwiZXhwaXJlc19hdCI6IjAwMDEtMDEtMDFUMDA6MDA6MDBaIn0=
+ lxc remote add target eyJjbGllbnRfbmFtZSI6Imhvc3QiLCJmaW5nZXJwcmludCI6IjY0NjRkZGY3MWIyZTZlZjRhNDBlYTZmY2ZlNzY5Nzg2Zjk0NDc5OTIyYmM4ZWM1OWU0YmMzZmJjZjEzZTM3YTAiLCJhZGRyZXNzZXMiOlsiMTAuMTAyLjExLjEzNTo4NDQzIiwiW2ZkNDI6OTMxODo0YWQ0OmRiY2Q6MjE2OjNlZmY6ZmUxZDo5ZTkyXTo4NDQzIiwiMTAuMTA3LjI1MC4xOjg0NDMiLCJbZmQ0MjplZDc4OjcyYTI6OGRjMzo6MV06ODQ0MyJdLCJzZWNyZXQiOiI2ZTIzOTcxMmRjZGY0YzEzZmZmYWZhOWI5ZTkyNDdlNGZhZjE2MTQ2YzFjMmZhYTE2ZjIzZTllM2ZmNzZlN2NjIiwiZXhwaXJlc19hdCI6IjAwMDEtMDEtMDFUMDA6MDA6MDBaIn0= --accept-certificate
Generating a client certificate. This may take a minute...
Error: Failed to create certificate: The provided certificate isn't valid yet
```

In there ^, the host creates a certificate with a `Not Before` time that is in
the future from a guest's point of view.

Signed-off-by: Simon Deziel <[email protected]>
  • Loading branch information
simondeziel committed May 2, 2024
1 parent ec914d0 commit cc65711
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/container-copy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ loopdev="$(losetup --show --find "${loopimg}")"
# Begin Test.
set -x

echo "==> Wait for the host time to be synchronized with NTP"
for _ in $(seq 6); do
[ "$(timedatectl show --property=NTPSynchronized --value)" = "yes" ] && break
sleep 10
done

echo "==> Launch a VM which will be the target of the copy"
lxc launch "${IMAGE}" target --vm
waitInstanceBooted target
Expand Down

0 comments on commit cc65711

Please sign in to comment.