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

Rancher-Destop linux subsystem clock stop ticking when laptop goes to sleep. #4956

Open
phuot opened this issue Jun 14, 2023 · 3 comments
Open
Labels
kind/bug Something isn't working

Comments

@phuot
Copy link

phuot commented Jun 14, 2023

Actual Behavior

I have rancher-desktop version 1.8.1 installed in a dell laptop running windows 11.
When computer goes to sleep the rancher-destop linux subsystem clock stops to tick.
After the sleep if I type date to the rancher-desktop linux subsystem, I see a skewed date.
Running sudo hwclock -s fix the clock, but then on next sleep the issue happens again.

Steps to Reproduce

  • Install rancher-desktop version 1.8.1 on an windows 11 laptop.
  • put your laptop to sleep and wait some time
  • in a terminal type C:\WINDOWS\system32\wsl.exe -d rancher-desktop to open the rancher-desktop linux console
  • type date and notice that the date time is wrong
  • type sudo hwclock -s
  • type date and notice that the date is now ok

Result

date is wrong

Expected Behavior

date should be synchronized back when computer return from sleep.

Additional Information

No response

Rancher Desktop Version

1.8.1

Rancher Desktop K8s Version

1.26.5

Which container engine are you using?

containerd (nerdctl)

What operating system are you using?

Windows

Operating System / Build Version

windows 11 Pro (22h2 build 22621.1702)

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

No response

@phuot phuot added the kind/bug Something isn't working label Jun 14, 2023
@s0nea
Copy link

s0nea commented Jun 15, 2023

Hi @phuot,

Thank you for reporting the issue!

I did some research on the internet and found e.g. the following:

It seems like a problem in WSL. I know that's not a solution, yet. I'm wondering if we can make use of one of the workarounds mentioned in microsoft/WSL#10006.

@phuot
Copy link
Author

phuot commented Jun 20, 2023

I tried a couple of workarounds from the links above and the issue seems mitigated on my system (clock was not skewed in the last days). Here is what I tried:

  • open windows terminal and type the following
    wsl sudo nano /etc/wsl.conf
  • I needed to provide my linux password
  • add the following to the wsl.conf, save and close.
    [boot]
    command="ntpdate ntp.ubuntu.com"
    
  • restart the machine
  • note that this was supposed to fix by running a process that update the clock on every linux system start, but did not work for me. (still mentioned the steps since it seems that it worked for some people and I am not sure if only the next step is required to fix or if it is due to a combination of both steps.)

Next step is to add a task that runs each time the windows host machine come back to sleep. This task would call a command that would update the clock.

  • Make sure that the script that would update the clock could be ran without having to provide a password (if default user is not root)
    • open windows terminal and type wsl sudo visudo (and provide your linux password if asked)
    • Add the following line at the end of the file, save and exit
      %sudo ALL=(ALL) NOPASSWD: /usr/sbin/hwclock
  • Create a batch file in your windos machine (ex: c:\sync-clock.bat) and add the following content
    @echo off
    wsl sudo hwclock -s
    wsl -d rancher-desktop sudo hwclock -s
    
  • note that I was not sure if we needed to target only the WSL or the specific rancher-desktop container, we might just need one of those 2 lines, but having both worked for me
  • Create a task in the task scheduler that calls this script each time the system go back from sleep
    • Open the Task Scheduler and create a new "Basic Task".
    • Set the trigger to "When a specific event is logged" and click "Next".
    • Under "Log", select System.
    • Under "Source", select Kernel-Power.
    • Under "Event ID", type "507".
    • Under "action", select "Start a program" and click "next"
    • Specify the batch file we just created: C:\sync-clock.bat.

@mook-as
Copy link
Contributor

mook-as commented Jun 20, 2023

Hmm, it looks like we can detect machine resume from Electron; we may be able to run hwclock there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants