Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/container-copy: wait for host time to stabilize before creating VM #168

Merged
merged 2 commits into from
May 2, 2024

Conversation

simondeziel
Copy link
Member

@simondeziel simondeziel commented May 2, 2024

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.

This is a workaround for canonical/lxd#13388. If that workaround is not enough, another workaround would be to create pre-create the client cert, wait a while and then asking/use a join token to then inject the then "old" certificate.

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]>
@simondeziel simondeziel marked this pull request as ready for review May 2, 2024 17:04
@simondeziel simondeziel requested a review from tomponline May 2, 2024 17:11
@tomponline tomponline merged commit 8d05471 into canonical:main May 2, 2024
63 checks passed
@simondeziel simondeziel deleted the clock-difference branch May 2, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants