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

vfkit: Enable timesync #3416

Merged
merged 3 commits into from Dec 1, 2022
Merged

vfkit: Enable timesync #3416

merged 3 commits into from Dec 1, 2022

Conversation

cfergeau
Copy link
Contributor

On macOS, after a host suspend, the guest clock will be out of sync.
vfkit 0.0.4 has a --timesync feature, which resyncs the guest clock when the
host comes out of sleep. This PR makes use of it.

@openshift-ci
Copy link

openshift-ci bot commented Nov 15, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfergeau

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cfergeau
Copy link
Contributor Author

To test this, you need these podman bundles https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/origin-ci-test/pr-logs/pull/crc-org_snc/595/pull-ci-crc-org-snc-podman-e2e-snc/1588460383008460800/artifacts/e2e-snc/gather-snc/artifacts/bundles.txt
If testing on a macbook, it's easier to test if it's not plugged in, otherwise I never know when it sleeps or not. Suspend the laptop for a few minutes, connect to the crc VM, and check date. It should be up to date, not lagging by the amount of time the mac slept.

// when loading a VM created by a crc version predating this commit,
// d.VsockQemuGAPort will be missing from ~/.crc/machines/crc/config.json
// In such a case, assume the VM will not support time sync
if d.VsockQemuGAPort != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense...

perhaps something that can also be detected in the main binary ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to detect it there, having a workaround for crc's behaviour in vfkit's code would be odd.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that you can't report back from the driver that this isn't possible.
We would like to inform the user about this error in some form... or we assume this will never happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's something specific to the machine driver. With an older crc, you run crc start; crc stop, the machine driver state is serialized to json, and does not contain a VsockQemuGAPort field because this did not exist when it was built.
Then crc start is ran with a new crc build which looks for VsockQemuGAPort in the serialized json. It will get 0 instead of the expected value since the field was not present.

// d.VsockQemuGAPort will be missing from ~/.crc/machines/crc/config.json
// In such a case, assume the VM will not support time sync
if d.VsockQemuGAPort != 0 {
timesync, err := client.TimeSyncNew(d.VsockQemuGAPort)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the device we add is not really timesync, but the guest agent. timesyncing is just one (only) of the features used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's more 'timesync' than just guest agent. The guest agent connection is not exposed externally, it's a net.Conn instance internal to vfkit. And vfkit monitors for wake up events, and sends a set-time $current_time command to the guest agent if present.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is the case, naming should represent that; GuestAgentForTimesync in some form inside the codebase.

Copy link
Contributor Author

@cfergeau cfergeau Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe VsockQemuGAPort -> VsockTimesyncPort?

@anjannath
Copy link
Member

To test this, you need these podman bundles https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/origin-ci-test/pr-logs/pull/crc-org_snc/595/pull-ci-crc-org-snc-podman-e2e-snc/1588460383008460800/artifacts/e2e-snc/gather-snc/artifacts/bundles.txt

this is not available for downloading anymore it seems, getting error when visiting the bundle links from the file

Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object. Permission 'storage.objects.get' denied on resource (or it may not exist)

This branch has the code for host->guest time synchronization.
It's currently hardcoded in the libvirt and vfkit drivers.
This centralizes its value in a single place
On macOS, after a host suspend, the guest clock will be out of sync.
vfkit has a --timesync feature, which resyncs the guest clock when the
host comes out of sleep.
This commit makes use of it.
@openshift-ci
Copy link

openshift-ci bot commented Nov 22, 2022

@cfergeau: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-crc 9955798 link true /test e2e-crc

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@praveenkumar
Copy link
Member

Created bundle manually and tested it, works as expected.

Without this PR (current main), time skew happens

== Before putting laptop to sleep==
$ date -u
Thu Dec  1 11:43:59 UTC 2022
$ ssh crc -- date  
Thu Dec  1 11:44:04 UTC 2022

==After waking from sleep==
$  date -u        
Thu Dec  1 13:04:37 UTC 2022
$ ssh crc -- date
Thu Dec  1 11:45:08 UTC 2022

With this PR

== Before putting laptop to sleep==
$ date -u
Thu Dec  1 10:49:02 UTC 2022
$ ssh crc -- date
Thu Dec  1 10:49:06 UTC 2022

==After waking from sleep==
$ date -u
Thu Dec  1 11:33:51 UTC 2022
$ ssh crc -- date
Thu Dec  1 11:33:55 UTC 2022

@praveenkumar praveenkumar merged commit db63999 into crc-org:main Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants